/* ============================================
   PrepTutorAI Auth Pages — Dark Theme
   ============================================ */

/* --- Custom Properties --- */
:root {
    /* Dark backgrounds */
    --bg-base:         #0D0A1A;
    --bg-card:         #131029;
    --bg-input:        #1A1635;
    --bg-input-hover:  #1E1A3D;
    --bg-alert-error:  rgba(255, 107, 107, 0.1);
    --bg-alert-success: rgba(123, 237, 111, 0.08);

    /* Text */
    --text-primary:   #F0EBF8;
    --text-secondary: #9F94C0;
    --text-muted:     #8A80A8; /* upgraded from #6B6087 for WCAG AA contrast on dark bg */

    /* Brand accents */
    --color-coral:  #FF6B6B;
    --color-pink:   #FF36AB;
    --color-purple: #8B5CF6;
    --color-cyan:   #00D4FF;
    --color-yellow: #FFD93D;
    --color-lime:   #7BED6F;

    /* Gradients */
    --gradient-cta:  linear-gradient(135deg, #FF6B6B 0%, #FF36AB 100%);
    --gradient-logo: linear-gradient(135deg, #FF6B6B 0%, #FF36AB 100%);
    --gradient-text: linear-gradient(135deg, #FF6B6B 0%, #8B5CF6 50%, #00D4FF 100%);

    /* Borders */
    --border-card:    rgba(255, 255, 255, 0.07);
    --border-input:   rgba(255, 255, 255, 0.1);
    --border-focus:   rgba(255, 107, 107, 0.55);
    --border-error:   rgba(255, 107, 107, 0.75);
    --border-success: rgba(123, 237, 111, 0.5);

    /* Shadows */
    --shadow-card:        0 24px 64px rgba(0, 0, 0, 0.55),
                          0 0 0 1px var(--border-card),
                          inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --shadow-btn:         0 4px 20px rgba(255, 107, 107, 0.4);
    --shadow-btn-hover:   0 8px 40px rgba(255, 107, 107, 0.55);
    --shadow-input-focus: 0 0 0 3px rgba(255, 107, 107, 0.15);
    --shadow-input-error: 0 0 0 3px rgba(255, 107, 107, 0.12);

    /* Typography */
    --font-body:    'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Fredoka', 'Nunito', sans-serif;
    --auth-font:    'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Focus ring — WCAG-compliant blue, visible on dark backgrounds */
    --color-focus: #58a6ff;

    /* Transitions */
    --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --t-fast:   150ms;
    --t-normal: 300ms;

    /* Radii */
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   18px;
    --radius-xl:   24px;
    --radius-full: 9999px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100dvh;
}

img, svg { display: block; max-width: 100%; }
a        { color: inherit; text-decoration: none; }
button   { border: none; background: none; cursor: pointer; font-family: inherit; font-size: inherit; color: inherit; }

/* --- Focus States --- */
:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ============================================
   Layout — Auth Page
   ============================================ */
.auth-page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 2rem 1.25rem;
    font-family: var(--auth-font);
}

/* Ambient background glows */
.auth-glow {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
}

.auth-glow--top {
    top: -15%;
    right: -10%;
    width: min(55vw, 560px);
    height: min(55vw, 560px);
    background: radial-gradient(circle, rgba(255, 107, 107, 0.15) 0%, transparent 70%);
}

.auth-glow--bottom {
    bottom: -15%;
    left: -10%;
    width: min(50vw, 480px);
    height: min(50vw, 480px);
    background: radial-gradient(circle, rgba(139, 92, 246, 0.13) 0%, transparent 70%);
}

/* Wrapper — logo + card stacked */
.auth-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* ============================================
   Brand / Logo
   ============================================ */
.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    transition: opacity var(--t-normal) var(--ease-out);
}

.auth-brand:hover { opacity: 0.85; }

.auth-brand__icon {
    flex-shrink: 0;
    border-radius: 10px;
    overflow: visible;
    /* Subtle drop shadow on the logo mark */
    filter: drop-shadow(0 4px 12px rgba(255, 107, 107, 0.35));
}

.auth-brand__name {
    font-family: var(--auth-font);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    /* Brand gradient text */
    background: var(--gradient-logo);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-brand-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
}

.auth-brand__tagline {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ============================================
   Auth Card
   ============================================ */
.auth-card {
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    padding: 2.25rem 2rem;
    border: 1px solid var(--border-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    /* Subtle gradient wash inside the card */
    background-image: linear-gradient(
        160deg,
        rgba(255, 107, 107, 0.03) 0%,
        transparent 40%,
        rgba(139, 92, 246, 0.03) 100%
    );
}

.auth-card__header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-card__title {
    font-family: var(--auth-font);
    font-size: 1.875rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.375rem;
    /* Subtle white-to-lavender gradient on the heading */
    background: linear-gradient(135deg, #F0EBF8 0%, #C4B8E8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-card__subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.auth-card__footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-card);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--color-coral);
    font-weight: 600;
    transition: color var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}

.auth-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   Alert Banners
   ============================================ */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.45;
    margin-bottom: 1.25rem;
    animation: alertSlideIn var(--t-normal) var(--ease-out);
}

.auth-alert[hidden] { display: none; }

.auth-alert__icon {
    flex-shrink: 0;
    margin-top: 1px;
    width: 18px;
    height: 18px;
}

.auth-alert--error {
    background: var(--bg-alert-error);
    border: 1px solid rgba(255, 107, 107, 0.25);
    color: #FF9A9A;
}

.auth-alert--error .auth-alert__icon { color: var(--color-coral); }

.auth-alert--success {
    background: var(--bg-alert-success);
    border: 1px solid rgba(123, 237, 111, 0.2);
    color: #9FEF99;
}

.auth-alert--success .auth-alert__icon { color: var(--color-lime); }

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Auth Nav Status — hash fallback recovery message
   ============================================ */
.auth-nav-status {
    font-size: 0.875rem;
    color: var(--color-yellow);
    background: rgba(255, 211, 61, 0.07);
    border: 1px solid rgba(255, 211, 61, 0.2);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    line-height: 1.45;
    animation: alertSlideIn var(--t-normal) var(--ease-out);
}

.auth-nav-status:empty {
    display: none;
}

/* Auth status banner — in-flow live region for error and status announcements.
   Targeted by ID so it sits as a normal-flow banner above the form. Never
   display:none so the element stays in the accessibility tree and
   screen-reader live-region updates fire reliably. Mobile-first: full width,
   wraps long messages cleanly at 375px without horizontal overflow. */
#auth-status {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

/* Empty: collapse to zero height (and no margin) while keeping the element in
   the a11y tree so it never intrudes on the card layout. */
#auth-status:empty {
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    max-height: 0;
    overflow: hidden;
}

/* Shared banner structure for any populated state */
#auth-status:not(:empty) {
    padding: 0.75rem 1rem;
    animation: alertSlideIn var(--t-normal) var(--ease-out) both;
}

/* Informational / polite state (non-error notices) */
#auth-status[role="status"]:not(:empty) {
    background: rgba(255, 217, 61, 0.07);
    border: 1px solid rgba(255, 217, 61, 0.2);
    color: var(--color-yellow);
}

