/* Build prompt Section 6.4 — implemented via CSS variables so both render modes (MAUI Hybrid
   and Web) pick the theme up consistently. Dark is the default (no data-theme attribute needed);
   light is an explicit opt-in via data-theme="light" on <html>, set by theme.js. */
:root {
    --pp-bg: #0f1115;
    --pp-surface: #171a21;
    --pp-surface-alt: #1f232c;
    --pp-border: #2a2f3a;
    --pp-text: #e8eaed;
    --pp-text-muted: #9aa1ab;
    --pp-brand: #4c8dff;
    --pp-accent: #4c8dff;
    --pp-danger: #e5484d;
    --pp-success: #3dd68c;
    --pp-warning: #f5a524;
    --pp-online: var(--pp-success);
    --pp-offline: var(--pp-danger);
}

html[data-theme="light"] {
    --pp-bg: #f5f6f8;
    --pp-surface: #ffffff;
    --pp-surface-alt: #eef0f3;
    --pp-border: #dde1e6;
    --pp-text: #16181d;
    --pp-text-muted: #5b6270;
    --pp-brand: #2f6fed;
    --pp-accent: #2f6fed;
    --pp-danger: #d92d20;
    --pp-success: #12894f;
    --pp-warning: #b54708;
}

html, body {
    background-color: var(--pp-bg);
    color: var(--pp-text);
}

.pp-shell {
    display: flex;
    height: 100vh;
}

.pp-sidebar {
    background-color: var(--pp-surface);
    border-right: 1px solid var(--pp-border);
    width: 260px;
    flex-shrink: 0;
    transition: width 0.15s ease-in-out, opacity 0.15s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
}

.pp-sidebar.collapsed {
    width: 0;
    opacity: 0;
}

.pp-sidebar-inner {
    width: 260px;
    padding: 0.5rem 0;
}

.pp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.pp-toolbar {
    background-color: var(--pp-surface);
    border-bottom: 1px solid var(--pp-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.pp-toolbar-spacer {
    flex: 1;
}

.pp-brand {
    font-weight: 700;
    color: var(--pp-brand);
    text-decoration: none;
    font-size: 1.1rem;
}

.pp-content {
    padding: 1.25rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.pp-nav-section-title {
    color: var(--pp-text-muted);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem 0.25rem;
}

.pp-nav-group {
    border-bottom: 1px solid transparent;
}

.pp-nav-group-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    color: var(--pp-text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.pp-nav-group-title::-webkit-details-marker {
    display: none;
}

.pp-nav-group-title::after {
    content: "";
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--pp-text-muted);
    border-bottom: 1.5px solid var(--pp-text-muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease-in-out;
}

.pp-nav-group[open] > .pp-nav-group-title::after {
    transform: rotate(-135deg);
}

.pp-nav-group-title:hover {
    background-color: var(--pp-surface-alt);
}

.pp-nav-icon {
    flex-shrink: 0;
    opacity: 0.85;
}

.pp-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1rem 0.4rem 2.2rem;
    color: var(--pp-text);
    text-decoration: none;
    border-radius: 0;
}

/* A NavItem given an Icon (currently just Dashboard) is a top-level item, not a group sub-item —
   give it the same indent and weight as a group title instead of the sub-item indent above. */
.pp-nav-link:has(.pp-nav-icon) {
    padding-left: 1rem;
    font-weight: 600;
}

.pp-nav-link:hover {
    background-color: var(--pp-surface-alt);
}

.pp-nav-link.active {
    background-color: var(--pp-surface-alt);
    color: var(--pp-brand);
    font-weight: 600;
}

.pp-connection-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--pp-text-muted);
}

.pp-connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--pp-text-muted);
}

.pp-connection-dot.online {
    background-color: var(--pp-online);
}

.pp-connection-dot.offline {
    background-color: var(--pp-offline);
}

.pp-toolbar-btn {
    background: none;
    border: 1px solid var(--pp-border);
    color: var(--pp-text);
    border-radius: 0.35rem;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
}

.pp-toolbar-btn:hover {
    background-color: var(--pp-surface-alt);
}

.pp-card {
    background-color: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-radius: 0.5rem;
    padding: 1.25rem;
}

/* Full-screen block shown while a database restore runs (MainLayout.razor +
   IBackupMaintenanceState). Nothing on the page should be usable until it clears. */
.pp-maintenance-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.6);
}

.pp-maintenance-card {
    background-color: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-radius: 0.5rem;
    padding: 2rem 2.5rem;
    text-align: center;
    max-width: 420px;
}

