/*
 * Light theme. assets/js/theme.js sets <html data-theme="light|dark"> before
 * the page draws; dark is the pages' own styles, so everything here only
 * applies to light. Included on every staff page, after the page's styles.
 *
 * Most colours come from the page variables (--bg, --panel, --fg, …),
 * swapped below. The rest are colours written straight into the pages
 * (inline style="…" on modals, error boxes, and a few rules) and into the
 * shared dialogs — each overridden here.
 */

:root[data-theme="light"]{
  color-scheme: light;
  --bg:        #eef0f3;
  --panel:     #ffffff;
  --panel-2:   #f3f4f6;
  --line:      #d3d7de;
  --line-soft: #e6e8eb;
  --fg:        #111418;
  --fg-dim:    #262c35;
  --fg-faint:  #3f4753;
  /* Status colours, a shade deeper so they read on white. */
  --danger:    #d92d2d;
  --warning:   #c98a00;
  --info:      #1f7ae0;
}
/* Secondary text (hints, labels, times, meta lines) must read clearly in
   both themes: these greys replace the pages' dimmer ones (#9a9a9a /
   #5c5c5c on black) and clear WCAG AA contrast by a wide margin. */
:root[data-theme="dark"]{
  color-scheme: dark;
  --fg-dim:    #dcdcdc;
  --fg-faint:  #c2c2c2;
}
.text-muted, .text-secondary{ color:var(--fg-dim) !important; }

[data-theme="light"] body{ background:var(--bg); color:var(--fg); }

/* ---- Colours written inline in the pages (modals, notices) ---- */
[data-theme="light"] [style*="background:#0d0d0d"]{ background:var(--panel) !important; }
[data-theme="light"] [style*="background:#141414"],
[data-theme="light"] [style*="background:#161616"],
[data-theme="light"] [style*="background:#1c1c1c"]{ background:var(--panel-2) !important; }
[data-theme="light"] [style*="color:#fff"]{ color:var(--fg) !important; }
[data-theme="light"] [style*="color:#999"]{ color:var(--fg-dim) !important; }
[data-theme="light"] [style*="#2b2b2b"]{ border-color:var(--line) !important; }

