/* ================================================================
   EDP Health — Shared Styles
   Loaded by all three dashboard pages.
   ================================================================ */

/* ── Brand tokens ──────────────────────────────────────────────── */
:root {
    --royal:        #221B95;
    --indigo:       #455FFF;
    --jade:         #00A86B;
    --navy:         #00023F;
    --charcoal:     #3F5461;
    --slate:        #7F929D;
    --smoke:        #BFC9CF;
    --ash:          #F1F4F5;
    --mist:         #ECEFFF;
    --error-1:      #B92020;
    --error-2:      #FFE6E6;
    --white:        #FFFFFF;
    --amber:        #D97706;
    --amber-light:  #FEF3C7;
    --amber-dark:   #92400E;
    --jade-light:   #D1FAE5;
    --jade-dark:    #065F46;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Base ──────────────────────────────────────────────────────── */
body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 300;
    background: var(--ash);
    color: var(--charcoal);
    line-height: 1.5;
}
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ── Header ────────────────────────────────────────────────────── */
.header {
    background: linear-gradient(135deg, var(--royal) 0%, #2E25BD 60%, var(--indigo) 100%);
    color: var(--white);
    padding: 16px 24px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
}
.header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.header-text { flex: 1; min-width: 0; }
.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}
.header-brand-divider {
    width: 1px; height: 24px;
    background: rgba(255,255,255,0.25);
    flex-shrink: 0;
}
.header-page-title {
    font-size: 17px;
    font-weight: 600;
    color: rgba(255,255,255,0.92);
    letter-spacing: 0.1px;
}
.header .subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    font-weight: 300;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding-top: 2px;
}
.user-display {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* ── Page nav (inside header) ──────────────────────────────────── */
.page-nav {
    display: flex;
    gap: 2px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.15);
}
.page-nav-link {
    color: rgba(255,255,255,0.52);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 11px;
    border-radius: 5px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.page-nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.85);
}
.page-nav-link.active {
    background: rgba(255,255,255,0.17);
    color: var(--white);
    font-weight: 600;
}

/* ── Help button ───────────────────────────────────────────────── */
.help-btn {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.85); font-size: 13px; font-weight: 500;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s; line-height: 1;
    font-family: inherit; flex-shrink: 0;
}
.help-btn:hover { background: rgba(255,255,255,0.22); color: var(--white); }

/* ── Theme toggle (sits in .header-actions, on the brand gradient) ─ */
.theme-toggle {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.85);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s; line-height: 1;
    font-family: inherit; flex-shrink: 0; padding: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.22); color: #fff; }
.theme-toggle svg { width: 15px; height: 15px; display: block; }

/* ── Snapshot info ─────────────────────────────────────────────── */
.snapshot-info {
    margin-top: 7px; font-size: 14px; color: rgba(255,255,255,0.65); display: none;
}
.snapshot-info.visible { display: block; }
.snapshot-info strong { color: rgba(255,255,255,0.95); font-weight: 600; font-size: 15px; }
.snapshot-info .tz-note { margin-left: 10px; font-size: 12px; opacity: 0.8; letter-spacing: 0.3px; }

