/* CADS — Computer Aided Dispatch System
 *
 * Uses #dispatcher-window (ID specificity) to fully override styles.css,
 * then builds a CSS grid matching MDCS's .outline structure exactly.
 *
 * Win11 chrome retrofit (Phase 1 desktop redesign, §D.3): frame-only
 * acrylic on #dispatcher-window/#dispatcher-title-bar, mirroring the same
 * frame-acrylic/opaque-content pattern used everywhere else in this pass —
 * deliberately conservative here given this window's data-table density
 * (roster/calls lists, dense forms). Every .cads-* content rule below is
 * intentionally left untouched: no blur, no color/font changes, so nothing
 * a dispatcher needs to read stays exactly as legible as it was.
 */

/* ── Window reset — ID beats class ──────────────────────────── */
#dispatcher-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 820px;
    max-width: calc(100% - 40px);
    height: 560px;
    max-height: calc(100% - 80px);
    background: var(--win11-bg-solid-dark, #202020);
    border: none;
    border-radius: var(--win11-radius-lg, 12px);
    box-shadow: var(--win11-shadow-window, 4px 6px 20px rgba(0,0,0,0.7));
    display: none;
    z-index: 5000;
    overflow: hidden;
    /* Round-2 runtime fix (Runtime Finding #6): was hardcoded 'Lucida
     * Console' (never actually tokenized in round 1, despite the plan's
     * intent to unify frame font across all 5 hand-rolled windows) and,
     * separately, unable to beat frontend/css/fonts.css's pre-existing,
     * untouched blanket rule (`:root, body, body * { font-family:
     * 'Courier New',... !important; }`) without !important regardless.
     * Only affects this outer frame/title-bar (inherited font-family) —
     * .cads-grid and every .cads-* content rule below declare their own
     * explicit 'Lucida Console' font-family and are untouched, per this
     * file's own "frame-only" scope boundary.
     */
    font-family: var(--win11-font, 'Segoe UI', 'Segoe UI Variable', Tahoma, Geneva, Verdana, sans-serif) !important;
}

#dispatcher-window.show {
    display: block;
}

/* ── Title bar — now day/night-responsive (RUN_ID
 * 20260825-day-night-mode-and-themes); frame-only, same acrylic-family
 * treatment as the window above. */
#dispatcher-title-bar {
    background: var(--win11-bg-solid-dark, #202020) !important;
    border: none !important;
    box-shadow: none !important;
    color: #f3f3f3 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Round-2 runtime fix (Runtime Finding #6): fonts.css's `body *` blanket
 * !important rule directly matches every descendant of the title bar too
 * (icon/text/buttons) — inheriting from #dispatcher-window/#dispatcher-
 * title-bar alone isn't enough, a directly-matching declaration always
 * wins over an inherited one. Scoped to #dispatcher-title-bar's own
 * subtree only — does not touch .cads-* content.
 */
#dispatcher-title-bar,
#dispatcher-title-bar * {
    font-family: var(--win11-font, 'Segoe UI', 'Segoe UI Variable', Tahoma, Geneva, Verdana, sans-serif) !important;
}

#dispatcher-title-bar .title-text {
    color: #f3f3f3 !important;
    font-weight: bold;
    letter-spacing: 0.4px;
}

#dispatcher-title-bar .title-icon {
    filter: brightness(1.6) saturate(0);
}

#dispatcher-title-bar .minimize-btn,
#dispatcher-title-bar .close-btn {
    background: transparent !important;
    border: none !important;
    border-radius: var(--win11-radius-sm, 6px) !important;
    color: #f3f3f3 !important;
}

#dispatcher-title-bar .minimize-btn:hover { background: rgba(255, 255, 255, 0.08) !important; color: #fff !important; }
#dispatcher-title-bar .close-btn:hover    { background: #e81123 !important; color: #fff !important; }

/* Accessibility fix (design spec §7): every title-bar button needs a
 * visible keyboard-focus ring, not present here before this run. */
#dispatcher-title-bar .minimize-btn:focus-visible,
#dispatcher-title-bar .close-btn:focus-visible {
    outline: 2px solid #fff !important;
    outline-offset: 2px !important;
}

/* ── Main grid — mirrors MDCS .outline exactly ───────────────── */
.cads-grid {
    position: absolute;
    top: 30px;    /* below title bar */
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: 76px 1fr 1fr 1fr 1fr 1fr;  /* 6 rows: row 1 buttons, rows 2-6 content */
    font-family: 'Lucida Console', monospace;
    font-size: 11px;
    text-transform: uppercase;
    overflow: hidden;
}

/* ── Top button row — row 1, all columns ─────────────────────── */
.cads-btn-row {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
    width: 100%;
    height: 100%;
    border-bottom: 2px solid #000;
}

/* ── Right status column — rows 2–6, col 10 ─────────────────── */
.cads-right-col {
    grid-column: 10;
    grid-row: 2 / -1;
    display: grid;
    grid-template-rows: repeat(5, 1fr);
    gap: 0;
    width: 100%;
    height: 100%;
    border-left: 1px solid #000;
}

