@font-face {
    font-family: 'TaraType';
    src: url('/fonts/TaraType.ttf') format('truetype');
    font-display: swap;
}

@font-face {
    font-family: 'PlayfairDisplay';
    src: url('/fonts/PlayfairDisplay-VariableFont_wght.ttf') format('truetype');
    font-display: swap;
}

:root {
    --bg: #0a0a0c;
    --surface: #110d1a;
    --cyan: #eaff00;
    --magenta: #9b4dca;
    --violet: #7B2FBE;
    --text: #E0E0E0;
    --text-bright: #FFFFFF;
    --muted: rgba(224, 224, 224, 0.6);
    --muted-2: rgba(224, 224, 224, 0.35);
    --line: rgba(155, 77, 202, 0.2);
    --line-strong: rgba(234, 255, 0, 0.35);
    --radius: 18px;
    --transition: 220ms cubic-bezier(0.2, 0.9, 0.2, 1);
    --glass-bg: rgba(17, 13, 26, 0.7);
    --glass-border: rgba(155, 77, 202, 0.25);
    --glow-cyan: 0 0 15px rgba(234, 255, 0, 0.25), 0 0 30px rgba(155, 77, 202, 0.15);
    --glow-magenta: 0 0 15px rgba(155, 77, 202, 0.3), 0 0 30px rgba(155, 77, 202, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', 'PlayfairDisplay', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    color: var(--text);
    min-height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

.grid-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(155, 77, 202, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(155, 77, 202, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

.hero-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 8s ease-in-out infinite;
}

@keyframes particleFloat {
    0%, 100% { opacity: 0; transform: translateY(0) scale(0.5); }
    25% { opacity: 0.8; }
    50% { opacity: 0.4; transform: translateY(-40px) scale(1); }
    75% { opacity: 0.6; }
}

.floating-brand {
    position: fixed;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    pointer-events: none;
    animation: floatBrand 6s ease-in-out infinite;
}

.brand-mark {
    font-family: 'Orbitron', 'TaraType', ui-sans-serif, system-ui;
    font-size: 8rem;
    font-weight: 800;
    letter-spacing: 3px;
    line-height: 1;
    color: var(--cyan);
    text-shadow: 0 0 20px rgba(234, 255, 0, 0.45), 0 0 40px rgba(155, 77, 202, 0.25);
    opacity: 0.9;
}

@keyframes floatBrand {
    0%, 100% {
        transform: translateX(-50%) translateY(0px);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

.auth-shell {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    padding-top: 180px;
}

.auth-card {
    width: min(600px, 100%);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    box-shadow: none;
    backdrop-filter: none;
    padding: 0;
    animation: slideUp var(--transition);
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.dynamic-island {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0;
    padding: 6px;
    background: rgba(17, 13, 26, 0.75);
    border: 1px solid rgba(155, 77, 202, 0.25);
    border-radius: 30px;
    backdrop-filter: blur(20px);
    box-shadow: var(--glow-cyan);
    min-height: 48px;
    overflow: hidden;
    margin-bottom: 20px;
}

.nav-item {
    position: relative;
    height: 36px;
    border: none;
    border-radius: 24px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    padding: 0 12px;
    gap: 8px;
    min-width: 36px;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.nav-item-text {
    font-family: 'Orbitron', 'PlayfairDisplay', ui-sans-serif, system-ui;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-item:hover {
    color: var(--text-bright);
}

.nav-item.active {
    background: var(--cyan);
    color: var(--bg);
    padding: 0 16px;
    box-shadow: 0 0 12px rgba(234, 255, 0, 0.35);
}

.nav-item.active .nav-item-text {
    max-width: 120px;
    opacity: 1;
    margin-left: 4px;
}

.nav-item.active svg {
    display: none;
}

.auth-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 100%;
}

.form-area {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.inline-messages {
    min-height: 0;
}

.error-message {
    display: none;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 10px;
    background: rgba(155, 77, 202, 0.12);
    border: 1px solid rgba(155, 77, 202, 0.3);
    color: #bb88e0;
    backdrop-filter: blur(10px);
    font-family: 'Inter', 'PlayfairDisplay', ui-sans-serif, system-ui;
}

.error-message.show {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.success-message {
    display: none;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 10px;
    background: rgba(155, 77, 202, 0.15);
    border: 1px solid rgba(234, 255, 0, 0.25);
    color: var(--cyan);
    backdrop-filter: blur(10px);
    font-family: 'Inter', 'PlayfairDisplay', ui-sans-serif, system-ui;
}

.success-message.show {
    display: block;
}

.form {
    display: none;
    flex-direction: column;
}

.form.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.fields-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

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

.field {
    margin-bottom: 0;
}

.field label {
    display: block;
    font-family: 'Orbitron', 'PlayfairDisplay', ui-sans-serif, system-ui;
    font-size: 10px;
    font-weight: 600;
    color: var(--cyan);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
}

.input-wrapper {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    box-shadow: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--cyan);
    box-shadow: 0 0 12px rgba(155, 77, 202, 0.25);
}

.input-fill {
    position: absolute;
    inset: 0;
    background: rgba(155, 77, 202, 0.06);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.input-wrapper:hover .input-fill,
.input-wrapper:focus-within .input-fill {
    transform: scaleX(1);
}

.field input {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    background: transparent;
    font-family: 'Inter', 'PlayfairDisplay', ui-sans-serif, system-ui;
    font-size: 14px;
    color: var(--text-bright);
    transition: all var(--transition);
    outline: none;
}

.field input::placeholder {
    color: var(--muted-2);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-background-clip: text;
    -webkit-text-fill-color: var(--text-bright);
    transition: background-color 5000s ease-in-out 0s;
    box-shadow: inset 0 0 20px 20px transparent;
}

.password-row {
    position: relative;
    display: flex;
    align-items: center;
}

.password-row input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: color var(--transition), transform var(--transition);
    z-index: 2;
}

.password-toggle:hover {
    color: var(--cyan);
    transform: translateY(-50%) scale(1.04);
}

.password-toggle:focus {
    outline: none;
    color: var(--cyan);
}

.eye-icon {
    width: 20px;
    height: 20px;
}

.btn-primary {
    width: 100%;
    padding: 16px 24px;
    background: var(--cyan);
    color: var(--bg);
    border: none;
    border-radius: 14px;
    font-family: 'Orbitron', 'PlayfairDisplay', ui-sans-serif, system-ui;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: var(--glow-cyan);
}

.btn-primary:hover {
    background: #f5ff4d;
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(234, 255, 0, 0.45), 0 0 40px rgba(155, 77, 202, 0.25);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary:active {
    transform: translateY(0px) scale(0.99);
}

.btn-loader {
    display: flex;
    align-items: center;
}

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

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

@media (max-width: 768px) {
    body {
        overflow: auto;
        overflow-x: hidden;
    }

    .floating-brand {
        top: 8%;
    }

    .floating-brand .brand-mark {
        font-size: 5rem;
    }

    .auth-shell {
        padding: 20px;
        padding-top: 160px;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .auth-card {
        width: 100%;
    }

    .dynamic-island {
        margin-bottom: 16px;
    }
}

@media (max-width: 640px) {
    .floating-brand {
        top: 5%;
    }

    .floating-brand .brand-mark {
        font-size: 3.5rem;
        letter-spacing: 1px;
    }

    .auth-shell {
        padding: 16px;
        padding-top: 120px;
    }

    .fields-row {
        grid-template-columns: 1fr;
    }

    .fields-container {
        gap: 12px;
    }

    .field label {
        font-size: 9px;
        margin-bottom: 6px;
    }

    .field input {
        padding: 12px 14px;
        font-size: 16px;
    }

    .btn-primary {
        padding: 14px 20px;
    }

    .input-wrapper {
        border-radius: 12px;
    }

    .field input {
        border-radius: 12px;
    }

    .btn-primary {
        border-radius: 12px;
    }

    .error-message,
    .success-message {
        font-size: 12px;
        padding: 8px 10px;
        border-radius: 10px;
    }
}

@media (max-width: 440px) {
    .floating-brand {
        top: 3%;
    }

    .floating-brand .brand-mark {
        font-size: 2.5rem;
    }

    .auth-shell {
        padding: 12px;
        padding-top: 90px;
    }

    .dynamic-island {
        padding: 4px;
        min-height: 42px;
    }

    .nav-item {
        height: 34px;
        padding: 0 10px;
    }

    .nav-item.active {
        padding: 0 14px;
    }

    .nav-item-text {
        font-size: 11px;
    }

    .field input {
        padding: 11px 12px;
    }

    .btn-primary {
        padding: 13px 16px;
        font-size: 12px;
    }

    .password-toggle {
        right: 10px;
    }
}

body.loading .grid-bg,
body.loading .hero-particles,
body.loading .floating-brand,
body.loading .auth-shell {
    opacity: 0;
    visibility: hidden;
}

body:not(.loading) .grid-bg,
body:not(.loading) .hero-particles,
body:not(.loading) .floating-brand,
body:not(.loading) .auth-shell {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

body:not(.loading) .page-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.loader-brand {
    font-family: 'Orbitron', 'TaraType', ui-sans-serif, system-ui;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--cyan);
    text-shadow: 0 0 20px rgba(234, 255, 0, 0.45);
    opacity: 0.9;
}

.loader-spinner {
    color: var(--cyan);
    opacity: 0.6;
}

.loader-spinner svg {
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@media (max-width: 640px) {
    .loader-content {
        gap: 18px;
    }

    .loader-brand {
        font-size: 2rem;
    }

    .loader-spinner svg {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 440px) {
    .loader-content {
        gap: 14px;
    }

    .loader-brand {
        font-size: 1.6rem;
    }

    .loader-spinner svg {
        width: 28px;
        height: 28px;
    }
}
