/* ==========================================================================
   Auth modals (sign in / create account) — mobile first
   Brand tokens come from style.css (--qu-*).
   ========================================================================== */

:root {
    --am-primary: var(--qu-primary, #1E3A8A);
    --am-primary-deep: #16295E;
    --am-accent: var(--qu-accent, #3B82F6);
    --am-tint: var(--qu-badge-bg, #EFF6FF);
    --am-ink: var(--qu-text-dark, #111827);
    --am-muted: var(--qu-text-muted, #6B7280);
    --am-border: var(--qu-border-color, #E5E7EB);
    --am-danger: #DC2626;
    --am-success: #059669;
}

.auth-modal-dialog {
    max-width: 440px;
    margin: .75rem auto;
}

.auth-modal-content {
    position: relative;
    border: none;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
}

.auth-modal-close {
    position: absolute;
    top: .7rem;
    right: .7rem;
    z-index: 3;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color .16s ease;
}
.auth-modal-close:hover { background: rgba(255, 255, 255, .3); }
.auth-modal-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Head
   -------------------------------------------------------------------------- */
.auth-modal-head {
    padding: 1.5rem 1.35rem 1.35rem;
    text-align: center;
    background:
        radial-gradient(460px 180px at 100% -40%, rgba(59, 130, 246, .38), transparent 62%),
        linear-gradient(135deg, var(--am-primary) 0%, var(--am-primary-deep) 100%);
    color: #fff;
}
.auth-modal-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: .7rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .22);
}
.auth-modal-mark img { width: 30px; height: 30px; object-fit: contain; }
.auth-modal-title {
    margin: 0 0 .3rem;
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 1.32rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: #fff;
}
.auth-modal-subtitle {
    margin: 0;
    font-size: .82rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, .72);
}

/* --------------------------------------------------------------------------
   Body
   -------------------------------------------------------------------------- */
.auth-modal-body {
    padding: 1.35rem 1.35rem 1.5rem;
    background: #fff;
}

.auth-feedback {
    border-radius: 10px;
    padding: .6rem .8rem;
    margin-bottom: 1rem;
    font-size: .82rem;
    font-weight: 500;
}
.auth-feedback.is-success {
    background: #F0FDF4;
    border: 1px solid #DCFCE7;
    color: #15803D;
}
.auth-feedback.is-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--am-danger);
}

/* Two-up field grid so the form stays short. */
.auth-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 .85rem;
}
.auth-grid .auth-field.is-full { grid-column: 1 / -1; }

.auth-field { margin-bottom: .95rem; }
.auth-field > label {
    display: block;
    margin-bottom: .35rem;
    font-size: .78rem;
    font-weight: 700;
    color: #374151;
}

