/* CyberTech NZ — shared styles for the public map and admin backend.
 * Light theme; categorical series colors are defined in data/taxonomy.json
 * (validated palette) and applied inline as swatch/marker fills.
 */

:root {
  --sea: #e9eff3;
  --land: #f6f4ec;
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-dark: #1c5cab;
  --danger: #d03b3b;
  --ok-bg: #e7f4e7;
  --ok-ink: #006300;
  --err-bg: #fbe9e9;
  --radius: 8px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--page);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.swatch {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(11, 11, 11, 0.15); vertical-align: -1px; margin-right: 6px;
  flex: none;
}

/* ---------- Map page ---------- */

.page-map { overflow: hidden; }
.map-app { display: flex; height: 100vh; height: 100dvh; }

.view-area { flex: 1; min-width: 0; position: relative; }
#map {
  height: 100%;
  background: var(--sea);
}
.map-error { padding: 2rem; color: var(--ink-2); }

#list-view { height: 100%; overflow: auto; padding: 18px 22px; background: var(--page); }
.list-table td { vertical-align: top; }
.list-table td:last-child { max-width: 420px; }
.list-table .entry-icon { margin-right: 8px; }

.view-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin: 2px 0 8px; }
.view-btn {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--ink-2); border: 0; padding: 5px 16px;
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn.active { background: var(--accent); color: #fff; }

.entry-icon {
  width: 18px; height: 18px; object-fit: contain; border-radius: 4px;
  vertical-align: -4px; margin-right: 6px;
}

.panel {
  width: 330px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 500;
  box-shadow: 2px 0 8px rgba(11, 11, 11, 0.05);
}
.panel-header { padding: 18px 18px 10px; border-bottom: 1px solid var(--hairline); }
.panel-header h1 { margin: 0 0 4px; font-size: 21px; }
.panel-header p { margin: 0 0 8px; font-size: 13px; }
#panel-toggle { display: none; }
.panel-body { display: flex; flex-direction: column; }
.panel-body.collapsed { display: none; }

.panel-block { padding: 14px 18px; border-bottom: 1px solid var(--hairline); }
.panel-block h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 8px; color: var(--ink-2); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; }
.mini-actions { font-size: 12px; color: var(--muted); }
.linklike {
  background: none; border: 0; padding: 0; font: inherit; font-size: 12px;
  color: var(--accent-dark); cursor: pointer; text-decoration: underline;
}

.toggle-list { list-style: none; margin: 0; padding: 0; }
.toggle {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 2px; cursor: pointer; border-radius: 4px;
}
.toggle:hover { background: var(--page); }
.toggle input { accent-color: var(--accent); margin: 0; }
.toggle-label { flex: 1; }
.count {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.entry-list { display: flex; flex-direction: column; }
.list-cat { font-size: 12.5px; margin: 10px 0 2px; display: flex; align-items: center; }
.entry-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: 0; font: inherit; text-align: left;
  padding: 5px 6px; margin-left: 12px; border-radius: 4px; cursor: pointer;
}
.entry-row:hover { background: var(--page); }
.entry-name { color: var(--ink); }
.panel-footer { padding: 12px 18px 18px; }
.panel-footer p { margin: 4px 0; }

/* Region + zone labels on the map */
.region-label {
  font: 600 12px/1.2 var(--sans);
  color: var(--ink-2);
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(252, 252, 251, 0.9);
  transform: translate(-50%, -50%);
  width: auto !important; height: auto !important;
}
.region-label small { display: block; font-weight: 400; color: var(--muted); }
.zone-label { color: #5b7285; }

/* Leaflet popup content */
.popup h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; }
.popup p { margin: 5px 0; font-size: 13px; }
.popup-meta { color: var(--ink-2); }
.popup-fact { margin: 3px 0; }
.popup-icon {
  width: 22px; height: 22px; object-fit: contain; border-radius: 4px;
  margin-right: 8px; flex: none;
}
.leaflet-container { font-family: var(--sans); }

/* ---------- Auth / 404 card ---------- */

.page-auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 30px; width: 340px; box-shadow: 0 4px 16px rgba(11, 11, 11, 0.06);
}
.auth-card h1 { margin: 0 0 2px; font-size: 22px; }
.auth-card form { margin-top: 14px; }

/* ---------- Admin ---------- */

.topnav {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border-bottom: 1px solid var(--hairline);
  padding: 10px 22px;
}
.topnav a { text-decoration: none; color: var(--ink-2); }
.topnav a.active { color: var(--ink); font-weight: 600; }
.topnav a:hover { color: var(--ink); }
.topnav .brand { font-weight: 700; color: var(--ink); margin-right: 8px; }
.topnav form { margin-left: auto; }

.admin-wrap { max-width: 1000px; margin: 24px auto 60px; padding: 0 22px; }
.admin-narrow { max-width: 560px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-head h1 { font-size: 22px; }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); }
.data-table th, .data-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: "\2195"; opacity: 0.35; margin-left: 5px; }
th.sortable[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: "\2193"; opacity: 1; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .actions { white-space: nowrap; text-align: right; }
.clamp { max-width: 380px; }

label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13.5px; }
input[type="text"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; padding: 8px 10px; font: inherit;
  border: 1px solid #c8c7c0; border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
fieldset { border: 1px solid var(--hairline); border-radius: 6px; margin: 14px 0 0; padding: 10px 12px 12px; }
legend { font-weight: 600; font-size: 13.5px; padding: 0 4px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.check { display: flex; align-items: center; gap: 7px; font-weight: 400; margin: 3px 0; cursor: pointer; }
.check input { accent-color: var(--accent); margin: 0; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none;
  padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: none; color: var(--ink-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--ink); }
.btn-small { padding: 3px 9px; font-size: 12.5px; font-weight: 500; }
.btn-danger { background: none; color: var(--danger); border-color: rgba(208, 59, 59, 0.4); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; margin-top: 16px; }
.inline-form { display: inline; }

.alert { padding: 10px 14px; border-radius: 6px; margin: 14px 0; font-size: 13.5px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert-error { background: var(--err-bg); color: #8f2424; }

.panel-block h2 { margin-top: 0; }
section.panel-block { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 16px 18px; margin-top: 22px; }
section.panel-block form { max-width: 340px; }
section.panel-block .btn { margin-top: 12px; }

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .map-app { flex-direction: column; }
  .panel { width: 100%; max-height: 55vh; border-right: 0; border-bottom: 1px solid var(--hairline); order: 0; }
  .view-area { min-height: 45vh; }
  #panel-toggle { display: inline-block; }
  .admin-head { flex-wrap: wrap; }
  .data-table { display: block; overflow-x: auto; }
  .topnav { flex-wrap: wrap; gap: 10px 14px; }
}
