/* Login Page Styles - Matching Create Account Theme */

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

body.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: 1rem;
    overflow: hidden;
}

/* Main Container */
.login-container {
    width: 100%;
    max-width: 460px;
    padding: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100dvh - 2rem);
}

.login-content {
    width: 100%;
}

/* Brand */
.auth-brand {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1.25rem;
}

.auth-brand a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 0;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.auth-brand a:hover {
    opacity: 0.85;
}

.auth-brand img {
    height: 140px;
    width: auto;
    max-width: min(520px, 92vw);
    object-fit: contain;
    display: block;
    filter: none;
}

.login-container h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #000000;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.login-description {
    font-size: 1rem;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

/* Form */
#loginForm {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Input Group */
.input-group {
    position: relative;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 1rem 1rem;
    font-size: 1.125rem;
    font-family: inherit;
    background: #ffffff;
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    color: #000000;
    transition: all 0.2s ease;
    outline: none;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover {
    border-color: rgba(0, 0, 0, 0.3);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: none;
    outline: none;
}

/* Disable autofill background color */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    -webkit-text-fill-color: #000000 !important;
    transition: background-color 5000s ease-in-out 0s;
}

input::placeholder {
    color: rgba(0, 0, 0, 0.35);
}

/* Password Wrapper */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: rgba(0, 0, 0, 0.4);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: #000000;
}

.toggle-password i {
    font-size: 1.25rem;
}

/* Field Error */
.field-error {
    font-size: 0.75rem;
    color: #dc2626;
    margin-top: 0.5rem;
    padding-left: 0.125rem;
    min-height: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.field-error:not(:empty) {
    opacity: 1;
}

/* Global Error */
.global-error {
    color: #dc2626;
    font-size: 0.875rem;
    text-align: center;
    margin-top: 1rem;
    min-height: 0;
}

.global-error:empty {
    display: none;
}

/* Submit Button */
.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-height: 48px;
    background: #000000;
    color: #ffffff;
    margin-top: 0.5rem;
}

.btn-submit:hover:not(:disabled) {
    background: #1a1a1a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.btn-submit:disabled {
    background: rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.4);
    cursor: not-allowed;
}

/* Submit Button Loading State */
.btn-submit .button-loader {
    display: none;
}

.btn-submit.loading .button-text {
    display: none;
}