/* ── Form column — rows 2–6, cols 1–5 ───────────────────────── */
.cads-form-col {
    grid-column: 1 / 6;
    grid-row: 2 / -1;
    display: flex;
    flex-direction: column;
    background: #f0f0f0;
    border-right: 2px solid #000;
    overflow: hidden;
}

/* ── Roster pane — rows 2–4, cols 6–9 ───────────────────────── */
.cads-roster-pane {
    grid-column: 6 / 10;
    grid-row: 2 / 5;
    display: flex;
    flex-direction: column;
    border-bottom: 2px solid #000;
    overflow: hidden;
}

/* ── Calls pane — rows 5–6, cols 6–9 ────────────────────────── */
.cads-calls-pane {
    grid-column: 6 / 10;
    grid-row: 5 / -1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Button style — mirrors .blue-btn but charcoal ───────────── */
.cads-btn {
    background-color: #3c3c3c;
    color: #e0e0e0 !important;
    border: 2px groove #1a1a1a;
    padding: 0;
    border-radius: 0;
    font-family: 'Lucida Console', monospace;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    margin: 0;
    width: 100%;
    height: 100%;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cads-btn:hover:not(:disabled) { background-color: #555; color: #fff !important; }
.cads-btn:active:not(:disabled) { background-color: #222; }
.cads-btn:focus, .cads-btn:focus-visible { outline: none; box-shadow: none; }

.cads-btn-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    line-height: 1;
    text-align: center;
}

/* Thin separators between adjacent buttons — same as MDCS */
.cads-btn-row .cads-btn:not(:first-child) { border-left: 1px solid #000; }
.cads-right-col .cads-btn:not(:first-child) { border-top: 1px solid #000; }

/* ── Section label bars — silver instead of MDCS yellow ─────── */
.cads-label-bar {
    height: 18px;
    background-color: #c8c8c8;
    border: 1.5px solid #888;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font-family: 'Bebas Neue', 'Lucida Console', monospace;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
    user-select: none;
    letter-spacing: 1px;
}

/* ── Form internals ──────────────────────────────────────────── */
.cads-form-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: #f0f0f0;
}

.cads-upd-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-top: 2px solid #000;
    background: #e0e0e0;
    flex-shrink: 0;
    height: 30px;
    box-sizing: border-box;
}

.cads-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cads-lbl {
    width: 36px;
    flex-shrink: 0;
    font-size: 10px;
    font-weight: bold;
    color: #444;
    text-align: right;
    font-family: 'Lucida Console', monospace;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

.cads-input {
    background: #fff;
    border: 1px solid #999;
    color: #111;
    font-family: 'Lucida Console', monospace;
    font-size: 11px;
    height: 20px;
    padding: 0 4px;
    box-sizing: border-box;
    text-transform: uppercase;
    border-radius: 0;
}

.cads-input:focus {
    outline: none;
    border-color: #444;
    background: #f8f8f8;
}

.cads-input-wide { flex: 1; min-width: 0; }
.cads-input-code { width: 52px; flex-shrink: 0; }
.cads-input-pri  { width: 36px; flex-shrink: 0; cursor: pointer; }

/* ── List areas ──────────────────────────────────────────────── */
.cads-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: #0f0f0f;
    font-family: 'Lucida Console', monospace;
    font-size: 11px;
}

.cads-list .dispatch-item {
    border-bottom: 1px solid #2a2a2a !important;
    color: #ccc;
    padding: 3px 6px !important;
}

.cads-list .dispatch-item:hover    { background: #1a2a1a !important; }
.cads-list .dispatch-item.selected { background: #152030 !important; border-left: 3px solid #888 !important; }

.cads-list .dispatch-meta          { color: #aaa; }
.cads-list .dispatch-meta strong   { color: #eee; }
.cads-list .dispatch-meta span     { color: #666; font-size: 10px; }
.cads-list .dispatch-empty         { color: #444 !important; font-style: italic; text-align: center; padding: 10px; }

.cads-list .dispatch-action {
    background: #2a2a2a !important;
    border-color: #555 !important;
    color: #aaa !important;
    font-size: 10px;
}
.cads-list .dispatch-action:hover     { background: #3a3a3a !important; color: #fff !important; }
.cads-list .dispatch-action.detach    { color: #cc6666 !important; }
.cads-list .dispatch-action.delete    { color: #aa4444 !important; border-color: #663333 !important; }
.cads-list .dispatch-status {
    display: inline-block; padding: 0 4px;
    font-size: 9px; font-weight: bold;
    background: #444; color: #eee;
}

/* ── Scrollbars ──────────────────────────────────────────────── */
.cads-list::-webkit-scrollbar            { width: 5px; }
.cads-list::-webkit-scrollbar-track      { background: #111; }
.cads-list::-webkit-scrollbar-thumb      { background: #3a3a3a; }
.cads-list::-webkit-scrollbar-thumb:hover{ background: #555; }

.cads-form-inner::-webkit-scrollbar            { width: 4px; }
.cads-form-inner::-webkit-scrollbar-track      { background: #ddd; }
.cads-form-inner::-webkit-scrollbar-thumb      { background: #bbb; }
