/* Login page — matches dashboard dark theme (maroon + slate) */

:root {
    --brand-red: #a00000;
    --brand-red-dark: #860000;
    --brand-red-light: #b81818;
    --primary-bg: #0c0e12;
    --secondary-bg: #14171d;
    --tertiary-bg: #181c24;
    --card-bg: #14171d;
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #eceef2;
    --text-secondary: #a8adb8;
    --text-muted: #6e7582;
    --accent-blue: var(--brand-red);
    --accent-teal: var(--brand-red-light);
    --accent-gradient: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-dark) 100%);
    --success: #3d9a6a;
    --error: #d46a62;
    --warning: #c9924a;
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-lg: rgba(0, 0, 0, 0.55);
}

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

body.auth-page {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
    position: relative;
    overflow: hidden;
}

body.auth-page::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 14% 10%, rgba(160, 0, 0, 0.1) 0%, transparent 52%),
        radial-gradient(ellipse at 86% 88%, rgba(20, 23, 29, 0.55) 0%, transparent 50%),
        linear-gradient(152deg, #12151a 0%, #0c0e12 42%, #090a0e 100%);
    opacity: 1;
}

body.auth-page::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 30%, rgba(160, 0, 0, 0.06) 0%, transparent 55%),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
    opacity: 0.9;
    pointer-events: none;
}