/* Error / assertive state — high-contrast error treatment */
#auth-status[role="alert"]:not(:empty) {
    background: var(--bg-alert-error);
    border: 1px solid rgba(255, 107, 107, 0.45);
    color: #FFC4C4;
}

/* Auth tab nav — single-panel pages: visually hidden but available as a hash target hook */
.auth-tab-nav {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.auth-tab-link {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: color var(--t-fast) var(--ease-out);
    text-decoration: none;
}

.auth-tab-link:hover {
    color: var(--text-secondary);
}

/* Active nav tab (hash-based panel switcher) */
[data-auth-tab][aria-current="page"] {
    color: var(--color-coral);
    font-weight: 700;
}

/* ============================================
   Exam Catalog Note (Register page)
   ============================================ */
.auth-catalog-note {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.15);
    margin-bottom: 1.25rem;
}

.auth-catalog-note__label {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--color-cyan);
    text-transform: uppercase;
}

.auth-catalog-note__text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================
   Role Selector (Register page)
   ============================================ */
.role-selector {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-full);
    padding: 4px;
    margin-bottom: 1.5rem;
}

.role-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    transition: all var(--t-normal) var(--ease-out);
    cursor: pointer;
    user-select: none;
}

.role-btn[aria-pressed="true"] {
    background: var(--gradient-cta);
    color: #fff;
    box-shadow: 0 2px 12px rgba(255, 107, 107, 0.35);
}

.role-btn:hover:not([aria-pressed="true"]) {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.role-btn:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
    border-radius: var(--radius-full);
}