/* ── Summary bar ───────────────────────────────────────────────── */
.summary-bar {
    background: var(--white);
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.summary-bar-visual {
    height: 8px; border-radius: 4px; overflow: hidden;
    display: flex; background: #f1f5f9;
}

/* ── Controls ──────────────────────────────────────────────────── */
.controls {
    background: var(--white);
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.controls-row {
    display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end;
}
.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group.grow { flex: 1; min-width: 200px; }
.control-label {
    font-size: 11px; font-weight: 500; text-transform: uppercase;
    color: var(--slate); letter-spacing: 0.5px;
}

/* ── Form elements ─────────────────────────────────────────────── */
.search-input {
    padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; width: 100%; background: #f8fafc;
    font-family: inherit; font-weight: 300; color: var(--charcoal);
}
.search-input:focus {
    outline: none; border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(69,95,255,0.15);
}
.file-row { display: flex; gap: 8px; align-items: center; }
.file-row input[type="file"] {
    padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; background: #f8fafc; flex: 1; min-width: 0; font-family: inherit;
}
.submit-btn {
    padding: 7px 18px; border: none; border-radius: 6px; font-size: 13px;
    font-weight: 500; background: var(--indigo); color: var(--white);
    cursor: pointer; transition: background 0.15s; font-family: inherit;
}
.submit-btn:hover:not(:disabled) { background: var(--royal); }
.submit-btn:disabled { background: var(--smoke); cursor: not-allowed; }

/* ── Multi-select dropdown ─────────────────────────────────────── */
.multi-select { position: relative; min-width: 160px; }
.multi-select-trigger {
    padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; background: var(--white); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center;
    transition: border-color 0.15s; font-family: inherit;
}
.multi-select-trigger:hover { border-color: var(--slate); }
.multi-select-trigger.open {
    border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(69,95,255,0.15);
}
.multi-select-trigger.has-selection {
    border-color: var(--indigo); background: var(--mist); color: var(--royal); font-weight: 500;
}
.multi-select-trigger .chevron { font-size: 10px; color: var(--slate); transition: transform 0.2s; }
.multi-select-trigger.open .chevron { transform: rotate(180deg); }
.multi-select-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
    background: var(--white); border: 1px solid #e2e8f0; border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 300px; overflow-y: auto; z-index: 1000; display: none;
}
.multi-select-dropdown.open { display: block; }
.multi-select-option {
    padding: 7px 12px; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; gap: 8px; transition: background 0.1s;
}
.multi-select-option:hover { background: #f8fafc; }
.multi-select-option input[type="checkbox"] { margin: 0; cursor: pointer; }
.multi-select-count { font-size: 12px; color: var(--slate); margin-left: 4px; }

/* ── Filter chips ──────────────────────────────────────────────── */
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; background: #f1f5f9; border: 1px solid #e2e8f0;
    border-radius: 20px; font-size: 12px; cursor: pointer;
    transition: all 0.15s; user-select: none; font-family: inherit;
}
.chip:hover { background: #e2e8f0; }
.chip.active { background: var(--indigo); color: var(--white); border-color: var(--indigo); }
/* Status-toned active chips (shared by every status filter across the dashboards): the active
   chip fills with its status color rather than a flat indigo. Builders add one tone class
   (chip-good / chip-warn / chip-bad / chip-muted) alongside .chip. Chips without a tone (e.g. the
   admin level filters) keep the indigo default above. */
.chip.chip-good.active  { background: var(--jade);    border-color: var(--jade); }
.chip.chip-warn.active  { background: var(--amber);   border-color: var(--amber); }
.chip.chip-bad.active   { background: var(--error-1); border-color: var(--error-1); }
.chip.chip-muted.active { background: var(--slate);   border-color: var(--slate); }
.chip .dot, .chip-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
}
.chip.active .dot, .chip.active .chip-dot { background: rgba(255,255,255,0.7); }
.chip .count { font-size: 10px; font-weight: 700; opacity: 0.7; margin-left: 2px; }

/* ── Sort / view buttons ───────────────────────────────────────── */
.sort-btn, .view-btn {
    padding: 5px 12px; border: 1px solid #e2e8f0; background: var(--white);
    border-radius: 6px; font-size: 12px; cursor: pointer; transition: all 0.15s;
    font-family: inherit; font-weight: 400;
}
.sort-btn:hover, .view-btn:hover { border-color: var(--slate); }
.sort-btn.active { background: var(--royal); color: var(--white); border-color: var(--royal); }
.view-btn.active { background: var(--royal); color: var(--white); border-color: var(--royal); }

/* ── Developer / upload section ────────────────────────────────── */
.developer-controls, .upload-section {
    background: var(--white);
    padding: 14px 20px;
    border-radius: 10px;
    margin-top: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.section-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--slate); letter-spacing: 0.5px; margin-bottom: 10px;
}

/* ── Drag-and-drop overlay ─────────────────────────────────────── */
.drop-overlay {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(69, 95, 255, 0.08);
    border: 3px dashed var(--indigo);
    z-index: 1000;
    align-items: center; justify-content: center;
    pointer-events: none;
}
.drop-overlay.active { display: flex; }
.drop-overlay-inner {
    background: var(--white); padding: 32px 48px; border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12); text-align: center;
}
.drop-overlay-inner .drop-icon { font-size: 36px; margin-bottom: 8px; display: block; color: var(--indigo); }
.drop-overlay-inner strong { font-size: 16px; color: var(--charcoal); display: block; margin-bottom: 4px; }
.drop-overlay-inner span { font-size: 13px; color: var(--slate); }