.login-container {
    display: flex;
    width: 90vw;
    max-width: 600px;
    height: auto;
    min-height: 500px;
    max-height: 700px;
    background: color-mix(in srgb, var(--card-bg) 88%, transparent);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 25px 50px var(--shadow-lg);
    position: relative;
    z-index: 1;
    animation: loginSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

@keyframes loginSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-panel {
    flex: 1;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: transparent;
    position: relative;
    overflow: hidden;
}

.form-header {
    margin-bottom: 32px;
    animation: loginFadeInUp 0.8s ease-out 0.2s both;
    position: relative;
    z-index: 3;
}

.form-header .brand-logo-header {
    display: inline-flex;
    align-items: center;
    margin-bottom: 20px;
}

.form-header .brand-name {
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--brand-red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.form-header .brand-name:hover {
    opacity: 0.85;
}

.form-header .brand-name:visited {
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--brand-red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-header h1 {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.form-header p {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

.form-group {
    margin-bottom: 24px;
    animation: loginFadeInUp 0.8s ease-out 0.4s both;
    position: relative;
    z-index: 3;
}

.form-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: 0.2px;
}

.input-wrapper {
    position: relative;
    z-index: 4;
}

.input-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    transition: all 0.3s ease;
    z-index: 5;
}

.form-control {
    width: 100%;
    padding: 12px 16px 12px 50px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1.125rem !important;
    font-weight: 400;
    color: var(--text-muted) !important;
    background: var(--neutral-tint-04, rgba(255, 255, 255, 0.04));
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    position: relative;
    z-index: 4;
    line-height: 1.5;
    caret-color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: rgba(160, 0, 0, 0.45);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    box-shadow: 0 0 0 3px rgba(160, 0, 0, 0.18);
}

.form-control:focus + .input-icon {
    color: var(--accent-blue);
    transform: translateY(-50%) scale(1.1);
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-control:-webkit-autofill:active {
    font-size: 1.125rem !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    transition: background-color 5000s ease-in-out 0s, -webkit-text-fill-color 0s;
    line-height: 1.5 !important;
    border-color: var(--border-color) !important;
}

input[type="text"],
input[type="password"] {
    font-size: 1.125rem !important;
    color: var(--text-muted) !important;
    -webkit-text-fill-color: var(--text-muted) !important;
}

input[type="text"]:focus,
input[type="password"]:focus {
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

input[type="text"]:not(:placeholder-shown),
input[type="password"]:not(:placeholder-shown) {
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

.password-toggle {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    z-index: 5;
}

.password-toggle:hover {
    color: var(--accent-blue);
    background: rgba(160, 0, 0, 0.1);
}

.error-message {
    background: rgba(212, 106, 98, 0.12);
    border: 1px solid rgba(212, 106, 98, 0.28);
    color: var(--error);
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 15px;
    margin-bottom: 24px;
    display: none;
    align-items: center;
    gap: 12px;
    animation: loginShake 0.4s ease;
    position: relative;
    z-index: 10;
}

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

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

.error-message i {
    font-size: 20px;
}

.btn-primary {
    width: 100%;
    padding: 12px 16px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 4;
    overflow: hidden;
    margin-bottom: 20px;
    animation: loginFadeInUp 0.8s ease-out 0.6s both;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
    transition: left 0.6s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(160, 0, 0, 0.35);
}

.btn-primary:active {
    transform: translateY(-1px);
}

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

.btn-primary .spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: loginSpin 0.8s linear infinite;
    margin: 0 auto;
}

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

.btn-primary.loading .btn-text {
    display: none;
}

.btn-primary.loading .spinner {
    display: block;
}

.signup-link {
    text-align: center;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
    animation: loginFadeInUp 0.8s ease-out 0.8s both;
    position: relative;
    z-index: 3;
}

.signup-link p {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 16px;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 32px;
    border: 1px solid rgba(160, 0, 0, 0.35);
    background: transparent;
    color: var(--accent-blue);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-outline:hover {
    background: rgba(160, 0, 0, 0.1);
    color: var(--text-primary);
    border-color: rgba(160, 0, 0, 0.45);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(160, 0, 0, 0.2);
}

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

@media (max-width: 968px) {
    .login-container {
        width: 98vw;
        max-width: 500px;
        min-height: 500px;
        max-height: 680px;
    }

    .login-panel {
        padding: 40px 30px;
    }

    .form-header h1 {
        font-size: 26px;
    }

    body.auth-page {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .login-container {
        width: 98vw;
        height: 90vh;
        min-height: 480px;
        max-height: 650px;
        border-radius: 16px;
    }

    .login-panel {
        padding: 28px 20px;
    }

    .form-header h1 {
        font-size: 24px;
    }

    body.auth-page {
        padding: 5px;
    }
}

*:focus-visible {
    outline: 2px solid rgba(160, 0, 0, 0.55);
    outline-offset: 2px;
}

.form-control.is-invalid {
    border-color: var(--error);
    background: rgba(212, 106, 98, 0.1);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(212, 106, 98, 0.18);
}

.form-control:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.password-toggle:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Theme toggle (top-right) ─────────────────────────────────────── */
.auth-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 20;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: color-mix(in srgb, var(--card-bg) 90%, transparent);
    color: var(--accent-blue);
    cursor: pointer;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.2));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

.auth-theme-toggle:hover {
    border-color: rgba(160, 0, 0, 0.35);
    background: var(--hover-elevated, rgba(160, 0, 0, 0.08));
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(160, 0, 0, 0.15);
}

.auth-theme-toggle:focus-visible {
    outline: 2px solid rgba(160, 0, 0, 0.45);
    outline-offset: 2px;
}

.auth-theme-toggle__icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 1;
    transition:
        opacity 0.35s ease,
        transform 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

/* Dark mode active → show sun (switch to light) */
body.auth-page.theme-dark .auth-theme-toggle__icon--light {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

body.auth-page.theme-dark .auth-theme-toggle__icon--dark {
    opacity: 0;
    transform: rotate(75deg) scale(0.45);
    pointer-events: none;
}

/* Light mode active → show moon (switch to dark) */
body.auth-page.theme-light .auth-theme-toggle__icon--light {
    opacity: 0;
    transform: rotate(-75deg) scale(0.45);
    pointer-events: none;
}

body.auth-page.theme-light .auth-theme-toggle__icon--dark {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Light theme ──────────────────────────────────────────────────── */
body.auth-page.theme-light {
    --primary-bg: #e4e7ec;
    --secondary-bg: #d8dde4;
    --tertiary-bg: #e9ecf1;
    --card-bg: #f1f3f6;
    --border-color: rgba(35, 40, 48, 0.1);
    --text-primary: #232830;
    --text-secondary: #555555;
    --text-muted: #727986;
    --shadow: rgba(35, 40, 48, 0.08);
    --shadow-lg: rgba(35, 40, 48, 0.14);
    --hover-elevated: #f6f8fa;
    --neutral-tint-04: rgba(35, 40, 48, 0.04);
}

body.auth-page.theme-light::before {
    background:
        radial-gradient(ellipse at 14% 10%, rgba(160, 0, 0, 0.035) 0%, transparent 52%),
        radial-gradient(ellipse at 86% 88%, rgba(55, 62, 72, 0.06) 0%, transparent 50%),
        linear-gradient(152deg, #eceef2 0%, #e4e7ec 42%, #dde1e8 100%);
}

body.auth-page.theme-light::after {
    background:
        radial-gradient(circle at 20% 30%, rgba(160, 0, 0, 0.04) 0%, transparent 55%),
        radial-gradient(circle at 80% 70%, rgba(35, 40, 48, 0.03) 0%, transparent 50%);
}

body.auth-page.theme-light .login-container {
    background: color-mix(in srgb, var(--card-bg) 94%, transparent);
    box-shadow: 0 20px 40px var(--shadow-lg);
}

body.auth-page.theme-light .form-control {
    background: var(--neutral-tint-04);
    color: var(--text-muted) !important;
    -webkit-text-fill-color: var(--text-muted) !important;
}

body.auth-page.theme-light .form-control:focus,
body.auth-page.theme-light input[type="text"]:focus,
body.auth-page.theme-light input[type="password"]:focus {
    background: #fff;
    border-color: rgba(160, 0, 0, 0.35);
    box-shadow: 0 0 0 3px rgba(160, 0, 0, 0.12);
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

body.auth-page.theme-light input[type="text"]:not(:placeholder-shown),
body.auth-page.theme-light input[type="password"]:not(:placeholder-shown) {
    color: var(--text-primary) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

body.auth-page.theme-light .form-control:-webkit-autofill,
body.auth-page.theme-light .form-control:-webkit-autofill:hover,
body.auth-page.theme-light .form-control:-webkit-autofill:focus,
body.auth-page.theme-light .form-control:-webkit-autofill:active {
    background: var(--neutral-tint-04) !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    color: var(--text-primary) !important;
}

body.auth-page.theme-light .password-toggle:hover {
    background: rgba(160, 0, 0, 0.06);
}

body.auth-page.theme-light .btn-outline:hover {
    background: rgba(160, 0, 0, 0.06);
    color: var(--accent-blue);
}

body.auth-page.theme-light .auth-theme-toggle {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 2px 10px rgba(35, 40, 48, 0.08);
}

@media (max-width: 480px) {
    .auth-theme-toggle {
        top: 14px;
        right: 14px;
        width: 40px;
        height: 40px;
    }

    .auth-theme-toggle__icon {
        font-size: 15px;
    }
}

/* ============================================================================
   LOGIN — 4K / 8K viewport fill
   Scoped to body.auth-page (@media min-width: 3840px).
   ============================================================================ */
@media (min-width: 3840px) {
    html:has(body.auth-page.theme-light) {
        background: #e4e7ec;
    }

    html:has(body.auth-page.theme-dark),
    html:has(body.auth-page:not(.theme-light)) {
        background: #0c0e12;
    }

    html:has(body.auth-page),
    body.auth-page {
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        width: 100%;
        max-width: none !important;
        margin: 0 !important;
        padding: 48px !important;
        overflow: hidden;
        transform: none !important;
        transform-origin: top left !important;
        box-sizing: border-box;
        -webkit-font-smoothing: subpixel-antialiased;
        -moz-osx-font-smoothing: auto;
        text-rendering: geometricPrecision;
    }

    body.auth-page .login-container {
        width: 100%;
        max-width: 720px;
        min-height: 560px;
        max-height: min(820px, calc(100dvh - 96px));
        box-sizing: border-box;
    }

    body.auth-page::before,
    body.auth-page::after {
        display: none !important;
        content: none !important;
    }
}