/* ---- Bootstrap pieces ---- */
[data-theme="light"] .modal-content{ background:var(--panel) !important; color:var(--fg) !important; border-color:var(--line) !important; }
[data-theme="light"] .modal-header, [data-theme="light"] .modal-footer{ border-color:var(--line) !important; }
[data-theme="light"] .btn-close-white{ filter:none; }
[data-theme="light"] .dropdown-menu{ box-shadow:0 6px 20px rgba(0,0,0,.12); }
[data-theme="light"] .form-control, [data-theme="light"] .form-select,
[data-theme="light"] .form-control:focus, [data-theme="light"] .form-select:focus{ background-color:#fff; color:var(--fg); }
[data-theme="light"] .form-control:disabled, [data-theme="light"] .form-select:disabled{ background-color:var(--panel-2); color:var(--fg-dim); }
/* Disabled fields in dark mode (e.g. settings only a super admin may
   change): Bootstrap's own :disabled rule is more specific than the pages'
   black .form-control and painted them light grey. Keep them dark — a
   shade lighter than an editable field, with dimmer text, so they still
   read as not editable. :not(light) also covers a page with no theme set. */
:root:not([data-theme="light"]) .form-control:disabled,
:root:not([data-theme="light"]) .form-select:disabled,
:root:not([data-theme="light"]) .form-control[readonly]{
  background-color:var(--panel-2, #141414); color:var(--fg-dim, #9a9a9a); border-color:var(--line, #2b2b2b); opacity:1;
}
/* The file picker's "Choose File" button: Bootstrap's is light grey in
   both themes — follow the theme instead (dimmer when disabled). */
.form-control::file-selector-button{
  background-color:var(--panel-2, #141414); color:var(--fg, #fff); border-color:var(--line, #2b2b2b);
}
.form-control:hover:not(:disabled):not([readonly])::file-selector-button{
  background-color:var(--line, #2b2b2b);
}
.form-control:disabled::file-selector-button{
  background-color:var(--panel-2, #141414); color:var(--fg-dim, #9a9a9a);
}
[data-theme="light"] .form-check-input{ background-color:#fff; }
[data-theme="light"] .form-check-input:checked{ background-color:var(--info); border-color:var(--info); }
[data-theme="light"] .input-group-text{ background:var(--panel-2); color:var(--fg-dim); border-color:var(--line); }
[data-theme="light"] .table{ --bs-table-color: var(--fg); --bs-table-bg: transparent; }

/* ---- Buttons and toggles that invert on hover / when active ---- */
[data-theme="light"] .btn-mono:hover,
[data-theme="light"] .btn-mono-soft.active,
[data-theme="light"] .range-tools .btn.active,
[data-theme="light"] .shape-btn-group input[type="radio"]:checked + label,
[data-theme="light"] .btn-accent:hover{ color:#fff; }
[data-theme="light"] .btn-danger-soft:hover{ color:#fff; }
[data-theme="light"] a:focus-visible, [data-theme="light"] button:focus-visible,
[data-theme="light"] [tabindex]:focus-visible, [data-theme="light"] input:focus-visible{ outline-color:var(--fg); }
[data-theme="light"] ::-webkit-scrollbar-track{ background:var(--panel-2); }
[data-theme="light"] ::-webkit-scrollbar-thumb{ background:#c3c8d0; }

/* ---- Dashboard ---- */
[data-theme="light"] #map, [data-theme="light"] #geoPickerMap{ background:#dfe3e8; }
[data-theme="light"] .stat-card.warn .stat-num{ color:var(--fg); }
[data-theme="light"] .stat-card.warn{ border-color:var(--warning); }
[data-theme="light"] .status-tip{ background:#fff; border-color:var(--line); box-shadow:0 8px 24px rgba(0,0,0,.15); }
[data-theme="light"] .app-toast{ box-shadow:0 6px 20px rgba(0,0,0,.15); }
[data-theme="light"] .device-focus-bar, [data-theme="light"] .device-selection-bar{ background:var(--panel-2); }
[data-theme="light"] .device-row.in-selection{ background:rgba(0,120,215,.1); }
[data-theme="light"] .map-tool-btn, [data-theme="light"] .map-legend-toggle,
[data-theme="light"] .map-legend-body{ background:#fff; border-color:var(--line); color:var(--fg-dim); box-shadow:0 2px 10px rgba(0,0,0,.15); }
[data-theme="light"] .map-legend-body{ color:var(--fg); }
[data-theme="light"] .map-tool-btn:hover, [data-theme="light"] .map-legend-toggle:hover{ color:var(--fg); }
[data-theme="light"] .map-tool-btn.active{ background:var(--fg); color:#fff; border-color:var(--fg); }
[data-theme="light"] .map-legend-title{ color:var(--fg-faint); }

/* Map popups — Google's InfoWindow and the OpenStreetMap one. */
[data-theme="light"] .gm-style-iw, [data-theme="light"] .gm-style-iw-d, [data-theme="light"] .gm-style-iw-c,
[data-theme="light"] .gm-style-iw-tc::after{ background:#fff !important; }
[data-theme="light"] .gm-style-iw-c{ border-color:var(--line) !important; }
[data-theme="light"] .gm-style-iw-d{ color:var(--fg); }
[data-theme="light"] .gm-style-iw-chr button.gm-ui-hover-effect span{ background-color:var(--fg) !important; }
[data-theme="light"] .gm-osm-popup .leaflet-popup-content-wrapper,
[data-theme="light"] .gm-osm-popup .leaflet-popup-tip{ background:#fff; color:var(--fg); border-color:var(--line); }
[data-theme="light"] .gm-osm-popup a.leaflet-popup-close-button{ color:var(--fg-faint); }
[data-theme="light"] .gm-osm-popup a.leaflet-popup-close-button:hover{ color:var(--fg); }
[data-theme="light"] .map-popup-wearer{ border-color:var(--line); }
[data-theme="light"] .map-popup-who, [data-theme="light"] .map-popup-point{ color:var(--fg-dim); }
[data-theme="light"] .map-popup-who strong, [data-theme="light"] .map-popup-point strong{ color:var(--fg); }
[data-theme="light"] .map-popup-face{ border-color:var(--line); background:var(--panel-2); }
[data-theme="light"] .map-popup-face.none{ color:#6b7280; }
[data-theme="light"] .map-popup-muted{ color:var(--fg-faint); }
[data-theme="light"] .map-popup-unlock{ border-color:var(--line); color:var(--fg-dim); }

/* Map controls drawn by the scripts (Map / Satellite, OpenStreetMap / Google). */
[data-theme="light"] .gm-osm-maptype, [data-theme="light"] .map-provider-switch{ background:#fff; border-color:var(--line) !important; box-shadow:0 2px 10px rgba(0,0,0,.15) !important; }
[data-theme="light"] .gm-osm-maptype button, [data-theme="light"] .map-provider-switch button{ color:var(--fg-dim); border-color:var(--line); }
[data-theme="light"] .gm-osm-maptype button:hover, [data-theme="light"] .map-provider-switch button:hover{ color:var(--fg); }
[data-theme="light"] .gm-osm-maptype button[aria-pressed="true"],
[data-theme="light"] .map-provider-switch button[aria-pressed="true"]{ background:var(--fg); color:#fff; }
[data-theme="light"] .map-provider-switch span{ color:var(--fg-faint); }

/* ---- Other pages ---- */
[data-theme="light"] .people-list label:hover{ background:var(--panel-2); }
[data-theme="light"] .people-suggest{ background:#fff; }
[data-theme="light"] .status-badge.on, [data-theme="light"] .role-badge.super{ color:#fff; }
[data-theme="light"] .log-table{ --bs-table-bg:#fff; --bs-table-hover-bg:var(--panel-2); background:#fff; }
[data-theme="light"] .log-table thead th{ background:var(--panel-2); color:var(--fg-dim); }
[data-theme="light"] .log-table td{ background:#fff; color:var(--fg); border-color:var(--line-soft); }
[data-theme="light"] .log-table tbody tr:hover td{ background:var(--panel-2); }
[data-theme="light"] .action-badge.auth{ color:#0b5cad; border-color:#7db4e6; }
[data-theme="light"] .action-badge.device{ color:#17692c; border-color:#7cc58f; }
[data-theme="light"] .action-badge.geofence{ color:#8a5a00; border-color:#d9b46a; }
[data-theme="light"] .action-badge.geofence_breach, [data-theme="light"] .action-badge.device_offline{ color:#b32020; border-color:#e59a9a; }
[data-theme="light"] .action-badge.user, [data-theme="light"] .action-badge.admin_branch_access{ color:#7a2fb0; border-color:#c79ae6; }
[data-theme="light"] .action-badge.branch, [data-theme="light"] .action-badge.prisoner{ color:#0a6a8a; border-color:#82c3d9; }
[data-theme="light"] .action-badge.settings{ color:#3a3f47; border-color:#aeb4bd; }

/* ---- Shared dialogs (ui-dialog.js, reauth.js, photo-cropper.js, evidence) ---- */
[data-theme="light"] .uid-overlay, [data-theme="light"] .reauth-overlay:not(.gate), [data-theme="light"] .pcrop-overlay{ background:rgba(17,20,24,.45); }
[data-theme="light"] .reauth-overlay.gate{ background:var(--bg); }
[data-theme="light"] .uid-box, [data-theme="light"] .reauth-box, [data-theme="light"] .pcrop-box{ background:#fff; color:var(--fg); border-color:var(--line); box-shadow:0 12px 40px rgba(0,0,0,.2); }
[data-theme="light"] .uid-head, [data-theme="light"] .uid-foot, [data-theme="light"] .reauth-head, [data-theme="light"] .reauth-foot,
[data-theme="light"] .pcrop-head, [data-theme="light"] .pcrop-foot{ border-color:var(--line); }
[data-theme="light"] .uid-body, [data-theme="light"] .reauth-body{ color:var(--fg-dim); }
[data-theme="light"] .reauth-body input{ background:#fff; color:var(--fg); border-color:var(--line); }
[data-theme="light"] .reauth-body input:focus{ border-color:var(--fg); }
[data-theme="light"] .uid-btn, [data-theme="light"] .reauth-btn, [data-theme="light"] .pcrop-btn{ border-color:var(--line); color:var(--fg-dim); }
[data-theme="light"] .uid-btn:hover, [data-theme="light"] .reauth-btn:hover, [data-theme="light"] .pcrop-btn:hover{ border-color:var(--fg); color:var(--fg); }
[data-theme="light"] .uid-btn.uid-primary, [data-theme="light"] .reauth-btn.primary, [data-theme="light"] .pcrop-btn.primary{ border-color:var(--fg); color:var(--fg); }
[data-theme="light"] .uid-btn.uid-primary:hover, [data-theme="light"] .reauth-btn.primary:hover, [data-theme="light"] .pcrop-btn.primary:hover{ background:var(--fg); color:#fff; }
[data-theme="light"] .uid-toast{ background:#fff; color:var(--fg); border-color:var(--line); box-shadow:0 8px 24px rgba(0,0,0,.15); }
[data-theme="light"] .pcrop-hint{ color:var(--fg-faint); }

/* ---- The theme switch itself (theme.js) ---- */
.theme-toggle{ line-height:1; }
.theme-toggle-floating{ position:fixed; top:calc(12px + env(safe-area-inset-top, 0px)); right:12px; z-index:1500; }

/* Alerts list: the "Reviewed" chip green, a shade deeper so it reads on white. */
[data-theme="light"] .alert-chip.done{ color:#15803d; border-color:#15803d; }

/* Custom icons (assets/img/icons/*.svg), used like Bootstrap Icons:
   <i class="gi gi-officer"></i> = staff, <i class="gi gi-handcuffs"></i> =
   prisoner. Drawn in currentColor and sized by font-size. */
.gi{ display:inline-block; width:1em; height:1em; vertical-align:-.125em; background-color:currentColor;
  -webkit-mask:var(--gi) center/contain no-repeat; mask:var(--gi) center/contain no-repeat; }
.gi-officer{ --gi:url(/assets/img/icons/officer.svg); }
.gi-handcuffs{ --gi:url(/assets/img/icons/handcuffs.svg); }
