/* ═══════════════════════════════════════════════════════════
   CampusTea Auth — Login & Register (responsive split layout)
   ═══════════════════════════════════════════════════════════ */

/* Fallback tokens if theme.css fails to load */
:root {
    --primary: #7B2FF7;
    --primary-dark: #6229A7;
    --secondary: #FF4D94;
    --accent: #FF7A00;
    --background: #F0F2F8;
    --surface: #FFFFFF;
    --border: #E4E7EF;
    --text-dark: #1A1A2E;
    --text-muted: #64748B;
    --text-light: #94A3B8;
    --gradient-primary: linear-gradient(135deg, #7B2FF7 0%, #FF4D94 100%);
    --gradient-brand: linear-gradient(135deg, #6229A7 0%, #FF4D94 100%);
    --input-bg: #FFFFFF;
    --radius-md: 16px;
    --shadow-md: 0 4px 16px rgba(123, 47, 247, 0.1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.auth-body {
    font-family: var(--font-family);
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
    background: var(--background);
}

/* ── Animated background ── */
.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.auth-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(123, 47, 247, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 77, 148, 0.06) 0%, transparent 40%),
        linear-gradient(rgba(123, 47, 247, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(123, 47, 247, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 48px 48px, 48px 48px;
}

.auth-bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.4;
    animation: authBlobFloat 18s ease-in-out infinite;
}

.auth-bg-blob--1 {
    width: 560px;
    height: 560px;
    background: #7B2FF7;
    top: -160px;
    right: -100px;
}

.auth-bg-blob--2 {
    width: 480px;
    height: 480px;
    background: #FF4D94;
    bottom: -120px;
    left: -80px;
    animation-delay: -6s;
}

.auth-bg-blob--3 {
    width: 320px;
    height: 320px;
    background: #FF7A00;
    top: 55%;
    left: 40%;
    opacity: 0.15;
    animation-delay: -12s;
}

@keyframes authBlobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 15px) scale(0.95); }
}

[data-theme="dark"] .auth-bg-blob { opacity: 0.18; }
[data-theme="dark"] .auth-bg::before { opacity: 0.6; }

/* ── Top bar ── */
.auth-topbar {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.auth-topbar-brand img {
    height: 40px;
    transition: transform 0.2s;
}

.auth-topbar-brand:hover img { transform: scale(1.03); }

.auth-topbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 52px;
}

.auth-topbar-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.auth-topbar-link:hover {
    background: rgba(123, 47, 247, 0.08);
    border-color: rgba(123, 47, 247, 0.15);
}

.auth-topbar-link--muted {
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Main shell ── */
.auth-main {
    position: relative;
    z-index: 1;
    padding: 0 20px 48px;
    min-height: calc(100vh - 72px);
    min-height: calc(100dvh - 72px);
}

.auth-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1100px;
    margin: 0 auto;
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
    align-items: center;
    gap: 48px;
}

.auth-shell--register {
    max-width: 1200px;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 40px;
    align-items: start;
    padding-top: 16px;
}

/* ── Brand panel (left) ── */
.auth-brand {
    position: relative;
    padding: 48px 40px;
    border-radius: 28px;
    background: var(--gradient-brand);
    color: white;
    overflow: hidden;
    min-height: 480px;
    display: flex;
    align-items: center;
}

.auth-brand--compact {
    min-height: auto;
    position: sticky;
    top: 88px;
    padding: 36px 32px;
}

.auth-brand-inner {
    position: relative;
    z-index: 2;
}

.auth-brand-logo {
    height: 56px;
    margin-bottom: 28px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.auth-brand-title {
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.auth-brand-text {
    font-size: 15px;
    line-height: 1.65;
    opacity: 0.9;
    margin-bottom: 32px;
    max-width: 360px;
}

.auth-brand-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-brand-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.auth-brand-features li span {
    font-size: 20px;
}

.auth-steps-preview {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-steps-preview li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.auth-steps-preview li.active { opacity: 1; }

.auth-steps-preview li span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
}

.auth-steps-preview li.active span {
    background: white;
    color: var(--primary-dark);
}

.auth-brand-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    filter: blur(60px);
    top: -80px;
    right: -80px;
    pointer-events: none;
}

/* ── Form panel (right) ── */
.auth-form-panel {
    width: 100%;
}

.auth-form-panel--wide {
    min-width: 0;
}

.auth-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 40px 36px;
    box-shadow:
        0 4px 24px rgba(26, 26, 46, 0.06),
        0 1px 3px rgba(26, 26, 46, 0.04);
}

.auth-card--register {
    padding: 36px 32px 40px;
}

.auth-card-head {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card-head .auth-card-icon {
    margin: 0 auto 16px;
}

.auth-card-head--left {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    text-align: left;
    margin-bottom: 28px;
}

.auth-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(123, 47, 247, 0.12), rgba(255, 77, 148, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.auth-card-head h1,
.auth-card-head--left h1 {
    font-size: clamp(1.5rem, 2.5vw, 1.75rem);
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.auth-card-head p,
.auth-card-head--left p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.auth-toast { margin-bottom: 20px; }

/* ── Form elements ── */
.auth-form .form-group {
    margin-bottom: 18px;
}

.auth-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 7px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    pointer-events: none;
    z-index: 1;
}

.input-icon svg {
    width: 18px;
    height: 18px;
}

.input-wrap input {
    padding-left: 44px !important;
    padding-right: 44px !important;
}

.input-toggle-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
    z-index: 1;
}

.input-toggle-pw:hover {
    color: var(--primary);
    background: rgba(123, 47, 247, 0.08);
}

.input-toggle-pw svg {
    width: 18px;
    height: 18px;
}

.auth-form input,
.auth-form select {
    width: 100%;
    padding: 13px 14px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-family: inherit;
    font-size: 15px;
    background: var(--input-bg);
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.auth-form select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

.auth-form input::placeholder {
    color: var(--text-light);
}

.auth-form input:focus,
.auth-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(123, 47, 247, 0.1);
    background: var(--surface);
}

.auth-form input:disabled,
.auth-form select:disabled {
    background: var(--background);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.75;
}

.auth-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 7px;
    line-height: 1.45;
}

.form-optional {
    font-weight: 500;
    color: var(--text-light);
    font-size: 12px;
}

/* ── Register section cards ── */
.auth-section-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 22px 20px;
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-section-card:focus-within {
    border-color: rgba(123, 47, 247, 0.25);
    box-shadow: 0 0 0 1px rgba(123, 47, 247, 0.08);
}

.auth-section-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.auth-step-num {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--gradient-primary);
    color: white;
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.auth-section-head h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.auth-section-head p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── School search ── */
.school-search-wrap {
    position: relative;
    margin-bottom: 8px;
}

.school-search-wrap input {
    padding-left: 40px !important;
}

.school-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
    z-index: 1;
}

