/* ============================================================
   Map and compartment register — colour modes, the season
   tracker, the block panel, the Compartments page and the
   harvest / compartment / season forms.
   mp- is the map, rg- the register.
   ============================================================ */

/* Map colours. Every one points at a token, so a re-theme is still a token
   swap; map.js and register-ui.js resolve them for Leaflet. */
:root {
  --mp-status-not_started: #e8e8e2; /* bright enough over satellite imagery */
  --mp-status-in_progress: #c8e63c;
  --mp-status-done:        #3ddc97;
  --mp-status-attention:   #ff5a4f;

  --mp-species-gum:        var(--success);
  --mp-species-eucalyptus: var(--accent-ink);
  --mp-species-wattle:     var(--warning);
  --mp-species-pine:       var(--op-drone);
  --mp-species-open:       var(--warning-line);
  --mp-species-unknown:    var(--chart-muted);

  --mp-age-a0:   var(--accent-soft);
  --mp-age-a4:   var(--accent);
  --mp-age-a8:   var(--warning);
  --mp-age-a11:  var(--danger);
  --mp-age-none: var(--chart-muted);

  --mp-season-done: var(--success);
  --mp-season-next: var(--accent);
  --mp-season-todo: var(--warning);
  --mp-season-out:  var(--chart-muted);
}

/* ── toolbar: colour mode and season pick ───────────────────────── */

.mp-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-md);
  margin: calc(-1 * var(--space-md)) 0 var(--space-md);
}
.mp-toolbar-label { font-size: 12.5px; font-weight: 600; color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: 0.04em; }
.mp-season-pick { width: auto; min-width: 220px; max-width: 100%; }
.mp-legend { margin-top: var(--space-sm); }
.mp-legend .legend-key { white-space: nowrap; }
.mp-swatch { border-color: var(--line); display: inline-block; vertical-align: -1px; flex-shrink: 0; }
.mp-legend-count { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }
.mp-demo { margin: 0 0 var(--space-md); }

/* ── side panels ────────────────────────────────────────────────── */