/* ============================================
   Form Elements
   ============================================ */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

/* Label row (label + forgot password link side-by-side) */
.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-label-link {
    font-size: 0.8125rem;
    color: var(--text-muted);
    transition: color var(--t-fast) var(--ease-out);
}

.form-label-link:hover { color: var(--color-coral); }

/* Input wrapper — positions icon + toggle; glows on focus */
.form-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: var(--radius-md);
    transition: box-shadow var(--t-fast) var(--ease-out);
}

.form-input-wrap:focus-within {
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.12);
}

.form-input {
    width: 100%;
    min-height: 48px; /* WCAG-compliant touch target */
    padding: 0.75rem 2.75rem 0.75rem 2.5rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: border-color var(--t-fast) var(--ease-out),
                background   var(--t-fast) var(--ease-out),
                box-shadow   var(--t-fast) var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
}

.form-input::placeholder        { color: var(--text-muted); }
.form-input:hover               { background: var(--bg-input-hover); border-color: rgba(255,255,255,0.15); }
.form-input:focus               { outline: none; border-color: var(--border-focus); background: var(--bg-input-hover); box-shadow: var(--shadow-input-focus); }
.form-input:focus-visible       { outline: 2px solid #58a6ff; outline-offset: 2px; }
.form-input[aria-invalid="true"] { border-color: var(--border-error); box-shadow: var(--shadow-input-error); }
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input-hover) inset;
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    border-color: var(--border-focus);
}

/* No left icon on standalone inputs */
.form-input--no-icon {
    padding-left: 0.875rem;
}

/* Left icon */
.form-input-icon {
    position: absolute;
    left: 0.75rem;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
    transition: color var(--t-fast) var(--ease-out);
}

.form-input-wrap:focus-within .form-input-icon {
    color: var(--color-coral);
}

/* Password toggle (right side) */
.form-input-toggle {
    position: absolute;
    right: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
    flex-shrink: 0;
}

.form-input-toggle:hover        { color: var(--text-secondary); background: rgba(255,255,255,0.06); }
.form-input-toggle:focus-visible { outline: 2px solid #58a6ff; outline-offset: 2px; border-radius: var(--radius-sm); }
.form-input-toggle svg   { width: 18px; height: 18px; }

/* Error message */
.form-error {
    display: none;
    font-size: 0.8125rem;
    color: #FF9A9A;
    font-weight: 500;
    padding-left: 0.125rem;
    line-height: 1.4;
}

.form-error:not(:empty) { display: block; }

/* Password strength meter */
.pw-strength {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    height: 4px;
}

.pw-strength__bar {
    flex: 1;
    height: 4px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
    transition: background var(--t-normal) var(--ease-out);
}

.pw-strength[data-level="1"] .pw-strength__bar:nth-child(1) { background: var(--color-coral); }
.pw-strength[data-level="2"] .pw-strength__bar:nth-child(-n+2) { background: var(--color-yellow); }
.pw-strength[data-level="3"] .pw-strength__bar { background: var(--color-lime); }

.pw-strength-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    transition: color var(--t-normal) var(--ease-out);
    height: 1em;
}

.pw-strength[data-level="1"] + .pw-strength-label { color: var(--color-coral); }
.pw-strength[data-level="2"] + .pw-strength-label { color: var(--color-yellow); }
.pw-strength[data-level="3"] + .pw-strength-label { color: var(--color-lime); }

/* ============================================
   Submit Button
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.0625rem;
    border-radius: var(--radius-full);
    padding: 0.875rem 1.75rem;
    min-height: 52px; /* Comfortable mobile touch target */
    transition: all var(--t-normal) var(--ease-spring);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    letter-spacing: 0.01em;
}

/* Shine sweep on hover */
.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 40%,
        rgba(255, 255, 255, 0.12) 50%,
        transparent 60%
    );
    background-size: 200% 100%;
    background-position: -100% 0;
    transition: background-position 0.4s var(--ease-out);
}

.btn--primary:hover:not(:disabled)::before {
    background-position: 200% 0;
}

.btn--primary {
    background: var(--gradient-cta);
    color: #fff;
    box-shadow: var(--shadow-btn);
}

.btn--primary:hover:not(:disabled) {
    box-shadow: var(--shadow-btn-hover);
    transform: translateY(-2px) scale(1.02);
}

.btn--primary:active:not(:disabled) {
    transform: translateY(0) scale(0.97);
    box-shadow: var(--shadow-btn);
}