/* ── No data empty state ───────────────────────────────────────── */
.no-data {
    text-align: center; padding: 60px 20px; color: var(--slate);
    background: var(--white); border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.no-data-icon { font-size: 40px; margin-bottom: 12px; display: block; }
.no-data strong { color: var(--charcoal); display: block; margin-bottom: 4px; }

/* ── Help modal ────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white); border-radius: 12px;
    width: 90%; max-width: 700px; max-height: 88vh;
    overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.modal-header {
    padding: 20px 24px 14px;
    border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-header h2 { font-size: 17px; font-weight: 500; color: var(--royal); }
.modal-close {
    width: 28px; height: 28px; border-radius: 6px;
    background: var(--ash); border: none; cursor: pointer;
    font-size: 18px; color: var(--slate);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s; flex-shrink: 0; font-family: inherit;
}
.modal-close:hover { background: var(--mist); color: var(--royal); }
.modal-body { padding: 20px 24px; }
.modal-section { margin-bottom: 20px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section h3 {
    font-size: 11px; font-weight: 500; text-transform: uppercase;
    color: var(--slate); letter-spacing: 0.5px; margin-bottom: 10px;
}
.modal-section p { font-size: 14px; color: var(--charcoal); line-height: 1.6; font-weight: 300; margin-bottom: 8px; }
.modal-section p:last-child { margin-bottom: 0; }
.modal-section ul { font-size: 14px; color: var(--charcoal); line-height: 1.7; padding-left: 20px; font-weight: 300; }
.modal-section li { margin-bottom: 4px; }
.modal-section code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px; background: var(--mist); padding: 1px 5px; border-radius: 3px; color: var(--indigo);
}
.status-legend { display: flex; flex-direction: column; gap: 10px; }
.status-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.status-label { font-weight: 500; min-width: 70px; color: var(--royal); }
.status-desc { color: var(--charcoal); line-height: 1.5; font-weight: 300; }
.control-help-row {
    display: flex; gap: 12px; margin-bottom: 10px; align-items: flex-start;
    padding-bottom: 10px; border-bottom: 1px solid var(--ash);
}
.control-help-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.control-help-name { font-size: 13px; font-weight: 500; color: var(--royal); min-width: 120px; flex-shrink: 0; padding-top: 1px; }
.control-help-desc { font-size: 13px; color: var(--charcoal); line-height: 1.5; font-weight: 300; }

/* ── Pipeline technology icon + "View" link ────────────────────── */
/* Group the icon and link as one flex item so the row's gap sits to their left, not between them. */
.pipeline-view { display: inline-flex; align-items: center; flex-shrink: 0; }
.pipeline-type-icon {
    width: 14px; height: 14px; object-fit: contain;
    margin-right: 4px; flex-shrink: 0;
}

/* ── Responsive base ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .container { padding: 10px; }
    .header { padding: 12px 16px 10px; }
    .header-actions { flex-wrap: wrap; }
}

/* ================================================================
   DARK THEME
   Activated by html[data-theme="dark"] (set by theme.js before the
   first paint, so there is no light flash). Light mode is the default
   and is left completely unchanged.

   Strategy: the shared chrome and every per-page style.css are built
   almost entirely on the neutral brand tokens below, so remapping the
   tokens to a dark, navy-tinted palette (reused from the already
   colour-validated Incident Detail page) flips the large majority of the UI
   for free. The brand accents (--royal / --indigo / --jade / --amber /
   --error-1) are kept as *fill* colours (dots, bars, buttons, the
   header gradient) — they read well on dark — with targeted overrides
   only where those colours were used as *text* on a dark surface.
   ================================================================ */
html[data-theme="dark"] {
    color-scheme: dark;

    /* neutrals → dark navy-tinted scale */
    --ash:      #0C0F1A;   /* page background            (was #F1F4F5) */
    --white:    #171B2E;   /* card / surface             (was #FFFFFF) */
    --charcoal: #E6E9F4;   /* primary text               (was #3F5461) */
    --slate:    #A3AECA;   /* muted / secondary text     (was #7F929D) */
    --smoke:    #7C87A6;   /* dim text, thin borders     (was #BFC9CF) */
    --mist:     #242A46;   /* indigo-tinted fill         (was #ECEFFF) */

    /* status tints: light-tint badge bg → dark tint, dark text → light */
    --jade-light:  #103A2C;
    --jade-dark:   #5FE3A9;
    --amber-light: #3A2C0E;
    --amber-dark:  #FBBF24;
    --error-2:     #3A181B;
    --error-1:     #F87171;

    /* dark-only helpers, referenced by the per-page dark blocks */
    --dark-surface-2: #1E2338;   /* nested rows / input bg   (was #f8fafc) */
    --dark-surface-3: #232A45;   /* subtle bg / track        (was #f1f5f9) */
    --dark-border:    #2C3352;   /* card / control borders   (was #e2e8f0) */
    --dark-border-soft: #232945; /* faint separators */
    --accent-text:    #98A7FF;   /* royal/indigo when used as text on dark */
}

/* Cards / surfaces read by their surface-vs-background contrast; the
   light drop shadows vanish on dark, so give the main panels a hairline
   border for definition. */
html[data-theme="dark"] body:not(.dt-dark) .summary-bar,
html[data-theme="dark"] body:not(.dt-dark) .controls,
html[data-theme="dark"] body:not(.dt-dark) .developer-controls,
html[data-theme="dark"] body:not(.dt-dark) .upload-section,
html[data-theme="dark"] body:not(.dt-dark) .no-data {
    border: 1px solid var(--dark-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* White text that sits on a coloured fill (buttons / chips / header) must
   stay white — the token flip above would otherwise darken it. */
html[data-theme="dark"] body:not(.dt-dark) .header,
html[data-theme="dark"] body:not(.dt-dark) .page-nav-link.active,
html[data-theme="dark"] body:not(.dt-dark) .help-btn:hover,
html[data-theme="dark"] body:not(.dt-dark) .submit-btn,
html[data-theme="dark"] body:not(.dt-dark) .chip.active,
html[data-theme="dark"] body:not(.dt-dark) .sort-btn.active,
html[data-theme="dark"] body:not(.dt-dark) .view-btn.active { color: #fff; }

/* Summary-bar segment track */
html[data-theme="dark"] body:not(.dt-dark) .summary-bar-visual { background: var(--dark-surface-3); }

/* Form controls */
html[data-theme="dark"] body:not(.dt-dark) .search-input,
html[data-theme="dark"] body:not(.dt-dark) .file-row input[type="file"] {
    background: var(--dark-surface-2); border-color: var(--dark-border);
}
html[data-theme="dark"] body:not(.dt-dark) .search-input::placeholder { color: var(--smoke); }

/* Multi-select */
html[data-theme="dark"] body:not(.dt-dark) .multi-select-trigger { border-color: var(--dark-border); }
html[data-theme="dark"] body:not(.dt-dark) .multi-select-dropdown {
    border-color: var(--dark-border); box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
html[data-theme="dark"] body:not(.dt-dark) .multi-select-option:hover { background: var(--dark-surface-2); }
html[data-theme="dark"] body:not(.dt-dark) .multi-select-trigger.has-selection { color: var(--accent-text); }

/* Chips */
html[data-theme="dark"] body:not(.dt-dark) .chip {
    background: var(--dark-surface-3); border-color: var(--dark-border);
}
html[data-theme="dark"] body:not(.dt-dark) .chip:hover { background: var(--dark-border); }
/* Status-toned active chips — dark theme (brighter fills, dark ink for contrast). */
html[data-theme="dark"] body:not(.dt-dark) .chip.chip-good.active  { background: #34D399; border-color: #34D399; color: #0C0F1A; }
html[data-theme="dark"] body:not(.dt-dark) .chip.chip-warn.active  { background: #FBBF24; border-color: #FBBF24; color: #0C0F1A; }
html[data-theme="dark"] body:not(.dt-dark) .chip.chip-bad.active   { background: #F87171; border-color: #F87171; color: #0C0F1A; }
html[data-theme="dark"] body:not(.dt-dark) .chip.chip-muted.active { background: #94A3B8; border-color: #94A3B8; color: #0C0F1A; }

/* Sort / view buttons */
html[data-theme="dark"] body:not(.dt-dark) .sort-btn,
html[data-theme="dark"] body:not(.dt-dark) .view-btn { border-color: var(--dark-border); }

/* Modal */
html[data-theme="dark"] body:not(.dt-dark) .modal-header { border-bottom-color: var(--dark-border); }
html[data-theme="dark"] body:not(.dt-dark) .modal-header h2,
html[data-theme="dark"] body:not(.dt-dark) .modal-close:hover,
html[data-theme="dark"] body:not(.dt-dark) .status-label,
html[data-theme="dark"] body:not(.dt-dark) .control-help-name { color: var(--accent-text); }
html[data-theme="dark"] body:not(.dt-dark) .modal-section code { color: var(--accent-text); }
html[data-theme="dark"] body:not(.dt-dark) .control-help-row { border-bottom-color: var(--dark-border-soft); }

/* Drop overlay */
html[data-theme="dark"] body:not(.dt-dark) .drop-overlay-inner .drop-icon { color: var(--accent-text); }

/* UAT environment banner (injected by shared.js) */
html[data-theme="dark"] body:not(.dt-dark) .uat-env-banner {
    background: #3A2C0E; border-bottom-color: #D97706; color: #FCD34D;
}