.auth-input-wrap { position: relative; }
.auth-input-icon {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: #9CA3AF;
    pointer-events: none;
    transition: color .16s ease;
}
.auth-input {
    width: 100%;
    min-height: 48px;
    padding: .7rem .9rem .7rem 2.4rem;
    border: 1.5px solid var(--am-border);
    border-radius: 11px;
    background: #fff;
    color: var(--am-ink);
    font-size: 16px; /* stops iOS Safari zooming on focus */
    font-weight: 500;
    line-height: 1.4;
    transition: border-color .16s ease, box-shadow .16s ease;
}
.auth-input::placeholder { color: #A9B2BF; font-weight: 400; }
.auth-input:hover { border-color: #CBD5E1; }
.auth-input:focus {
    outline: none;
    border-color: var(--am-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.auth-input:focus + .auth-input-icon,
.auth-input-wrap:focus-within .auth-input-icon { color: var(--am-primary); }

.auth-input-toggle {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: none;
    color: #9CA3AF;
    cursor: pointer;
}
.auth-input-toggle:hover { background: #F3F4F6; color: var(--am-primary); }
.auth-input-toggle:focus-visible { outline: 2px solid var(--am-accent); outline-offset: 1px; }
/* Toggle sits inside the field, so keep text clear of it. */
.auth-input-wrap:has(.auth-input-toggle) .auth-input { padding-right: 2.9rem; }

.auth-hint {
    display: block;
    margin-top: .3rem;
    font-size: .72rem;
    color: #9CA3AF;
}
.auth-error {
    display: none;
    margin-top: .3rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--am-danger);
}
.auth-field.is-invalid .auth-input { border-color: var(--am-danger); }
.auth-field.is-invalid .auth-input-icon { color: var(--am-danger); }
.auth-field.is-invalid .auth-error { display: block; }
.auth-field.is-invalid .auth-hint { display: none; }

/* Terms checkbox */
.auth-terms { margin-top: 1.1rem; margin-bottom: 1.1rem; }
.auth-check {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    cursor: pointer;
    margin: 0;
}
.auth-check input { position: absolute; opacity: 0; pointer-events: none; }
.auth-check-box {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #CBD5E1;
    border-radius: 6px;
    background: #fff;
    color: transparent;
    font-size: .7rem;
    transition: background-color .14s ease, border-color .14s ease, color .14s ease;
}
.auth-check input:checked + .auth-check-box {
    background: var(--am-primary);
    border-color: var(--am-primary);
    color: #fff;
}
.auth-check input:focus-visible + .auth-check-box {
    outline: 2px solid var(--am-accent);
    outline-offset: 2px;
}
.auth-check-text {
    font-size: .8rem;
    line-height: 1.45;
    color: var(--am-muted);
}
.auth-check-text a {
    color: var(--am-primary);
    font-weight: 700;
    text-decoration: none;
}
.auth-check-text a:hover { text-decoration: underline; }
.auth-field.is-invalid .auth-check-box { border-color: var(--am-danger); }

/* Submit */
.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    width: 100%;
    min-height: 50px;
    border: none;
    border-radius: 11px;
    background: var(--am-primary);
    color: #fff;
    font-size: .93rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .16s ease, transform .12s ease, box-shadow .12s ease;
}
.auth-submit:hover:not(:disabled) {
    background: var(--am-primary-deep);
    box-shadow: 0 8px 20px rgba(30, 58, 138, .28);
}
.auth-submit:active:not(:disabled) { transform: translateY(1px); }
.auth-submit:focus-visible { outline: 2px solid var(--am-accent); outline-offset: 2px; }
.auth-submit:disabled { opacity: .65; cursor: not-allowed; }

.auth-alt {
    margin: 1.05rem 0 0;
    text-align: center;
    font-size: .82rem;
    color: var(--am-muted);
}
.auth-alt a {
    color: var(--am-primary);
    font-weight: 700;
    text-decoration: none;
}
.auth-alt a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Split layout (login) — brand panel is desktop-only
   -------------------------------------------------------------------------- */
.auth-split { display: block; }
.auth-brand { display: none; }
.auth-split-form { background: #fff; }

.auth-mobile-head {
    padding: 1.4rem 1.35rem 1.1rem;
    margin: -1.35rem -1.35rem 1.1rem;
    text-align: center;
    background:
        radial-gradient(460px 180px at 100% -40%, rgba(59, 130, 246, .38), transparent 62%),
        linear-gradient(135deg, var(--am-primary) 0%, var(--am-primary-deep) 100%);
    color: #fff;
}
.auth-mobile-title {
    margin: 0 0 .25rem;
    font-family: var(--font-display, 'Outfit', sans-serif);
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}
.auth-mobile-subtitle {
    margin: 0;
    font-size: .8rem;
    color: rgba(255, 255, 255, .72);
}

.auth-brand-list {
    list-style: none;
    margin: 1.4rem 0 0;
    padding: 0;
}
.auth-brand-list li {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .83rem;
    color: rgba(255, 255, 255, .82);
}
.auth-brand-list li + li { margin-top: .7rem; }
.auth-brand-list i {
    flex: none;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: .9rem;
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .3rem;
    padding: .3rem;
    margin-bottom: 1.1rem;
    background: #F3F4F6;
    border-radius: 12px;
}
.auth-tabs .login-tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 40px;
    padding: .5rem .75rem;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--am-muted);
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.auth-tabs .login-tab-btn:hover { color: var(--am-primary); }
.auth-tabs .login-tab-btn.active {
    background: #fff;
    color: var(--am-primary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.auth-tabs .login-tab-btn i { font-size: .95rem; }

/* --------------------------------------------------------------------------
   Rows, links, OTP
   -------------------------------------------------------------------------- */
.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin: 0 0 1.1rem;
}
.auth-inline-link {
    background: none;
    border: none;
    padding: 0;
    font-size: .8rem;
    font-weight: 700;
    color: var(--am-primary);
    text-decoration: none;
    cursor: pointer;
}
.auth-inline-link:hover { text-decoration: underline; }

.auth-otp-head {
    text-align: center;
    margin-bottom: 1.1rem;
}
.auth-otp-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-bottom: .5rem;
    border-radius: 50%;
    background: var(--am-tint);
    color: var(--am-primary);
    font-size: 1.3rem;
}
.auth-otp-head p {
    margin: 0;
    font-size: .83rem;
    color: var(--am-muted);
}
.auth-otp-head span { font-weight: 700; color: var(--am-ink); }

.otp-digit-group {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .4rem;
}
.otp-digit-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 44px;
    text-align: center;
    border: 1.5px solid var(--am-border);
    border-radius: 10px;
    background: #fff;
    color: var(--am-ink);
    font-size: 1.1rem;
    font-weight: 700;
    transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.otp-digit-box:focus {
    outline: none;
    border-color: var(--am-accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .16);
}
.otp-digit-box.is-filled {
    border-color: var(--am-primary);
    background: var(--am-tint);
    color: var(--am-primary);
}

.auth-timer {
    font-size: .78rem;
    color: var(--am-muted);
    font-variant-numeric: tabular-nums;
}

.auth-ghost-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 100%;
    min-height: 42px;
    margin-top: .6rem;
    border: 1px solid var(--am-border);
    border-radius: 10px;
    background: #fff;
    color: var(--am-muted);
    font-size: .83rem;
    font-weight: 600;
    cursor: pointer;
}
.auth-ghost-btn:hover { background: #F9FAFB; color: var(--am-primary); }

/* Bootstrap alert classes are toggled by the existing login JS. */
.auth-feedback.alert-success {
    background: #F0FDF4;
    border-color: #DCFCE7;
    color: #15803D;
}
.auth-feedback.alert-danger {
    background: #FEF2F2;
    border-color: #FECACA;
    color: var(--am-danger);
}

/* --------------------------------------------------------------------------
   >= 576px
   -------------------------------------------------------------------------- */
@media (min-width: 576px) {
    .auth-modal-dialog { margin: 1.75rem auto; }
    .auth-modal-dialog.is-wide { max-width: 560px; }
    .auth-modal-head { padding: 1.9rem 1.75rem 1.6rem; }
    .auth-modal-body { padding: 1.6rem 1.75rem 1.75rem; }
    .auth-modal-title { font-size: 1.45rem; }

    /* Two fields per row once there is room for them. */
    .auth-grid { grid-template-columns: 1fr 1fr; }

    .auth-mobile-head {
        margin: -1.6rem -1.75rem 1.3rem;
        padding: 1.5rem 1.75rem 1.2rem;
    }
}

/* --------------------------------------------------------------------------
   >= 768px — the login modal opens into two panels
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
    .auth-modal-dialog.is-split { max-width: 780px; }

    .auth-split {
        display: grid;
        grid-template-columns: 1fr 1fr;
        min-height: 480px;
    }

    .auth-brand {
        display: flex;
        align-items: center;
        position: relative;
        overflow: hidden;
        padding: 2rem 1.85rem;
        background:
            radial-gradient(520px 240px at 110% -20%, rgba(59, 130, 246, .45), transparent 62%),
            linear-gradient(150deg, var(--am-primary) 0%, var(--am-primary-deep) 100%);
        color: #fff;
    }
    .auth-brand-inner { position: relative; z-index: 1; }
    .auth-brand .auth-modal-title,
    .auth-brand .auth-modal-subtitle { text-align: left; }
    .auth-brand .auth-modal-subtitle { font-size: .85rem; }
    .auth-brand .auth-modal-mark {
        margin-bottom: 1rem;
        font-size: 1.5rem;
        color: #fff;
    }

    .auth-split-form { display: flex; align-items: center; }
    .auth-split-form .auth-modal-body { width: 100%; padding: 2rem 1.85rem; }

    /* The brand panel carries the greeting on desktop. */
    .auth-mobile-head { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-input,
    .auth-submit,
    .auth-check-box,
    .auth-modal-close { transition: none !important; }
    .auth-submit:active:not(:disabled) { transform: none; }
}