.btn--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn:focus-visible {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
    border-radius: var(--radius-full);
}

.btn--full { width: 100%; }

.btn--submit { margin-top: 0.375rem; }

/* Spinner inside button */
.btn-spinner {
    display: inline-flex;
    align-items: center;
}

.btn-spinner[hidden] { display: none; }

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 0.75s linear infinite;
}

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

/* ============================================
   Divider
   ============================================ */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin: 0.25rem 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-card);
}

/* ============================================
   Responsive — General
   ============================================ */

/* 640px — narrow-viewport entry point: tighten outer padding and gap
   before the more aggressive 480px/414px passes kick in. */
@media (max-width: 640px) {
    .auth-page {
        padding: 2rem 1.125rem;
    }
    .auth-wrapper {
        gap: 1.75rem;
    }
    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
}

@media (max-width: 480px) {
    .auth-page  { padding: 1.5rem 1rem; align-items: flex-start; padding-top: 2rem; }
    .auth-card  { padding: 1.75rem 1.375rem; border-radius: var(--radius-lg); }
    .auth-card__title { font-size: 1.625rem; }
    .auth-form  { gap: 1rem; }
}

/* 414px — iPhone 8 Plus / SE 3rd (large) / most mid-range Android */
@media (max-width: 414px) {
    .auth-page  { padding: 1.375rem 1rem; padding-top: 1.875rem; }
    .auth-card  { padding: 1.625rem 1.25rem; }
    .auth-card__title { font-size: 1.5625rem; }
    .auth-form  { gap: 1rem; }
    .form-input { font-size: 1rem; } /* Prevents iOS zoom on focus */
}

/* 375px — iPhone 6/7/8/SE 2nd/3rd — primary mobile target */
@media (max-width: 375px) {
    .auth-page  { padding: 1.25rem 0.875rem; align-items: flex-start; padding-top: 1.75rem; }
    .auth-card  { padding: 1.375rem 1.125rem; border-radius: var(--radius-lg); }
    .auth-card__title    { font-size: 1.5rem; }
    .auth-card__subtitle { font-size: 0.875rem; }
    .auth-card__header   { margin-bottom: 1.375rem; }
    .auth-wrapper        { gap: 1.375rem; }
    .auth-brand__name    { font-size: 1.375rem; }
    .auth-brand__icon    { width: 32px; height: 32px; }
    .auth-form           { gap: 0.875rem; }

    /* Ensure inputs are still comfortably tappable */
    .form-input { font-size: 1rem; } /* Prevents iOS zoom on focus */

    /* Single-column track grid on 375px */
    .plan-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .plan-card__label {
        padding: 0.75rem 2rem 0.75rem 0.75rem;
    }

    .plan-card__features { display: none; }

    /* Wider wrapper fills screen edge-to-edge on 375px */
    .auth-wrapper--wide { max-width: 100%; }
}

@media (max-height: 700px) {
    .auth-page  { align-items: flex-start; padding-top: 1.5rem; }
    .auth-wrapper { gap: 1.25rem; }
}

/* ============================================
   Terms note (register page)
   ============================================ */
.auth-terms {
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
    margin-top: 0.25rem;
}

.auth-terms .auth-link {
    color: var(--text-muted);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-terms .auth-link:hover { color: var(--color-coral); }

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   Plan Selection (Signup page)
   ============================================ */

/* Wider wrapper for the plan grid */
.auth-wrapper--wide {
    max-width: 560px;
}

/* Section label above plan grid (reusable) */
.form-section-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    margin-bottom: 0.625rem;
}

.form-section-hint {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.5;
    margin: -0.375rem 0 0.75rem;
}

/* 3-track plan grid */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
}

.plan-card {
    position: relative;
}

/* Visually hidden radio — keyboard/screen-reader accessible */
.plan-card__radio {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip: rect(0, 0, 0, 0);
}

.plan-card__label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.875rem;
    padding-right: 1.875rem; /* room for check indicator */
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color  var(--t-fast) var(--ease-out),
                background    var(--t-fast) var(--ease-out),
                box-shadow    var(--t-fast) var(--ease-out),
                transform     var(--t-fast) var(--ease-spring);
    user-select: none;
    height: 100%;
    position: relative;
    /* Touch-friendly minimum height */
    min-height: 72px;
}

