:root {
    /* Token Dark mode colors (default) */
    --bg-gradient-start: rgb(0, 51, 156);
    --bg-gradient-middle: #1a1f2b;
    --bg-gradient-end: rgb(45, 85, 190);
    --text-color: white;
    --primary-color: rgb(59, 130, 246);
    --primary-color-hover: rgb(37, 99, 235);
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-bg-hover: rgba(255, 255, 255, 0.15);
    --card-border: rgba(255, 255, 255, 0.2);
    --input-bg: rgba(255, 255, 255, 0.1);
    --input-border: rgba(255, 255, 255, 0.3);
    --input-focus-border: rgb(59, 130, 246);
    --button-bg: rgb(59, 130, 246);
    --button-bg-hover: rgb(37, 99, 235);
    --logo-opacity: 0.6;
    --logo-hover-opacity: 0.8;
    --pattern-opacity: 0.3;
}

/* Token Light mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg-gradient-start: rgb(65, 105, 225);
        --bg-gradient-middle: #f0f2f8;
        --bg-gradient-end: rgb(30, 144, 255);
        --text-color: #2c3e50;
        --primary-color: rgb(29, 78, 216);
        --primary-color-hover: rgb(30, 58, 138);
        --card-bg: rgba(255, 255, 255, 0.95);
        --card-bg-hover: rgba(255, 255, 255, 1);
        --card-border: rgba(0, 0, 0, 0.1);
        --input-bg: rgba(255, 255, 255, 0.9);
        --input-border: rgba(0, 0, 0, 0.2);
        --input-focus-border: rgb(29, 78, 216);
        --button-bg: rgb(29, 78, 216);
        --button-bg-hover: rgb(30, 58, 138);
        --logo-opacity: 1;
        --logo-hover-opacity: 0.8;
        --pattern-opacity: 0.15;
    }
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-middle), var(--bg-gradient-end));
    background-size: 200% 200%;
    background-position: 70% 50%;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', sans-serif;
    transition: background-position 0.8s ease;
    padding: 2rem 0;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/img/bg-t.svg');
    background-repeat: repeat;
    background-position: center;
    background-size: 8%;
    opacity: var(--pattern-opacity);
    pointer-events: none;
    z-index: -1;
}

.login-container {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--card-border);
    border-radius: 1.5rem;
    padding: 3rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, background 0.3s ease;
}

.login-container:hover {
    transform: translateY(-5px);
    background: var(--card-bg-hover);
}

.brand-header {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.brand-header h2 {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.brand-header p {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 0;
}

.form-floating {
    margin-bottom: 1.5rem;
}

.form-control {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.75rem;
    color: var(--text-color);
    font-size: 1rem;
    padding: 1rem 0.75rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    background: var(--input-bg);
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
    color: var(--text-color);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.form-floating > label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.btn-login {
    background: var(--button-bg);
    border: none;
    border-radius: 0.75rem;
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.875rem;
    width: 100%;
    transition: background 0.3s ease, transform 0.2s ease;
    margin-bottom: 1rem;
}

.btn-login:hover {
    background: var(--button-bg-hover);
    color: white;
    transform: translateY(-2px);
}

.btn-login:focus {
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.forgot-password {
    text-align: center;
    margin-bottom: 1.5rem;
}

.forgot-password a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

.forgot-password a:hover {
    color: var(--primary-color-hover);
    text-decoration: underline;
}

.back-link {
    text-align: center;
    margin-top: 1rem;
}

.back-link a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.back-link a:hover {
    opacity: 1;
    color: var(--text-color);
}

.footer-logo {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
}

.footer-logo a {
    transition: opacity 0.3s ease;
}

.footer-logo a:hover {
    opacity: var(--logo-hover-opacity);
}

/* Light mode adjustments */
@media (prefers-color-scheme: light) {
    .form-control::placeholder {
        color: rgba(0, 0, 0, 0.6);
    }

    .form-floating > label {
        color: rgba(0, 0, 0, 0.7);
    }

    .footer-logo img {
        filter: invert(1);
    }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    body {
        padding: 1rem;
    }

    .login-container {
        padding: 2rem 1.5rem;
    }

    .brand-header h1 {
        font-size: 2rem;
    }

    .brand-header h2 {
        font-size: 1.5rem;
    }
}

/* Loading state */
.btn-login.loading {
    position: relative;
    color: transparent;
}

.btn-login.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}