/* Dashboard (Dashboard.razor) — stat tiles and a lightweight horizontal-bar list. Deliberately
   plain: no charting library, just a little CSS over the existing .pp-card + Bootstrap grid. */
.pp-stat-label {
    color: var(--pp-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.pp-stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
}

.pp-stat-sub {
    color: var(--pp-text-muted);
    font-size: 0.85rem;
    margin-top: 0.15rem;
}

.pp-bar-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pp-bar-row {
    display: grid;
    grid-template-columns: minmax(7rem, 34%) 1fr auto;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.pp-bar-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pp-bar-track {
    background-color: var(--pp-surface-alt);
    border-radius: 0.25rem;
    height: 0.75rem;
    overflow: hidden;
}

.pp-bar-fill {
    background-color: var(--pp-accent);
    height: 100%;
    border-radius: 0.25rem;
}

.pp-bar-fill.none {
    background-color: var(--pp-warning);
}

.pp-bar-value {
    font-variant-numeric: tabular-nums;
    color: var(--pp-text-muted);
    min-width: 2.5rem;
    text-align: right;
}

/* Reusable "long list" table pattern: a bounded-height, independently-scrolling table body with
   its own header row pinned to the top of that scroll area — not the whole page's. This also
   solves the "keep the title/filters visible too" requirement for free, since they sit in normal
   page flow outside this scroll container and are never carried away by it. First used on the
   Payroll Entry list (600+ rows); reuse for any other list this size (e.g. Employees). */
.pp-table-scroll {
    max-height: 65vh;
    overflow-y: auto;
}

/* Bootstrap's own .table cell rule (.table > :not(caption) > * > *) sets both color and
   background-color from its own --bs-table-color/--bs-table-bg variables, which always resolve
   to Bootstrap's light-mode values (black text, white background) here since this app's
   dark/light system uses its own [data-theme] attribute, never Bootstrap's own [data-bs-theme].
   Body cells end up black-on-white (legible, if theme-mismatched); thead cells only get their
   background overridden below to match the page's dark surface, leaving Bootstrap's own black
   text in place - unreadable against a dark background. Found affecting every .pp-table-scroll
   table app-wide, not just one page - fix the shared rule here rather than patch each table. */
.pp-table-scroll thead th {
    position: sticky;
    top: 0;
    background-color: var(--pp-surface);
    color: var(--pp-text);
    font-weight: 700;
    z-index: 1;
}

/* Reusable "sticky page header" pattern: pins a page's own title (and anything else placed
   inside it, e.g. a status line or action buttons) to the top of .pp-content's scroll region
   while the rest of the page's fields/content scroll underneath - the same sticky-within-a-
   scroll-container principle as .pp-table-scroll above, just applied to a page title instead of
   a table's thead. Wrap the title block in this class on any form/detail page long enough to
   scroll, so there's always a visible answer to "which page/form am I in". */
.pp-sticky-page-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--pp-surface);
}

/* Searchable employee picker (EmployeeCombobox.razor): a plain input with an absolutely
   positioned results menu below it, plus a full-viewport transparent backdrop (rendered only
   while open) that closes the menu on an outside click - avoids the classic blur-fires-before-
   click race you get from closing on the input's own blur/focusout event instead. */
.pp-combobox {
    position: relative;
}

.pp-combobox-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: transparent;
}

.pp-combobox-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    margin-top: 2px;
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--pp-surface);
    border: 1px solid var(--pp-border);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pp-combobox-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.375rem 0.75rem;
    background: none;
    border: none;
    color: var(--pp-text);
}

.pp-combobox-item:hover {
    background-color: var(--pp-surface-alt);
}

.pp-combobox-empty {
    padding: 0.375rem 0.75rem;
    color: var(--pp-text-muted);
}

/* Bootstrap's own .modal-content defaults to a fixed white background/dark text regardless of
   theme — only its CSS is loaded here, not its JS, so modals are plain conditionally-rendered
   markup (see the Deactivate confirmation modal) rather than the JS-driven component, but still
   need the same theme-awareness as everything else or dark mode gets a jarring white popup. */
.modal-content {
    background-color: var(--pp-surface);
    color: var(--pp-text);
    border: 1px solid var(--pp-border);
}

.modal-header, .modal-footer {
    border-color: var(--pp-border);
}

html:not([data-theme="light"]) .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.pp-login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.pp-login-card {
    width: 100%;
    max-width: 360px;
}
