/**
 * Auth Modal — compact login / register / forgot password
 */

/* ── Modal shell ── */
.auth-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    animation: authFadeIn 0.18s ease-out;
}

.auth-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}

@keyframes authFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.auth-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
}

.auth-modal-content {
    position: relative;
    z-index: 10001;
    width: min(100%, 520px);
    max-width: 520px;
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    padding: 1.65rem 1.75rem 1.5rem;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
    animation: authSlideUp 0.22s ease-out;
    -webkit-overflow-scrolling: touch;
}

.auth-modal-content--tall {
    width: min(100%, 640px);
    max-width: 640px;
    padding: 1.75rem 2rem 1.6rem;
}

@media (min-width: 768px) {
    .auth-modal-content {
        width: min(92vw, 600px);
        max-width: 600px;
        padding: 2rem 2.25rem 1.75rem;
    }

    .auth-modal-content--tall {
        width: min(92vw, 720px);
        max-width: 720px;
        padding: 2.15rem 2.5rem 1.9rem;
    }

    .auth-modal-header {
        margin-bottom: 1.35rem;
    }

    .auth-modal-header h2 {
        font-size: 1.5rem;
    }

    .auth-modal-header p {
        font-size: 0.9375rem;
    }

    .auth-field {
        gap: 0.45rem;
    }

    .auth-field label {
        font-size: 0.8125rem;
    }

    .auth-field .form-control,
    .auth-form .form-control {
        font-size: 1.0625rem;
        padding: 0.9rem 1.05rem;
        min-height: 3rem;
    }

    .auth-form .btn-primary.btn-block {
        font-size: 1.0625rem;
        padding: 1rem 1.25rem;
        min-height: 3.15rem;
    }

    .auth-form-grid {
        gap: 0.85rem 1rem;
    }
}

@keyframes authSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-modal-close {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-400, #9ca3af);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.auth-modal-close:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-700, #374151);
}

.auth-modal-close svg {
    width: 18px;
    height: 18px;
}

/* ── Header ── */
.auth-modal-header {
    padding-right: 1.75rem;
    margin-bottom: 0.875rem;
}

.auth-modal-header h2 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--gray-900, #111827);
    letter-spacing: -0.01em;
}

.auth-modal-header p {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--gray-500, #6b7280);
}

/* ── Form ── */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.auth-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

@media (max-width: 400px) {
    .auth-form-grid {
        grid-template-columns: 1fr;
    }
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.auth-field label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gray-500, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.auth-field .form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.35;
    color: var(--gray-900, #111827);
    background: var(--gray-50, #f9fafb);
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.auth-field .form-control:hover {
    border-color: var(--gray-300, #d1d5db);
    background: #fff;
}

.auth-field .form-control:focus {
    border-color: var(--primary, #ed4b25);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 237, 75, 37), 0.12);
}

.auth-field .form-control::placeholder {
    color: var(--gray-400, #9ca3af);
}

/* Legacy class support */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.form-group label {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--gray-500, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.35;
    color: var(--gray-900, #111827);
    background: var(--gray-50, #f9fafb);
    outline: none;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.form-control:hover {
    border-color: var(--gray-300, #d1d5db);
    background: #fff;
}

.form-control:focus {
    border-color: var(--primary, #ed4b25);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 237, 75, 37), 0.12);
}

.form-control::placeholder {
    color: var(--gray-400, #9ca3af);
}

.form-help {
    font-size: 0.6875rem;
    color: var(--gray-400, #9ca3af);
    line-height: 1.3;
}

/* Login extras row */
.auth-form-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: -0.125rem;
}

.link-primary {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary, #ed4b25);
    text-decoration: none;
}

.link-primary:hover {
    text-decoration: underline;
}

/* Terms */
.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: 0.4375rem;
    margin: 0.125rem 0 0;
    font-size: 0.6875rem;
    line-height: 1.35;
    color: var(--gray-500, #6b7280);
    cursor: pointer;
}

.auth-terms input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin-top: 1px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary, #ed4b25);
}

.auth-terms a {
    color: var(--primary, #ed4b25);
    font-weight: 600;
    text-decoration: none;
}

.auth-terms a:hover {
    text-decoration: underline;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.4375rem;
    font-size: 0.6875rem;
    line-height: 1.35;
    color: var(--gray-500, #6b7280);
    cursor: pointer;
    margin: 0.125rem 0 0;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: var(--primary, #ed4b25);
}

.checkbox-label a {
    color: var(--primary, #ed4b25);
    font-weight: 600;
    text-decoration: none;
}

/* Submit */
.auth-form .btn-primary.btn-block {
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.5625rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: var(--primary, #ed4b25);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.auth-form .btn-primary.btn-block:hover {
    background: var(--primary-dark, #d9431f);
}

.auth-form .btn-primary.btn-block:active {
    transform: scale(0.99);
}

.auth-form .btn-primary.btn-block:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Footer switch — no divider */
.auth-footer {
    margin: 0.625rem 0 0;
    padding-top: 0.625rem;
    border-top: 1px solid var(--gray-100, #f3f4f6);
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-500, #6b7280);
}

.auth-footer a,
.auth-switch a {
    color: var(--primary, #ed4b25);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer a:hover,
.auth-switch a:hover {
    text-decoration: underline;
}

.auth-switch {
    margin: 0.625rem 0 0;
    padding-top: 0.625rem;
    border-top: 1px solid var(--gray-100, #f3f4f6);
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-500, #6b7280);
}

/* Hide old divider */
.auth-divider {
    display: none;
}

/* Alerts */
.auth-error,
.auth-success {
    padding: 0.5rem 0.625rem;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.4;
}

.auth-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.auth-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.auth-spinner {
    display: inline-block;
    animation: authSpin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes authSpin {
    to { transform: rotate(360deg); }
}

/* ── Header auth buttons (unchanged behaviour) ── */
.auth-buttons {
    display: none;
    align-items: center;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .auth-buttons {
        display: flex;
    }
}

.btn-link {
    background: none;
    border: none;
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-link:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.btn-online-payment {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-online-payment:hover {
    background: var(--primary);
    color: #fff;
}

@media (max-width: 900px) {
    .btn-online-payment__label { display: none; }
    .btn-online-payment { padding: 0.45rem 0.65rem; }
}

.mobile-menu-link--payment {
    font-weight: 600;
    color: var(--primary) !important;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 0.25rem;
}

/* Header CTA — not modal submit */
.auth-buttons .btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.auth-buttons .btn-primary:hover {
    background: var(--primary-dark, #e64f00);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 237, 75, 37), 0.25);
}

/* User menu */
.user-menu { position: relative; }

.user-menu-toggle {
    background: white;
    border: 1.5px solid var(--gray-200);
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-menu-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.125rem);
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 160px;
    padding: 0.125rem;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.user-menu:hover .user-dropdown,
.user-menu-toggle:focus + .user-dropdown {
    display: flex;
}

.user-dropdown a {
    color: var(--gray-700);
    text-decoration: none;
    padding: 0.375rem 0.625rem;
    border-radius: 3px;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.user-dropdown a svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.user-dropdown a:hover svg { opacity: 1; }
.user-dropdown a:hover { background: var(--gray-100); }
.user-dropdown a.text-danger { color: #ef4444; }
.user-dropdown a.text-danger:hover { background: #fef2f2; }

/* Mobile */
@media (max-width: 480px) {
    .auth-modal-content {
        padding: 1rem;
        border-radius: 10px;
    }
}
