/* =============================================================================
   AUTHENTICATION STYLES
   Login, registration, and password reset pages

   Uses employee CSS design system variables and components.
   Only auth-specific layout and component styles are defined here.
   ============================================================================= */


/* =============================================================================
   1. AUTH PAGE LAYOUT
   Fixed viewport, centered card layout
   ============================================================================= */

.auth-page {
    height: 100%;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f1f5 100%);
    padding: var(--space-5);
    box-sizing: border-box;
    overflow: hidden;
}

.auth-wrapper {
    width: 100%;
    max-width: 400px;
}

/* Wide wrapper for registration form */
.auth-wrapper--wide {
    max-width: 500px;
}


/* =============================================================================
   2. AUTH CARD
   Glass-morphism card container
   ============================================================================= */

.auth-card {
    background: var(--glass-white-strong);
    backdrop-filter: var(--blur-lg);
    -webkit-backdrop-filter: var(--blur-lg);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-lg);
}


/* =============================================================================
   3. AUTH BRAND HEADER
   Logo, title, and divider
   ============================================================================= */

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--space-6);
}

.auth-brand img {
    width: 64px;
    height: 64px;
    margin-bottom: var(--space-4);
}

.auth-brand h1 {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
    margin: 0;
    letter-spacing: var(--tracking-tight);
}

.auth-divider {
    width: 40px;
    height: 3px;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    margin-top: var(--space-4);
}


/* =============================================================================
   4. AUTH CONTENT SECTIONS
   Headers, sections for multi-step forms
   ============================================================================= */

.auth-header {
    text-align: center;
    margin-bottom: var(--space-4);
}

.auth-header .card-title {
    margin-bottom: var(--space-2);
}

/* Section dividers for multi-section forms (registration) */
.auth-section {
    margin-bottom: var(--space-5);
}

.auth-section-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-border-light);
}


/* =============================================================================
   5. AUTH STATUS ICONS
   Large emoji/icon indicators for status pages
   ============================================================================= */

.auth-icon {
    font-size: var(--text-5xl);
    margin-bottom: var(--space-4);
    display: block;
}

.auth-icon--primary { color: var(--color-primary); }
.auth-icon--success { color: var(--color-success); }
.auth-icon--warning { color: var(--color-warning); }
.auth-icon--danger { color: var(--color-danger); }


/* =============================================================================
   6. AUTH INFO BOX
   Sunken box for instructions/info
   ============================================================================= */

.auth-info-box {
    background: var(--color-surface-sunken);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-5);
    text-align: left;
}

.auth-info-box ul {
    margin: 0;
    padding-left: var(--space-5);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}


/* =============================================================================
   7. AUTH FOOTER & LINKS
   Bottom section with links
   ============================================================================= */

.auth-footer {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border-light);
}

.auth-footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.auth-footer-links a {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.auth-form-footer {
    text-align: center;
    margin-top: var(--space-4);
}

/* Inline button wrapper for anchors styled as buttons */
.auth-btn-inline {
    display: inline-flex;
}


/* =============================================================================
   8. AUTH INFO BOX
   Sunken background box for instructions and informational messages
   ============================================================================= */

.auth-info-box {
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface-sunken);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
    text-align: center;
}

.auth-info-box p {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-3) 0;
}

.auth-info-box p:last-child {
    margin-bottom: 0;
}

.auth-info-box ul {
    margin: 0;
    padding-left: var(--space-5);
    font-size: 14px;
    color: var(--color-text-secondary);
}


/* =============================================================================
   9. PASSWORD TOGGLE
   Show/hide password input
   ============================================================================= */

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

.password .form-control {
    flex: 1;
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0;
    font-size: 1.15rem;
    transition: color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--color-text-primary);
}

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

.password-toggle [icon="fluent:eye-off-20-filled"] {
    display: none;
}

.password.is-visible .password-toggle [icon="fluent:eye-20-filled"] {
    display: none;
}

.password.is-visible .password-toggle [icon="fluent:eye-off-20-filled"] {
    display: inline-block;
}


/* =============================================================================
   10. iOS PWA FIXES
   Prevent overscroll/bounce on iOS
   ============================================================================= */

@supports (-webkit-touch-callout: none) {
    .auth-page {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        -webkit-overflow-scrolling: none;
        overscroll-behavior: none;
    }
}

