:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --danger: #ef4444;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Background Animation */
.background-animation {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    animation: float 10s infinite alternate ease-in-out;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: rgba(99, 102, 241, 0.4);
    top: -10%;
    left: -10%;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: rgba(236, 72, 153, 0.3);
    bottom: -10%;
    right: -5%;
    animation-delay: -5s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: rgba(16, 185, 129, 0.2);
    top: 40%;
    left: 40%;
    animation-duration: 15s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Container & Glassmorphism Box */
.container {
    width: 100%;
    max-width: 1040px;
    padding: 20px;
    z-index: 1;
}

.auth-box {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    width: 100%;
    min-height: 660px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.form-panel,
.welcome-panel {
    position: absolute;
    inset-block: 0;
    width: 50%;
    will-change: transform;
    transition: transform .95s cubic-bezier(.22, 1, .36, 1);
}

.form-panel {
    left: 0;
    padding: 54px 58px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 2;
}

.welcome-panel {
    left: 50%;
    display: grid;
    place-items: center;
    padding: 54px;
    isolation: isolate;
    background: linear-gradient(145deg, rgba(79,70,229,.97), rgba(49,46,129,.94));
    overflow: hidden;
    z-index: 3;
}

.auth-box.register-mode .form-panel { transform: translateX(100%); }
.auth-box.register-mode .welcome-panel { transform: translateX(-100%); }

.welcome-glow {
    position: absolute;
    width: 420px;
    aspect-ratio: 1;
    border-radius: 50%;
    top: -180px;
    right: -160px;
    background: rgba(255,255,255,.12);
    box-shadow: -220px 430px 0 60px rgba(236,72,153,.12);
    z-index: -1;
}

.welcome-content {
    position: absolute;
    width: calc(100% - 108px);
    max-width: 390px;
    text-align: center;
    will-change: opacity, transform;
    transition: opacity .42s ease, transform .72s cubic-bezier(.22, 1, .36, 1);
}

.welcome-register { opacity: 0; transform: translateX(45px) scale(.985); pointer-events: none; }
.auth-box.register-mode .welcome-login { opacity: 0; transform: translateX(-45px) scale(.985); pointer-events: none; }
.auth-box.register-mode .welcome-register { opacity: 1; transform: translateX(0); pointer-events: auto; }

.welcome-kicker,
.eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: 12px;
    font-weight: 700;
}

.welcome-kicker { color: #c7d2fe; margin: 28px 0 12px; }
.welcome-content h2 { font-size: clamp(38px, 4vw, 58px); line-height: .98; letter-spacing: -.04em; }
.welcome-content p { color: rgba(255,255,255,.78); line-height: 1.7; margin: 24px 0 32px; }
.welcome-content .welcome-panel-title { font-size: clamp(30px, 3vw, 43px); white-space: nowrap; }
.welcome-tagline { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.welcome-tagline span { font-size: 14px; color: #c7d2fe; }
.welcome-tagline strong { color: #fff; font-size: 17px; line-height: 1.4; }
.welcome-description { min-height: 58px; display: flex; align-items: center; justify-content: center; text-align: center; }
.btn-switch { width: 100%; padding-inline: 22px; color: #fff; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.5); }
.btn-switch:hover { background: #fff; color: #3730a3; transform: translateY(-2px); }

.form-heading { grid-area: 1 / 1; margin-bottom: 28px; transition: opacity .4s ease, transform .65s cubic-bezier(.22, 1, .36, 1); }
.form-heading .eyebrow { color: #818cf8; margin-bottom: 9px; }
.form-heading h2 { font-size: 36px; letter-spacing: -.03em; }
.form-heading p { color: var(--text-muted); margin-top: 7px; }
.form-panel { display: grid; grid-template-rows: auto auto auto; align-content: center; }
.register-heading { opacity: 0; transform: translateX(28px); }
.auth-box.register-mode .login-heading { opacity: 0; transform: translateX(-28px); }
.auth-box.register-mode .register-heading { opacity: 1; transform: translateX(0); transition-delay: .16s; }
.form-panel > .alert { grid-column: 1; grid-row: 2; }
.forms-stage { position: relative; display: grid; grid-column: 1; grid-row: 3; }
.forms-stage .auth-form {
    display: block;
    grid-area: 1 / 1;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-30px) scale(.985);
    transition: opacity .4s ease, transform .7s cubic-bezier(.22, 1, .36, 1), visibility 0s linear .7s;
}
.forms-stage #register-form { transform: translateX(30px) scale(.985); }
.forms-stage .auth-form.active-form {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) scale(1);
    animation: none;
    transition-delay: .14s, .14s, 0s;
}
.alert { padding: 10px; border-radius: 8px; margin-bottom: 18px; text-align: center; }
.alert-danger { background: rgba(239,68,68,.2); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(16,185,129,.2); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }
.register-feedback {
    margin: 0 0 16px;
    padding: 11px 13px;
    border: 1px solid rgba(239,68,68,.45);
    border-radius: 10px;
    background: rgba(239,68,68,.14);
    color: #fecaca;
    font-size: 14px;
    line-height: 1.45;
}
.register-feedback[hidden] { display: none; }
.register-feedback ul { margin: 0; padding-left: 19px; }
.register-feedback li + li { margin-top: 3px; }
.input-group.has-error input {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239,68,68,.12);
}
.input-group.has-error > i { color: #f87171; }
.auth-form .btn.is-loading { cursor: wait; opacity: .75; }

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-brand-logo {
    display: block;
    width: 100%;
    max-width: 330px;
    height: auto;
    margin: 0 auto 16px;
    padding: 8px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.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;
}

.auth-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

/* Forms */
.auth-form {
    display: none;
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.4s ease;
}

.auth-form.active-form {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: slideUpFade 0.5s ease forwards;
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
    transition: color 0.3s ease;
}

.input-group input, .input-group select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 16px 14px 45px;
    color: var(--text-main);
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    appearance: none;
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-group input:focus + i, .input-group select:focus + i {
    color: var(--primary);
}

/* Select Styling */
.input-group select {
    cursor: pointer;
}
.input-group select option {
    background: var(--bg-dark);
    color: var(--text-main);
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    font-size: 13px;
}

.form-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
}

.form-options a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.3s;
}

.form-options a:hover {
    color: var(--primary-hover);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.divider {
    margin: 25px 0;
    text-align: center;
    position: relative;
}

.divider::before, .divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--glass-border);
}

.divider::before { left: 0; }
.divider::after { right: 0; }

.divider span {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.btn-google {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
}

.btn-google img {
    width: 20px;
    height: 20px;
}

.btn-google:hover {
    background: #f9fafb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.switch-form {
    text-align: center;
    margin-top: 25px;
    font-size: 14px;
    color: var(--text-muted);
}

.switch-form a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.switch-form a:hover {
    color: var(--primary-hover);
}

@media (max-width: 520px) {
    body {
        align-items: flex-start;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .container {
        max-width: 100%;
        min-height: 100vh;
        padding: 14px;
        display: flex;
        align-items: center;
    }

    .auth-box {
        width: 100%;
        padding: 28px 18px;
        border-radius: 18px;
    }

    .auth-header {
        margin-bottom: 24px;
    }

    .auth-brand-logo {
        max-width: 320px;
        margin-bottom: 13px;
        padding: 6px;
    }

    .auth-header h2 {
        font-size: 24px;
    }

    .input-group input,
    .input-group select {
        min-height: 48px;
        font-size: 16px;
    }

    .form-options {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .shape-1 { width: 260px; height: 260px; }
    .shape-2 { width: 220px; height: 220px; }
    .shape-3 { width: 180px; height: 180px; }
}

@media (max-width: 820px) {
    body { align-items: flex-start; overflow-y: auto; }
    .container { max-width: 560px; min-height: 100vh; padding: 14px; display: flex; align-items: center; }
    .auth-box { min-height: 0; padding: 235px 0 0; border-radius: 20px; overflow: hidden; }
    .form-panel, .welcome-panel { position: relative; inset: auto; left: auto; width: 100%; transform: none !important; }
    .form-panel { padding: 34px 24px 30px; min-height: 510px; }
    .welcome-panel { position: absolute; inset: 0 0 auto; height: 235px; padding: 24px; }
    .welcome-content { width: calc(100% - 48px); max-width: none; text-align: center; }
    .welcome-content .auth-brand-logo { max-width: 260px; margin-bottom: 12px; }
    .welcome-kicker { margin: 0 0 6px; }
    .welcome-content h2 { font-size: 30px; line-height: 1.05; }
    .welcome-content .welcome-panel-title { font-size: clamp(22px, 6.5vw, 29px); }
    .welcome-content p { display: none; }
    .welcome-content .welcome-tagline { display: flex; margin: 8px 0 0; line-height: 1.25; }
    .welcome-content .welcome-description { display: flex; min-height: 30px; margin: 8px 0 0; font-size: 12px; line-height: 1.25; }
    .welcome-tagline span { font-size: 11px; }
    .welcome-tagline strong { font-size: 12px; }
    .btn-switch { margin: 15px auto 0; padding: 9px 16px; font-size: 14px; }
    .welcome-glow { width: 300px; top: -210px; right: -80px; }
}

@media (max-height: 720px) {
    body { overflow-y: auto; }
    .container { padding-block: 14px; }
    .auth-box { padding-block: 24px; }
    .auth-header { margin-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .form-panel, .welcome-panel, .welcome-content, .auth-form { transition: none; animation: none !important; }
}