.plan-card__label:hover {
    background: var(--bg-input-hover);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.plan-card__label:active {
    transform: scale(0.98);
}

/* Selected state */
.plan-card__radio:checked + .plan-card__label {
    border-color: var(--color-coral);
    background: rgba(255, 107, 107, 0.07);
    box-shadow: var(--shadow-input-focus),
                inset 0 1px 0 rgba(255, 107, 107, 0.1);
}

/* Focus state — shows on keyboard navigation */
.plan-card__radio:focus-visible + .plan-card__label {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
}

/* Check indicator dot in top-right corner */
.plan-card__label::after {
    content: '';
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--border-input);
    background: transparent;
    transition: border-color var(--t-fast) var(--ease-out),
                background    var(--t-fast) var(--ease-out);
}

/* Filled checkmark when selected */
.plan-card__radio:checked + .plan-card__label::after {
    border-color: transparent;
    background-color: var(--color-coral);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 6l2.5 2.5 4.5-4.5' stroke='white' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 10px;
    background-position: center;
    background-repeat: no-repeat;
}

.plan-card__header {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.25rem 0.375rem;
}

.plan-card__name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.2;
    flex: 1;
}

.plan-card__badge {
    flex-shrink: 0;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: var(--gradient-cta);
    color: #fff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.6;
    align-self: center;
}

.plan-card__price {
    flex-basis: 100%;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin-top: 0.125rem;
}

.plan-card__price-unit,
.plan-card__price-note {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.plan-card__features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

.plan-card__features li {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    line-height: 1.3;
}

.plan-card__features li::before {
    content: '✓';
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--color-lime);
    flex-shrink: 0;
}

/* Plan form-group removes default gap (label sits above grid) */
.form-group--plan {
    gap: 0;
}

/* Plan error message */
.plan-error {
    display: none;
    font-size: 0.8125rem;
    color: #FF9A9A;
    font-weight: 500;
    line-height: 1.4;
    margin-top: 0.375rem;
}

.plan-error:not(:empty) { display: block; }

/* ============================================
   Signup — Responsive (480px–521px range)
   ============================================ */
@media (max-width: 520px) {
    .auth-wrapper--wide { max-width: 440px; }

    /* Hide feature lists to keep cards compact at this width */
    .plan-card__features { display: none; }

    /* Tighten plan card padding */
    .plan-card__label {
        padding: 0.75rem;
        padding-right: 1.75rem;
        min-height: 64px;
    }
}

/* ============================================
   Interview — One-at-a-time question flow
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Progress bar */
.interview-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    margin-bottom: 0.625rem;
    overflow: hidden;
}

.interview-progress__fill {
    display: block;
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-cta);
    width: 0%;
    transition: width 400ms var(--ease-out);
}

.interview-counter {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
}

/* ---- Animated step card ---- */
.interview-step {
    opacity: 1;
    transform: translateY(0);
    transition: transform 300ms ease, opacity 300ms ease;
    will-change: transform, opacity;
}

.interview-step--exit {
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
}

/* No transition on enter class — set initial position, then the base rule animates it in */
.interview-step--enter {
    opacity: 0;
    transform: translateY(12px);
    transition: none !important;
}

/* ---- Question label & hint ---- */
.interview-q__label {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 0.375rem;
}

.interview-q__hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Text / number / date input */
.interview-q__input {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 0.875rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    transition: border-color var(--t-fast) var(--ease-out),
                background   var(--t-fast) var(--ease-out),
                box-shadow   var(--t-fast) var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
}

.interview-q__input::placeholder { color: var(--text-muted); }
.interview-q__input:hover  { background: var(--bg-input-hover); border-color: rgba(255, 255, 255, 0.15); }
.interview-q__input:focus  { outline: none; border-color: var(--border-focus); background: var(--bg-input-hover); box-shadow: var(--shadow-input-focus); }
.interview-q__input:focus-visible { outline: 2px solid #58a6ff; outline-offset: 2px; }
.interview-q__input[aria-invalid="true"] { border-color: var(--border-error); box-shadow: var(--shadow-input-error); }

/* Radio option cards */
.interview-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.interview-option { position: relative; }

.interview-option__radio {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.interview-option__label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-input);
    border-radius: var(--radius-md);
    cursor: pointer;
    min-height: 52px;
    transition: border-color var(--t-fast) var(--ease-out),
                background   var(--t-fast) var(--ease-out),
                transform    var(--t-fast) var(--ease-spring);
    user-select: none;
}