@media (display-mode: standalone) {
    .auth-page {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
    }
}


/* =============================================================================
   11. RESPONSIVE
   Mobile adjustments
   ============================================================================= */

@media (max-width: 480px) {
    .auth-page {
        padding: var(--space-4);
        align-items: flex-start;
        padding-top: env(safe-area-inset-top);
    }

    .auth-card {
        padding: var(--space-5);
    }
}


/* =============================================================================
   12. LEGACY CARD-BASED LAYOUT
   Deprecated card layout used by auth_base.html (invitations, error pages).
   Not used by modern login/password-reset flows. Kept for backward compatibility.
   ============================================================================= */

/* (See sections 3-7 above for old auth-card, auth-brand, auth-divider styles) */


/* =============================================================================
   13. MODERN LOGIN PAGE (SPLIT LAYOUT)
   Desktop: split left-right with form and background image
   Mobile: stacked with image hidden
   ============================================================================= */

/* Override wrapper constraints for full-screen login */
.auth-wrapper--login {
    width: 100%;
    max-width: 100%;
}

.login-container {
    display: flex;
    height: 100%;
    height: 100dvh;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: var(--color-background-primary);
    z-index: 10;
    overflow-y: auto;
}

.login-form-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.login-branding {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo {
    height: auto;
    width: 80px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
}

.login-header {
    text-align: center;
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 var(--space-1) 0;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.login-subtitle {
    font-size: 16px;
    color: var(--color-text-secondary);
    margin: 0;
    font-weight: 400;
    line-height: 1.5;
}

.login-form .form-group {
    margin-bottom: var(--space-6);
}

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

.login-form .form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    border: 1px solid var(--color-border-light);
    border-radius: 12px;
    background: var(--color-surface-default);
    color: var(--color-text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    height: 48px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.login-form .form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(59, 130, 246, 0.15);
}

.login-form .form-control.is-invalid {
    border-color: var(--color-danger);
}

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

.login-footer-links {
    margin-bottom: var(--space-4);
    display: flex;
    justify-content: flex-end;
}

.login-footer-links .help-text {
    font-size: 14px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.login-footer-links .help-text:hover {
    text-decoration: underline;
}

.login-footer-links--centered {
    margin-top: var(--space-6);
    justify-content: center;
}

.login-form .btn {
    margin-top: var(--space-2);
    font-size: 16px;
    font-weight: 600;
    padding: var(--space-3) var(--space-4);
}

.error-banner {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-md);
    color: var(--color-danger);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.error-text {
    display: block;
    color: var(--color-danger);
    font-size: var(--text-xs);
    margin-top: var(--space-1);
}

/* Login background image - desktop only */
.login-background {
    flex: 1;
    display: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.login-bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.login-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

/* Desktop: show split layout */
@media (min-width: 1024px) {
    .auth-page {
        padding: 8rem 10rem;
    }

    .auth-wrapper--login {
        max-width: 100%;
        width: 100%;
        height: calc(100dvh - var(--space-12));
        border-radius: var(--radius-2xl);
        overflow: hidden;
        box-shadow:
            0 1px 3px rgba(0, 0, 0, 0.08),
            0 4px 12px rgba(0, 0, 0, 0.12),
            0 10px 30px rgba(0, 0, 0, 0.16),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }

    .login-container {
        flex-direction: row;
        height: 100%;
    }

    .login-form-panel {
        flex: 0 0 50%;
        max-width: 50%;
        background: var(--color-background-primary);
    }

    .login-background {
        display: flex;
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Tablet: stack but keep form readable */
@media (min-width: 768px) and (max-width: 1023px) {
    .login-form-panel {
        flex: 1;
        padding: var(--space-8) var(--space-6);
    }

    .login-form-wrapper {
        max-width: 480px;
        margin: 0 auto;
    }
}

/* Mobile: full screen form, hide image */
@media (max-width: 767px) {
    .login-container {
        flex-direction: column;
    }

    .login-form-panel {
        flex: 1;
        padding: var(--space-4) var(--space-4);
        padding-top: max(var(--space-4), env(safe-area-inset-top));
    }

    .login-form-wrapper {
        max-width: 100%;
    }

    .login-background {
        display: none;
    }
}