.btn-submit.loading .button-loader {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Forgot Password Link */
.forgot-password-link {
    text-align: center;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.forgot-password-link a {
    color: rgba(0, 0, 0, 0.5);
    text-decoration: none;
    transition: color 0.2s ease;
}

.forgot-password-link a:hover {
    color: #000000;
    text-decoration: underline;
}

/* Create Account Link */
.create-account-link {
    text-align: center;
    font-size: 0.9375rem;
    color: rgba(0, 0, 0, 0.5);
    margin-top: 1.25rem;
}

.create-account-link a {
    color: #000000;
    text-decoration: underline;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.create-account-link a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Keyboard Navigation Focus States */
input:focus-visible {
    outline: none;
}

.btn-submit:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    body.login-page {
        padding: 1rem;
        align-items: center;
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .login-container {
        padding: 1.5rem;
        max-width: 100%;
        min-height: calc(100dvh - 2rem);
    }

    .login-container h1 {
        font-size: 1.5rem;
    }

    .login-description {
        font-size: 0.9375rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"] {
        font-size: 1rem;
        padding: 0.875rem 1rem;
    }

    .auth-brand {
        margin-bottom: 1rem;
    }

    .auth-brand img {
        height: 120px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    body.login-page {
        min-height: 100svh;
        padding: 0;
    }

    .login-container {
        min-height: 100svh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 1.25rem;
        padding-top: max(1.5rem, env(safe-area-inset-top));
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }

    .login-container h1 {
        font-size: 1.375rem;
    }

    .login-description {
        font-size: 0.875rem;
    }

    .create-account-link {
        margin-top: 1.5rem;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .auth-brand {
        margin-bottom: 0.875rem;
    }

    .auth-brand img {
        height: 104px;
    }
}

/* Small Mobile */
@media (max-width: 360px) {
    .login-container h1 {
        font-size: 1.25rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"] {
        font-size: 1rem;
        padding: 0.75rem;
    }

    .btn-submit {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
        min-height: 44px;
    }
}

/* Large Screens */
@media (min-width: 1024px) {
    .login-container {
        padding: 3rem;
    }

    .login-container h1 {
        font-size: 2rem;
    }
}

/* Prefer Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    input,
    .btn-submit,
    .field-error {
        transition: none;
    }

    .spinner {
        animation: none;
    }
}

/* ==============================================
   TWO-FACTOR AUTHENTICATION STYLES
   ============================================== */

/* Back to login button */
.back-to-login {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9375rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    margin-bottom: 1.5rem;
    transition: color 0.2s ease;
}

.back-to-login:hover {
    color: #000000;
}

.back-to-login i {
    font-size: 1rem;
}

/* TOTP Input styling */
.totp-input {
    text-align: left;
    font-size: 1.75rem !important;
    font-weight: 600;
    letter-spacing: 0.5em;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.totp-input::placeholder {
    letter-spacing: 0.3em;
    font-weight: 400;
    opacity: 0.3;
}

/* Trust device checkbox */
.trust-device-wrapper {
    margin: 1rem 0;
}

.trust-device-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.trust-device-label input[type="checkbox"] {
    display: none;
}

.trust-device-checkbox {
    width: 20px;
    height: 20px;
    border: 1.5px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.trust-device-checkbox::after {
    content: '';
    width: 10px;
    height: 10px;
    background: #000000;
    border-radius: 2px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.trust-device-label input[type="checkbox"]:checked + .trust-device-checkbox {
    border-color: #000000;
}

.trust-device-label input[type="checkbox"]:checked + .trust-device-checkbox::after {
    opacity: 1;
    transform: scale(1);
}

.trust-device-text {
    font-size: 0.9375rem;
    color: rgba(0, 0, 0, 0.7);
}

/* Session timer */
.totp-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.5);
}

.totp-timer i {
    font-size: 1rem;
}

.totp-timer strong {
    color: rgba(0, 0, 0, 0.7);
    font-weight: 600;
}

/* Backup code section */
.backup-code-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.backup-code-toggle {
    display: inline-block;
    width: 100%;
    background: none;
    border: none;
    color: rgba(0, 0, 0, 0.4);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.backup-code-toggle:hover {
    color: rgba(0, 0, 0, 0.6);
}

.backup-code-form {
    margin-top: 1rem;
}

.backup-code-info {
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.5);
    margin-bottom: 0.75rem;
    text-align: center;
}

.backup-code-input {
    text-align: left;
    font-size: 1.5rem !important;
    font-weight: 600;
    letter-spacing: 0.15em;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    text-transform: uppercase;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body.login-page {
        background: #0a0a0a;
    }

    .login-container {
        color: #ffffff;
    }

    .login-container h1 {
        color: #ffffff;
    }

    .login-description {
        color: rgba(255, 255, 255, 0.5);
    }

    /* Input styling for dark mode */
    input[type="text"],
    input[type="email"],
    input[type="password"] {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.15);
        color: #ffffff;
    }

    input[type="text"]:hover,
    input[type="email"]:hover,
    input[type="password"]:hover {
        border-color: rgba(255, 255, 255, 0.3);
    }

    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="password"]:focus {
        border-color: rgba(255, 255, 255, 0.25);
        box-shadow: none;
    }

    /* Disable autofill background color - dark mode */
    input:-webkit-autofill,
    input:-webkit-autofill:hover,
    input:-webkit-autofill:focus,
    input:-webkit-autofill:active {
        -webkit-box-shadow: 0 0 0 1000px #0a0a0a inset !important;
        -webkit-text-fill-color: #ffffff !important;
    }

    input::placeholder {
        color: rgba(255, 255, 255, 0.35);
    }

    /* Password toggle */
    .toggle-password {
        color: rgba(255, 255, 255, 0.4);
    }

    .toggle-password:hover {
        color: #ffffff;
    }

    /* Field error */
    .field-error {
        color: #f87171;
    }

    /* Global error */
    .global-error {
        color: #f87171;
    }

    /* Submit button - inverted colors */
    .btn-submit {
        background: #ffffff;
        color: #000000;
    }

    .btn-submit:hover:not(:disabled) {
        background: #f0f0f0;
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    }

    .btn-submit:disabled {
        background: rgba(255, 255, 255, 0.15);
        color: rgba(255, 255, 255, 0.4);
    }

    /* Spinner for dark mode buttons */
    .spinner {
        border-color: rgba(0, 0, 0, 0.2);
        border-top-color: #000000;
    }

    /* Forgot password link */
    .forgot-password-link a {
        color: rgba(255, 255, 255, 0.5);
    }

    .forgot-password-link a:hover {
        color: #ffffff;
    }

    /* Create account link */
    .create-account-link {
        color: rgba(255, 255, 255, 0.5);
    }

    .create-account-link a {
        color: #ffffff;
    }

    .create-account-link a:hover {
        opacity: 0.7;
    }

    /* Focus visible states */
    input:focus-visible {
        outline: none;
    }

    .btn-submit:focus-visible {
        outline-color: #ffffff;
    }

    /* 2FA Dark Mode Styles */
    .back-to-login {
        color: rgba(255, 255, 255, 0.5);
    }

    .back-to-login:hover {
        color: #ffffff;
    }

    .trust-device-checkbox {
        border-color: rgba(255, 255, 255, 0.2);
    }

    .trust-device-checkbox::after {
        background: #ffffff;
    }

    .trust-device-label input[type="checkbox"]:checked + .trust-device-checkbox {
        border-color: #ffffff;
    }

    .trust-device-text {
        color: rgba(255, 255, 255, 0.7);
    }

    .totp-timer {
        background: rgba(255, 255, 255, 0.05);
        color: rgba(255, 255, 255, 0.5);
    }

    .totp-timer strong {
        color: rgba(255, 255, 255, 0.8);
    }

    .backup-code-section {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .backup-code-toggle {
        color: rgba(255, 255, 255, 0.4);
    }

    .backup-code-toggle:hover {
        color: rgba(255, 255, 255, 0.6);
    }

    .backup-code-info {
        color: rgba(255, 255, 255, 0.5);
    }

}

