/* === Base === */
html, body {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
}

/* === App Layout (pure CSS, no JS needed) === */
.app-layout {
    display: grid;
    grid-template-rows: 56px 1fr;
    grid-template-columns: 220px 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    min-height: 100vh;
}

.app-bar {
    grid-area: header;
    background: linear-gradient(135deg, #1a237e 0%, #263238 100%);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    position: sticky;
    top: 0;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
}
.app-logo { height: 36px; width: 36px; border-radius: 4px; object-fit: cover; }
.app-title { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.5px; line-height: 1.1; }
.app-subtitle { font-size: 0.65rem; opacity: 0.7; }
.app-spacer { flex: 1; }
.app-user { font-size: 0.85rem; margin-right: 12px; opacity: 0.9; }
.app-logout {
    background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer;
    padding: 6px 10px; border-radius: 4px;
}
.app-logout:hover { background: rgba(255,255,255,0.15); }
.app-login { color: white; text-decoration: none; font-size: 0.9rem; padding: 6px 12px; }

.app-sidebar {
    grid-area: sidebar;
    background: #fafafa;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding-top: 8px;
}

.app-main {
    grid-area: main;
    padding: 20px;
    background: #f5f5f5;
    overflow-y: auto;
}

/* === Nav Menu === */
.nav-menu { padding: 0 8px; }

.nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9e9e9e;
    padding: 16px 12px 4px;
    font-weight: 600;
}

