/* CSPC WhereITis — public/css/theme-fixes.css
   Loaded last (see views/partials/head.ejs). Three jobs:
   1. Light/dark contrast fixes for things that were hard to see.
   2. Visible borders on form fields (the old hairline border was about 1.3:1; WCAG asks for 3:1).
   3. Styles for the redesigned Admin > Manage locations page.
   Every colour is a token, so light, dark and the system theme all follow. */

/* ---------- 1. Tokens ---------- */
:root { --field-border: #838b97; }                                   /* 3.4:1 on white cards */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --field-border: #667385; --navy: var(--brand); }
}
:root[data-theme="dark"] { --field-border: #667385; --navy: var(--brand); }   /* 3.5:1 on dark cards; --navy was dark blue on a dark card (1.9:1) */

/* ---------- 2. Form fields you can actually see ---------- */
.input, .select, .textarea { border-color: var(--field-border); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.check input[type="checkbox"], .check input[type="radio"] { outline-offset: 2px; }

/* ---------- 3. Contrast fixes found by the audit ---------- */
/* White text on the dark-mode brand blue was 2.6:1. --on-brand flips to near-black in dark mode (7.2:1). */
.doc-body ol > li::before, .my-badge, .my-hero__avatar { color: var(--on-brand); }
/* Sign-in error was dark red on a dark card (2.6:1). */
.auth-google__error { color: var(--danger); }
/* Map popups: always themed, so links and text are readable in both modes (brand link on white was 2.6:1 in dark). */
.leaflet-container .leaflet-popup-content-wrapper,
.leaflet-container .leaflet-popup-tip { background: var(--card); color: var(--ink); }
.leaflet-container .leaflet-popup-content a { color: var(--brand); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.nxmap-pop .nxmap-pop__quiet { color: var(--muted); }

/* ---------- 4. Admin settings ---------- */
body.staff-queue-page,
:root[data-theme="dark"] body.staff-queue-page { background: var(--bg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.staff-queue-page { background: var(--bg); }
}
body.staff-queue-page .glass-ambient { display: none; }
.adm-pagehead { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-start; justify-content: space-between; margin-bottom: var(--s-3); }
.adm-pagehead h1 { margin-bottom: .25rem; }
.adm-pagehead p { margin: 0; max-width: 62ch; }
.adm-eyebrow { margin: 0 0 .25rem !important; color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.adm-category-total { display: flex; align-items: baseline; gap: .45rem; padding: .55rem .85rem; color: var(--muted); background: var(--card); border: 1px solid var(--border); border-radius: 999px; font-size: .86rem; }
.adm-category-total strong { color: var(--ink); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.adm-section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 var(--s-2); }
.adm-section-head h2 { margin: 0; font-size: 1.15rem; }
.adm-section-head p { margin: .15rem 0 0; font-size: .88rem; }

.adm-callout {
  display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; margin: 0 0 var(--s-3); padding: .8rem 1rem;
  color: var(--ink); background: var(--brand-050); border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--border)); border-radius: 10px;
}

/* Add form: a card at the top of the page, so nobody has to scroll to reach it. */
.adm-add { margin: 0 0 var(--s-3); background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.adm-add > summary { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; list-style: none; cursor: pointer; font-weight: 700; color: var(--brand); }
.adm-add > summary::-webkit-details-marker { display: none; }
.adm-add > summary:hover { background: var(--brand-050); border-radius: 10px; }
.adm-add__plus { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 6px; background: var(--brand); color: var(--on-brand); font-weight: 700; line-height: 1; transition: transform .2s; }
.adm-add[open] .adm-add__plus { transform: rotate(45deg); }
.adm-add[open] > summary { border-bottom: 1px solid var(--border); border-radius: 10px 10px 0 0; }
.adm-add__form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto auto; gap: .9rem 1rem; align-items: end; padding: 1rem; }
.adm-add__form .field { margin: 0; }
.adm-add__public { align-self: center; padding-bottom: .55rem; }
@media (max-width: 860px) {
  .adm-add__form { grid-template-columns: minmax(0, 1fr); }
  .adm-add__public { padding-bottom: 0; }
}
.adm-category-add { margin-top: 0; }
.adm-category-form { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) 8rem auto; }
.adm-category-actions { display: flex; align-items: end; padding-bottom: .05rem; }
.adm-category-list { margin-top: var(--s-4); }
.adm-category-wrap { margin-bottom: var(--s-4); }
.adm-category-table { min-width: 900px; }
.adm-category-table th,
.adm-category-table td { padding: .85rem 1rem; }
.adm-category-table thead th { border-bottom-color: var(--border); }
.adm-category-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--brand-050) 35%, var(--card)); }
.adm-category-table tbody tr:hover td { background: var(--brand-050); }
.adm-category-name { font-weight: 700; }
.adm-category-row-actions { white-space: nowrap; }
.adm-category-row-actions form { display: inline-flex; margin-left: .3rem; }
.adm-category-row-actions .adm-small { margin-left: .3rem; }
.adm-form-error { grid-column: 1 / -1; margin: 0; }
.adm-lookup-edit-card { max-width: 860px; padding: 1.25rem; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.adm-edit-note { margin: 0 0 1.25rem; padding: .8rem 1rem; color: var(--muted); background: var(--brand-050); border-left: 3px solid var(--brand); border-radius: 6px; font-size: .9rem; }
.adm-lookup-edit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.adm-lookup-edit-form .field { margin: 0; }
.adm-lookup-edit-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .25rem; }
.adm-lookup-edit-actions .btn { margin: 0; }
.adm-code { display: inline-block; padding: .2rem .45rem; color: var(--ink); background: var(--brand-050); border: 1px solid var(--border); border-radius: 5px; font-size: .83em; overflow-wrap: anywhere; }
.adm-order { display: inline-grid; min-width: 2rem; min-height: 2rem; place-items: center; color: var(--muted); background: var(--card); border: 1px solid var(--border); border-radius: 7px; font-size: .84rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.adm-category-empty { padding: 2rem !important; text-align: center !important; }
@media (max-width: 900px) {
  .adm-category-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .adm-category-actions { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .adm-category-form { grid-template-columns: minmax(0, 1fr); }
  .adm-category-actions { grid-column: auto; }
}
@media (max-width: 600px) {
  .adm-lookup-edit-card { padding: 1rem; }
  .adm-lookup-edit-form { grid-template-columns: minmax(0, 1fr); }
  .adm-lookup-edit-actions { grid-column: auto; }
}

/* Search + filter chips */
.adm-loc-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: 0 0 var(--s-3); }
.adm-loc-tools[hidden] { display: none; }
.adm-loc-tools .input { width: min(320px, 100%); }
.adm-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.adm-chips button {
  padding: .4rem .8rem; font: inherit; font-size: .85rem; font-weight: 600; color: var(--ink); cursor: pointer;
  background: var(--card); border: 1px solid var(--field-border); border-radius: 999px;
}
.adm-chips button span { margin-left: .3rem; font-weight: 700; color: var(--muted); }
.adm-chips button:hover:not([aria-pressed="true"]) { background: var(--brand-050); }
.adm-chips button[aria-pressed="true"] { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }
.adm-chips button[aria-pressed="true"] span { color: inherit; }
.adm-loc-count { margin: 0; font-size: .85rem; }

/* Keep the long list and its header together without squeezing the row controls. */
.adm-loc-wrap { max-height: min(68vh, 640px); overflow: auto; }
.adm-loc-table { min-width: 1100px; table-layout: fixed; }
.adm-loc-col-name { width: 22%; }
.adm-loc-col-zone { width: 15%; }
.adm-loc-col-visibility { width: 10%; }
.adm-loc-col-map { width: 12%; }
.adm-loc-col-reports { width: 7%; }
.adm-loc-col-actions { width: 34%; }
.adm-loc-table thead th { position: sticky; top: 0; z-index: 1; background: var(--brand-050); box-shadow: 0 1px 0 var(--border); }
.adm-loc-table tr[hidden] { display: none; }
.adm-loc-table td { vertical-align: middle; }
.adm-loc-name { font-weight: 500; }
.adm-loc-note { margin-top: .15rem; font-size: .78rem; color: var(--muted); }
.adm-loc-num { text-align: right !important; padding-right: 1.5rem !important; font-variant-numeric: tabular-nums; }
.adm-loc-th-actions { text-align: right !important; }
.adm-loc-table .adm-col-actions { white-space: nowrap; text-align: right !important; vertical-align: middle; }
/* three fixed slots: pin | visibility | delete, so buttons line up in every row */
.adm-loc-actions { display: grid; grid-template-columns: 7.5rem 9.5rem 5.5rem; justify-content: end; align-items: center; gap: .5rem; }
.adm-loc-actions > * { margin: 0; min-width: 0; }
.adm-loc-actions .adm-inline { display: block; }
.adm-loc-actions .btn { width: 100%; justify-content: center; text-align: center; white-space: nowrap; }
/* plain text states, no colored pill */
.adm-state { font-size: .9rem; font-weight: 400; color: inherit; background: none; padding: 0; border-radius: 0; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { .adm-add__plus { transition: none; } }