.interview-option__label:hover {
    background: var(--bg-input-hover);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateX(2px);
}

.interview-option__radio:checked + .interview-option__label {
    border-color: var(--color-coral);
    background: rgba(255, 107, 107, 0.07);
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
}

.interview-option__radio:focus-visible + .interview-option__label {
    outline: 2px solid #58a6ff;
    outline-offset: 2px;
}

.interview-option__dot {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--border-input);
    background: transparent;
    transition: border-color var(--t-fast) var(--ease-out),
                background   var(--t-fast) var(--ease-out);
}

.interview-option__radio:checked + .interview-option__label .interview-option__dot {
    border-color: transparent;
    background-color: var(--color-coral);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none'%3E%3Ccircle cx='5' cy='5' r='2.5' fill='white'/%3E%3C/svg%3E");
    background-size: cover;
}

.interview-option__text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.interview-option__name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.interview-option__desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Next / Finish button inside the step */
.interview-next-btn { width: 100%; margin-top: 0.25rem; }

/* Skip link for optional questions */
.interview-skip {
    display: block;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--t-fast) var(--ease-out);
}

.interview-skip:hover         { color: var(--text-secondary); }
.interview-skip:focus-visible { outline: 2px solid #58a6ff; outline-offset: 2px; }

/* ---- Reveal panel ---- */
.interview-reveal {
    text-align: center;
    padding: 0.5rem 0 1rem;
    animation: alertSlideIn 400ms var(--ease-out) both;
}

.interview-reveal[hidden] { display: none; }

.interview-reveal__part {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-purple);
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-full);
    padding: 3px 10px;
    margin-bottom: 1.25rem;
}

.interview-reveal__icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 1rem;
}

.interview-reveal__title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #F0EBF8 0%, #C4B8E8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.interview-reveal__body {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 1.75rem;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.interview-reveal__body em {
    font-style: normal;
    color: var(--color-coral);
    font-weight: 600;
}

/* ============================================
   Reduced Motion — Interview overrides
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .interview-step,
    .interview-step--exit,
    .interview-step--enter {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
        animation: none !important;
    }

    .interview-progress__fill {
        transition: none !important;
    }

    .interview-reveal {
        animation: none !important;
    }
}

/* ============================================================
   Mobile 414px — POLISH-17.2 (part 2/3)
   Additional refinements for /login and /signup auth pages:
   full-width form controls, touch targets ≥44px, error/alert
   readability, no horizontal overflow at 375px.
   ============================================================ */
@media (max-width: 414px) {
    /* Auth page container — claim full width */
    .auth-page {
        padding: 1.25rem 0.875rem;
    }

    .auth-card,
    .auth-wrapper {
        max-width: 100%;
        width: 100%;
    }

    /* Inputs are full-width with 16px font (prevents iOS zoom on focus)
       and 44px minimum tap height. */
    .form-input,
    .form-select,
    .form-textarea {
        width: 100%;
        min-height: 44px;
        font-size: 1rem;
        padding: 0.75rem 0.875rem 0.75rem 2.5rem;
    }

    /* Inputs without leading icon — even out left padding */
    .form-input--bare,
    .form-input:not([class*="icon"]) {
        padding-left: 0.875rem;
    }

    /* Form labels and helper text are readable */
    .form-label,
    .form-label-link {
        font-size: 0.9375rem;
    }

    .form-error,
    .auth-alert {
        font-size: 0.875rem;
        line-height: 1.45;
    }

    /* Primary submit + role chips — full-width, ≥48px tap targets */
    .btn,
    .btn--full {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        touch-action: manipulation;
    }

    /* Password-reveal toggle — ≥44px touch area */
    .form-input-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    /* Role selector chips — stack on narrow widths */
    .role-selector,
    .role-selector__chips {
        flex-direction: column;
        gap: 0.5rem;
    }

    .role-selector__chip {
        width: 100%;
        min-height: 48px;
        justify-content: center;
    }

    /* Brand block — slightly tighter */
    .auth-brand {
        gap: 0.625rem;
        margin-bottom: 1rem;
    }

    .auth-brand__name {
        font-size: 1.25rem;
    }

    /* Footer link row wraps gracefully */
    .auth-card__footer {
        text-align: center;
        font-size: 0.9375rem;
    }

    /* Hide ambient glow decorations on small screens */
    .auth-glow {
        display: none;
    }

    /* Hard-stop any accidental horizontal scroll */
    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
}