.school-select-list {
    width: 100%;
    min-height: 160px;
    max-height: 220px;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-family: inherit;
    font-size: 13px;
    background: var(--input-bg);
    color: var(--text-dark);
    overflow-y: auto;
}

.school-select-list:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(123, 47, 247, 0.1);
}

.school-select-list option {
    padding: 8px 6px;
    border-radius: 6px;
}

.school-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(123, 47, 247, 0.1);
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 4px;
}

/* ── Buttons ── */
.auth-submit {
    margin-top: 24px;
}

.btn-auth {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px 24px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.15s;
}

.btn-auth svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.btn-auth--primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 8px 28px rgba(123, 47, 247, 0.35);
}

.btn-auth--primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 36px rgba(123, 47, 247, 0.4);
}

.btn-auth--primary:hover:not(:disabled) svg {
    transform: translateX(3px);
}

.btn-auth--primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-auth:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Footer hints ── */
.auth-demo-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    padding: 12px 16px;
    background: rgba(123, 47, 247, 0.06);
    border: 1px dashed rgba(123, 47, 247, 0.2);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    flex-wrap: wrap;
}

.auth-demo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
    animation: authPulse 2s ease-in-out infinite;
}

@keyframes authPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.auth-demo-badge code {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    background: rgba(123, 47, 247, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary-dark);
}

[data-theme="dark"] .auth-demo-badge code {
    color: var(--primary);
}

.auth-switch {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--primary);
    font-weight: 700;
    margin-left: 4px;
    transition: opacity 0.15s;
}

.auth-switch a:hover {
    opacity: 0.85;
    text-decoration: underline;
}

.auth-legal-note {
    margin-top: 14px;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}