.mp-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); margin-bottom: 4px; }
.mp-block-code { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.mp-sub-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm);
  margin: var(--space-lg) 0 var(--space-sm);
}
.mp-sub-head .panel-title { margin: 0; }
.mp-figs { grid-template-columns: 1fr 1fr; }
.mp-fig-wide { grid-column: 1 / -1; }
.mp-fig-value-sm { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.mp-fig-note { font-size: 12px; color: hsl(var(--muted-foreground)); font-weight: 500; margin-top: 2px; }
.mp-muted-empty { padding: var(--space-sm) 0; font-size: 13px; color: hsl(var(--muted-foreground)); }
.mp-link { color: var(--accent-ink); font-weight: 600; font-size: 13px; }
.mp-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.mp-delete-row { margin-top: var(--space-lg); padding-top: var(--space-md); border-top: 1px solid var(--line); }

.mp-harvest { padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.mp-harvest:first-child { border-top: 0; }
.mp-harvest-head { display: flex; justify-content: space-between; gap: var(--space-sm); font-weight: 600; }
.mp-harvest-figs { color: hsl(var(--muted-foreground)); margin-top: 2px; line-height: 1.5; }

/* Fallback work log, used only when the field log helper is not on the page. */
.mp-log-row { padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.mp-log-row:first-child { border-top: 0; }

/* ── season tracker ─────────────────────────────────────────────── */

.mp-season-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 2px; }
.mp-season-line { font-size: 13.5px; color: hsl(var(--muted-foreground)); margin: 6px 0 10px; line-height: 1.5; }
.mp-season-compare { font-size: 13px; color: var(--accent-ink); font-weight: 500; margin-top: 8px; }
.mp-progress {
  height: 12px; border-radius: var(--radius-full);
  background: var(--canvas); border: 1px solid var(--line);
  overflow: hidden;
}
.mp-progress > span {
  display: block; height: 100%;
  background: var(--mp-season-done);
  border-radius: var(--radius-full);
  transition: width var(--dur-fast) var(--ease);
}

.mp-blocks { display: flex; flex-direction: column; margin-top: var(--space-md); max-height: 420px; overflow-y: auto; }
.mp-block {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; min-height: 52px;
  border-top: 1px solid var(--line);
}
.mp-block:first-child { border-top: 0; }
.mp-seq {
  width: 26px; flex-shrink: 0; text-align: right;
  font-family: var(--font-mono); font-size: 12px; color: hsl(var(--muted-foreground));
}
.mp-block-body { flex: 1; min-width: 0; }
.mp-block-name { font-weight: 700; font-size: 14px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.mp-block-name:hover { color: var(--accent-ink); }
.mp-block-sub { font-size: 12.5px; color: hsl(var(--muted-foreground)); line-height: 1.4; }
.mp-block-sub.is-stopped { color: var(--danger-ink); }
.mp-block.is-done .mp-block-name { color: hsl(var(--muted-foreground)); }
.mp-block.is-next { background: var(--accent-tint); border-radius: var(--radius-sm); padding-left: 6px; padding-right: 6px; }

/* Tick button: the same square as a task tick, at a thumb's size. */
.mp-tick {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  position: relative; cursor: pointer; padding: 0;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.mp-tick:hover:not(:disabled) { border-color: var(--accent); }
.mp-tick:disabled { opacity: 0.5; cursor: default; }
.mp-tick.on { background: var(--mp-season-done); border-color: var(--mp-season-done); }
.mp-tick.on::after {
  content: ""; position: absolute; left: 16px; top: 9px;
  width: 9px; height: 18px;
  border: solid var(--surface); border-width: 0 3px 3px 0; transform: rotate(45deg);
}

/* Season job editor: block codes typed in order. */
.mp-order-preview { font-size: 12.5px; margin-top: 6px; color: hsl(var(--muted-foreground)); line-height: 1.5; }
.mp-order-preview .is-bad { color: var(--danger-ink); font-weight: 600; }

/* This season against last season, side by side. */
.mp-season-table-wrap { margin-top: var(--space-md); }
table.mp-season-table { min-width: 0; font-size: 13px; }
.mp-season-table th, .mp-season-table td { padding: 7px 10px; }
.mp-season-table td:first-child { color: hsl(var(--muted-foreground)); font-weight: 600; }
.mp-season-table tbody tr:hover { background: transparent; }
.mp-season-next { margin-top: var(--space-md); font-size: 13.5px; }
.mp-season-next .hint { margin-top: 4px; }

/* A harvest still felling, with an expected finish date (C8). */
.mp-harvest.is-running .mp-harvest-head span:first-child { color: var(--warning-ink); }

/* ── Compartments page ──────────────────────────────────────────── */

.rg-filters .input { min-width: 0; }
.rg-filters [hidden] { display: none !important; }
.rg-filters .input.grow { flex: 1 1 200px; min-width: 200px; }
.rg-filters .rg-age { width: 84px; min-width: 0; }
.rg-filters .rg-age-sep { font-size: 13px; color: hsl(var(--muted-foreground)); }
.rg-summary { font-size: 13.5px; color: hsl(var(--muted-foreground)); }
.rg-summary strong { color: var(--ink); }

table.rg-table { min-width: 1280px; font-size: 13.5px; }
.rg-table td { padding: 11px 12px; vertical-align: top; }
.rg-table th { padding: 0; }
.rg-sort {
  display: flex; align-items: center; gap: 4px; width: 100%;
  padding: 11px 12px; border: 0; background: transparent;
  font: inherit; font-weight: 600; color: inherit; cursor: pointer; text-align: left; white-space: nowrap;
}
.rg-sort:hover { color: var(--accent-ink); }
.rg-sort[aria-sort="ascending"]::after  { content: "\2191"; color: var(--accent-ink); }
.rg-sort[aria-sort="descending"]::after { content: "\2193"; color: var(--accent-ink); }
.rg-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rg-table .rg-sort.num { justify-content: flex-end; }
.rg-table tbody tr { cursor: pointer; }
.rg-mapped { color: var(--text-muted); font-size: 12px; display: block; }
.rg-plan { max-width: 240px; white-space: normal; line-height: 1.45; }
.rg-fsc { display: block; font-size: 12px; color: var(--warning-ink); margin-top: 2px; }
.rg-table tfoot td { font-weight: 700; background: var(--canvas); border-top: 1px solid var(--line); }
.rg-perf-subpar { color: var(--warning-ink); font-weight: 600; }
.rg-perf-very_bad { color: var(--danger-ink); font-weight: 600; }
.rg-perf-good { color: var(--success-ink); font-weight: 600; }
.rg-expected { color: var(--warning-ink); font-weight: 600; display: block; max-width: 180px; white-space: normal; line-height: 1.4; }

/* Multi-pick dropdowns for farms and species. */
.rg-multi { position: relative; }
.rg-multi > summary { list-style: none; cursor: pointer; user-select: none; }
.rg-multi > summary::-webkit-details-marker { display: none; }
.rg-multi-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-width: 150px; white-space: nowrap;
}
.rg-multi-btn::after { content: "\25BE"; font-size: 11px; color: hsl(var(--muted-foreground)); }
.rg-multi.is-on > .rg-multi-btn { border-color: var(--accent-strong); box-shadow: 0 0 0 1px var(--accent-line); }
.rg-multi-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  min-width: 240px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 6px 12px 10px;
}
.rg-multi-opt { min-height: 44px; border-bottom: 1px solid var(--line); }
.rg-multi-opt:last-of-type { border-bottom: 0; }
.rg-multi-actions { padding-top: 8px; }

/* Register | Compare, and what to compare by. */
.rg-view-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm) var(--space-md); }
.rg-group { align-items: center; }
.rg-group[hidden] { display: none; }
.rg-group-label { font-size: 13px; color: hsl(var(--muted-foreground)); margin-right: 2px; }
table.rg-compare { min-width: 900px; }
.rg-compare tbody tr { cursor: default; }
.rg-compare td:first-child { white-space: nowrap; }