.nav-item {
    display: block;
    padding: 10px 12px;
    color: #424242;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: background 0.15s;
}
.nav-item:hover { background: #e3f2fd; color: #1565C0; text-decoration: none; }
.nav-item.active { background: #1565C0; color: white !important; }
.nav-icon { margin-right: 8px; font-size: 0.9rem; }

/* === Force dark readable text on MudBlazor components === */
.mud-typography { color: #000 !important; }
.mud-typography-h4 { color: #000 !important; }
.mud-typography-h5 { color: #000 !important; }
.mud-typography-h6 { color: #111 !important; }
.mud-typography-subtitle1 { color: #111 !important; }
.mud-typography-subtitle2 { color: #222 !important; }
.mud-typography-body1 { color: #111 !important; }
.mud-typography-body2 { color: #333 !important; }
.mud-typography-caption { color: #444 !important; }
.mud-typography-overline { color: #555 !important; }
.mud-input-label { color: #333 !important; }
.mud-input { color: #000 !important; }
.mud-chip { color: inherit; }
.mud-chip.mud-chip-color-default { color: #333 !important; }

/* MudBlazor buttons — darken outlined and text buttons */
.mud-button-text { color: #1565C0 !important; }
.mud-button-outlined { color: #333 !important; border-color: #999 !important; }
.mud-button-outlined:hover { background: #f0f0f0 !important; color: #111 !important; }
.mud-button-filled { color: white !important; }

/* MudBlazor selects, inputs, labels */
.mud-input-control .mud-input-label { color: #444 !important; }
.mud-select .mud-input { color: #000 !important; }
.mud-input-slot { color: #000 !important; }
.mud-list-item { color: #111 !important; }

/* MudBlazor alert text */
.mud-alert-text { color: #111 !important; }

/* MudDataGrid text */
.mud-table-cell { color: #111 !important; }
.mud-table-head .mud-table-cell { color: #000 !important; font-weight: 600; }

/* MudPaper text */
.mud-paper { color: #111; }

/* Keep white text on colored elements */
.app-bar, .app-bar * { color: white !important; }
.app-bar a { color: white !important; }
.welcome-banner, .welcome-banner * { color: white !important; }
.mud-chip-color-primary, .mud-chip-color-secondary, .mud-chip-color-info,
.mud-chip-color-success, .mud-chip-color-warning, .mud-chip-color-error { color: white !important; }
.mud-alert-filled { color: white !important; }
.mud-alert-filled .mud-alert-text { color: white !important; }
.mud-button-filled.mud-button-color-primary,
.mud-button-filled.mud-button-color-secondary,
.mud-button-filled.mud-button-color-success { color: white !important; }
.nav-item.active { color: white !important; }

/* === Overtime highlight (light mode) === */
.ot-highlight { color: #c62828; }

/* === Mobile bottom nav === */
.mobile-nav {
    display: none;
}

/* === Mobile: hide sidebar, show bottom nav === */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }
    .app-sidebar { display: none; }
    .app-user { display: none; }
    .app-main { padding: 12px 12px 80px 12px; } /* extra bottom padding for nav bar */

    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ffffff;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
        z-index: 1000;
        justify-content: space-around;
        padding: 4px 0 env(safe-area-inset-bottom, 4px);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: #757575;
        font-size: 1.2rem;
        padding: 6px 8px;
        border-radius: 8px;
        min-width: 56px;
        transition: color 0.15s;
    }
    .mobile-nav-item small {
        font-size: 0.6rem;
        margin-top: 2px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
    .mobile-nav-item:hover,
    .mobile-nav-item:active {
        color: #1565C0;
        text-decoration: none;
    }
    .mobile-nav-primary {
        background: #1565C0;
        color: white !important;
        border-radius: 50%;
        width: 52px;
        height: 52px;
        margin-top: -16px;
        box-shadow: 0 2px 8px rgba(21,101,192,0.4);
        justify-content: center;
        padding: 0;
    }
    .mobile-nav-primary small { display: none; }
    .mobile-nav-primary span { font-size: 1.4rem; }
}

/* === Dark mode: ONLY for Identity/Account pages (Bootstrap forms) ===
   MudBlazor pages are forced to light mode via IsDarkMode="false" on MudThemeProvider.
   This section handles the static SSR pages (Login, Register, etc.) that use Bootstrap. */
@media (prefers-color-scheme: dark) {

    /* Body background for Identity pages */
    body { background: #1e1e2e; color: #e0e0e0; }
    h1, h2, h3, h4, h5, h6 { color: #e0e0e0; }
    a { color: #64b5f6; }
    a:hover { color: #90caf9; }

    /* Bootstrap form controls (Identity/Account pages only) */
    .form-control, .form-select {
        background: #2a2a3e !important;
        color: #e0e0e0 !important;
        border-color: #555 !important;
    }
    .form-control:focus, .form-select:focus {
        background: #2a2a3e !important;
        color: #fff !important;
        border-color: #42A5F5 !important;
        box-shadow: 0 0 0 0.2rem rgba(66,165,245,0.25) !important;
    }
    .form-control::placeholder { color: #888 !important; }
    .form-check-input { background-color: #2a2a3e; border-color: #555; }
    .form-check-label { color: #ccc; }
    .form-floating > label { color: #999; }
    .btn-primary { background-color: #1976D2; border-color: #1565C0; }
    .text-danger { color: #ef9a9a !important; }
    .validation-message { color: #ef9a9a !important; }
    p, label, span { color: #ccc; }

    /* App shell adapts to dark */
    .app-bar { background: linear-gradient(135deg, #1a237e 0%, #263238 100%); }
    .app-sidebar { background: #1a1a2e; border-right-color: #333; }
    .nav-item { color: #e0e0e0; }
    .nav-item:hover { background: #2a2a4a; color: #90caf9; }
    .nav-item.active { background: #42A5F5; color: white !important; }
    .nav-section { color: #777; }
    .mobile-nav { background: #1a1a2e; border-top-color: #333; }
    .mobile-nav-item { color: #b0b0b0; }

    /* Reconnect modal */
    #components-reconnect-modal::after { background: #2a2a3e; color: #e0e0e0; }
}

/* === Blazor reconnect UI === */
#components-reconnect-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.6);
    align-items: center;
    justify-content: center;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}
#components-reconnect-modal::after {
    content: "Connection lost. Reconnecting...";
    background: white;
    color: #333;
    padding: 24px 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
#components-reconnect-modal.components-reconnect-failed::after {
    content: "Connection lost. Please refresh the page.";
}
#components-reconnect-modal.components-reconnect-rejected::after {
    content: "Session expired. Please refresh to sign in again.";
}

a, .btn-link {
    color: #1565C0;
}

.btn-primary {
    color: #fff;
    background-color: #1565C0;
    border-color: #0d47a1;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #42a5f5;
}

h1:focus { outline: none; }

/* === Form validation === */
.valid.modified:not([type=checkbox]) { outline: 1px solid #2E7D32; }
.invalid { outline: 1px solid #c62828; }
.validation-message { color: #c62828; }

/* === Blazor error UI === */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* === Identity form overrides === */
.darker-border-checkbox.form-check-input { border-color: #929292; }
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder { text-align: start; }

/* === Branding utilities === */
.form-section {
    padding: 20px 24px;
    margin-bottom: 16px;
    border-left: 4px solid var(--mud-palette-primary);
    background: var(--mud-palette-surface);
    border-radius: 4px;
}

.form-section-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--mud-palette-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.stat-card {
    text-align: center;
    padding: 16px;
    border-radius: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.welcome-banner {
    background: linear-gradient(135deg, var(--mud-palette-primary) 0%, var(--mud-palette-primary-darken) 100%);
    color: white;
    border-radius: 12px;
    padding: 24px 32px;
    margin-bottom: 24px;
}

/* === Print utilities === */
.print-only { display: none; }
.no-print { display: block; }

/* === Report letterhead === */
.report-letterhead {
    display: none;
}

@media print {
    .print-only { display: block !important; }
    .no-print { display: none !important; }
    .report-letterhead {
        display: flex !important;
        align-items: center;
        gap: 16px;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 2px solid #000;
    }
    .report-letterhead img {
        width: 60px;
        height: 60px;
        object-fit: cover;
    }
    .report-letterhead .company-name {
        font-size: 14pt;
        font-weight: bold;
    }
    .report-letterhead .company-address {
        font-size: 9pt;
        color: #555;
    }
}