.auth-legal-note a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 960px) {
    .auth-shell,
    .auth-shell--register {
        grid-template-columns: 1fr;
        gap: 0;
        max-width: 520px;
        padding-top: 8px;
    }

    .auth-brand {
        min-height: auto;
        padding: 28px 24px;
        border-radius: 20px;
        margin-bottom: 24px;
    }

    .auth-brand--compact {
        position: static;
        padding: 24px 20px;
    }

    .auth-brand-logo {
        height: 44px;
        margin-bottom: 16px;
    }

    .auth-brand-title {
        font-size: 1.5rem;
    }

    .auth-brand-text {
        margin-bottom: 20px;
        font-size: 14px;
    }

    .auth-brand-features {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .auth-brand-features li {
        flex: 1 1 calc(50% - 4px);
        min-width: 140px;
        padding: 10px 12px;
        font-size: 12px;
    }

    .auth-steps-preview {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .auth-steps-preview li {
        font-size: 12px;
        flex: 1 1 auto;
    }

    .auth-steps-preview li span {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .auth-brand-glow {
        width: 200px;
        height: 200px;
    }
}

@media (max-width: 640px) {
    .auth-topbar {
        padding: 12px 16px;
    }

    .auth-topbar-brand img { height: 36px; }

    .auth-topbar-nav {
        gap: 4px;
        padding-right: 48px;
    }

    .auth-topbar-link {
        font-size: 12px;
        padding: 7px 10px;
    }

    .auth-topbar-link--muted { display: none; }

    .auth-main {
        padding: 0 12px 32px;
    }

    .auth-card,
    .auth-card--register {
        padding: 28px 20px 32px;
        border-radius: 22px;
    }

    .auth-card-head--left {
        flex-direction: column;
        gap: 12px;
    }

    .auth-card-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .auth-form .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .auth-section-card {
        padding: 18px 16px;
        border-radius: 16px;
    }

    .school-select-list {
        min-height: 140px;
        max-height: 180px;
    }

    .auth-form input,
    .auth-form select {
        font-size: 16px; /* prevents iOS zoom */
        padding: 14px;
    }

    .input-wrap input {
        padding-left: 44px !important;
    }

    .btn-auth {
        padding: 16px 20px;
        font-size: 16px;
    }

    .auth-brand-features li {
        flex: 1 1 100%;
    }
}

@media (max-width: 380px) {
    .auth-topbar-nav .auth-topbar-link:first-child {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .auth-bg-blob,
    .auth-demo-dot {
        animation: none;
    }
}

/* ── Register wizard (matches login shell) ── */
.auth-shell--register-wizard {
    max-width: 1100px;
    grid-template-columns: minmax(260px, 340px) 1fr;
    align-items: start;
    padding-top: 12px;
}

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

.register-progress {
    margin-bottom: 28px;
}

.register-progress-track {
    height: 4px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.register-progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.35s ease;
}

.register-progress-steps {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.register-progress-steps li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-align: center;
}

.register-progress-steps li span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--background);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.register-progress-steps li.active span,
.register-progress-steps li.done span {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
}

.register-progress-steps li.active {
    color: var(--primary);
}

.register-step-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.register-step[hidden] {
    display: none !important;
}

.register-wizard-nav {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.register-wizard-nav .btn-auth {
    flex: 1;
}

.btn-auth--ghost {
    background: var(--background);
    color: var(--text-dark);
    border: 1.5px solid var(--border);
    box-shadow: none;
}

.btn-auth--ghost:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.school-select-list {
    min-height: 120px;
    max-height: 160px;
}

@media (max-width: 960px) {
    .auth-shell--register-wizard {
        max-width: 520px;
    }
    .register-progress-steps li {
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .register-progress-steps li span {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }
    .register-progress-steps li {
        font-size: 0;
    }
    .register-progress-steps li span {
        font-size: 11px;
    }
}

.auth-card--verify {
    text-align: center;
    max-width: 440px;
    margin: 0 auto;
}

.auth-verify-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
}

.auth-verify-icon--ok {
    background: #ecfdf5;
    color: #059669;
}

.auth-verify-icon--warn {
    background: #fef3c7;
    color: #d97706;
}

.auth-verify-icon--pending {
    background: #ede9fe;
    color: #7c3aed;
}

.auth-verify-steps {
    margin: 20px 0;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--surface-2, #f4f4f8);
    text-align: left;
    font-size: 14px;
    line-height: 1.5;
}

.auth-actions--stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.btn-full {
    width: 100%;
    text-align: center;
    display: block;
}