/* ── forms ──────────────────────────────────────────────────────── */

.mp-block-info { font-size: 13px; color: hsl(var(--muted-foreground)); margin-top: var(--space-sm); line-height: 1.5; }
.mp-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-sm); }
.mp-preview .comp-fig-value { font-size: 18px; }

.mp-tick-rows { display: flex; flex-direction: column; gap: 8px; }
.mp-tick-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 60px; padding: 8px 12px 8px 8px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; text-align: left; font: inherit;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.mp-tick-row:hover { border-color: var(--accent-line); }
.mp-tick-row .mp-tick { pointer-events: none; }
.mp-tick-row.on { background: var(--success-tint); border-color: var(--success-line); }
.mp-tick-row.changed { box-shadow: 0 0 0 2px var(--accent-line); }
.mp-tick-code { font-weight: 700; font-size: 16px; }
.mp-tick-meta { font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.mp-tick-side { margin-left: auto; text-align: right; font-size: 12.5px; color: hsl(var(--muted-foreground)); white-space: nowrap; }

.mp-other-species { margin-top: var(--space-sm); }

@media (max-width: 560px) {
  .mp-toolbar { margin-top: calc(-1 * var(--space-sm)); }
  .mp-season-pick { min-width: 0; width: 100%; }
  .mp-figs { grid-template-columns: 1fr 1fr; }
  .mp-preview { grid-template-columns: 1fr 1fr; }
  .rg-filters .input, .rg-filters select.input { flex: 1 1 140px; }
  .rg-multi { flex: 1 1 140px; min-width: 0; }
  .rg-multi[open] { flex-basis: 100%; }
  .rg-multi-btn { min-width: 0; width: 100%; }
  /* On a phone an open picker takes the whole row and opens in place. */
  .rg-multi-panel { position: static; min-width: 0; width: 100%; margin-top: 6px; max-height: 260px; }
}
