/* ═══════════════════════════════════════════════════════════
   HDC Land Registry — styles.css (v3)
   Left icon dock + flyouts + right side panel + landing page.
═══════════════════════════════════════════════════════════ */

:root {
  --bg:            #F6F4EC;
  --surface:       #FFFFFF;
  --surface-alt:   #EFEEE3;
  --line:          #E2E1D3;

  --ink:           #1E2B24;
  --ink-muted:     #6B7568;

  --primary:       #2F5D45;
  --primary-dark:  #22432F;
  --primary-tint:  #DCEAE0;

  --teal:          #4C7C8B;
  --lagoon:        #AFDDED;

  --verified:      #2FA85E;
  --verified-bg:   rgba(47,168,94,0.16);
  --unverified:    #D6503A;
  --unverified-bg: rgba(214,80,58,0.16);
  --neutral:       #8B93A1;
  --neutral-bg:    rgba(139,147,161,0.10);

  --cad-plots:      #E67E22;
  --cad-agreement:  #2E7D50;

  --radius:        16px;
  --radius-sm:     10px;
  --shadow-soft:   0 10px 30px rgba(34,67,47,0.14);
  --shadow-tight:  0 2px 8px rgba(34,67,47,0.08);

  --dock-w:        64px;
  --panel-w:       380px;
}

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

html, body {
  width: 100%; height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
[hidden], .hidden { display: none !important; }

/* The stray blue box after clicking a plot is the browser's default
   focus ring landing on some element (likely the map's focusable
   view surface). Using *:focus / *:focus-visible instead of guessing
   specific selectors guarantees it's caught regardless of which
   element actually receives focus. */
*:focus,
*:focus-visible {
  outline: none !important;
}

/* ── BOOT SPINNER (brief, sign-in check only) ─────────────── */
#boot-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.boot-spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ACCESS DENIED ────────────────────────────────────────── */
#access-denied {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-dark);
}
.access-denied-box {
  text-align: center; color: #fff; max-width: 380px; padding: 24px;
}
.access-denied-box svg { color: var(--unverified); margin-bottom: 12px; }
.access-denied-box h2 { font-size: 20px; margin-bottom: 10px; }
.access-denied-box p { font-size: 13px; color: rgba(255,255,255,0.8); line-height: 1.5; margin-bottom: 20px; }
#access-denied-signout {
  padding: 10px 22px; border-radius: 999px;
  background: #fff; color: var(--primary-dark); font-weight: 700; font-size: 13px;
}
#access-denied-signout:hover { background: rgba(255,255,255,0.9); }

/* ── LANDING PAGE ─────────────────────────────────────────── */
#landing {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: #FAF6EE;
}
.landing-inner {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  max-width: 480px; width: 100%;
}
.landing-logo {
  width: 40px; height: 40px;
  object-fit: contain;
  margin-bottom: 26px;
}
.landing-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #2F8A4E;
  margin-bottom: 14px;
}
.landing-sub {
  font-size: 13.5px;
  color: #B3AEA3;
  margin-bottom: 30px;
}
#login-btn {
  background: #E9E5DC;
  color: #1E2B24;
  padding: 13px 24px;
  border: 2px solid #7FA08E;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
#login-btn:hover { background: #E2DDD2; border-color: #5E8670; }

/* ── APP SHELL ────────────────────────────────────────────── */
#app { height: 100vh; width: 100vw; }
#map-wrap { position: relative; height: 100%; width: 100%; overflow: hidden; }
#viewDiv { position: absolute; inset: 0; left: var(--dock-w); }


.esri-ui {
  display: none !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
}
.esri-view-surface--inset-outline:focus {
  box-shadow: none !important;
  outline: none !important;
}
.esri-view-surface--inset-outline:focus::after {
  content: none !important;
  box-shadow: none !important;
  outline: none !important;
}

/* ── FLOATING BRAND CHIP ──────────────────────────────────── */
.brand-chip {
  position: absolute;
  top: 16px; left: calc(var(--dock-w) + 16px);
  z-index: 55;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px 8px 10px;
  box-shadow: var(--shadow-tight);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-dark);
}
/* USER CHIP*/
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  box-shadow: var(--shadow-tight);
  font-size: 12px;
}

/* ── FLOATING USER CHIP ───────────────────────────────────── */
#parcel-count { color: var(--ink-muted); white-space: nowrap; }
#parcel-count strong { color: var(--primary); font-weight: 700; }
.user-chip-divider { width: 1px; height: 16px; background: var(--line); }
#user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary-dark);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
#user-name { color: var(--ink); font-weight: 500; white-space: nowrap; }
#sign-out-btn {
  width: 26px; height: 26px; border-radius: 50%;
  color: var(--ink-muted);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, background 0.15s;
}
#sign-out-btn:hover { color: var(--unverified); background: var(--unverified-bg); }

/* ── DRONE IMAGERY TOGGLE (pill) ───────────────────────────── */
.view-toggle {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--shadow-tight);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  transition: background 0.15s, border-color 0.15s;
}
.view-toggle:hover { background: var(--primary-tint); border-color: var(--primary); }
.view-toggle.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.view-toggle.active:hover { background: var(--primary-dark); }

/* ── FLOATING TOP-RIGHT STACK (user chip + imagery toggles) ──── */
.topright-stack {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px; /* equal spacing between all three, however tall each one is */
}

/* ── LEFT ICON DOCK ───────────────────────────────────────── */
.dock {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--dock-w);
  z-index: 60;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 0;
}
.dock-group { display: flex; flex-direction: column; gap: 6px; }
.dock-spacer { flex: 1; }

.dock-btn {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.dock-btn:hover { background: var(--primary-tint); color: var(--primary); }
.dock-btn.active { background: var(--primary); color: #fff; }

/* ── FLYOUT (attached to dock) ────────────────────────────── */
.flyout {
  position: absolute;
  top: 0; left: var(--dock-w); bottom: 0;
  width: 300px;
  z-index: 58;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.flyout:not(.hidden) { transform: translateX(0); }

.flyout-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.icon-btn {
  color: var(--ink-muted); padding: 4px;
  display: flex; align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--primary-dark); background: var(--primary-tint); }

.flyout-body { flex: 1; overflow-y: auto; padding: 14px 16px; }

#search-container .esri-search { width: 100%; }
#search-container .esri-search__container { background: var(--surface-alt); border-radius: var(--radius-sm); }
#legend-container .esri-legend,
#layer-list-container .esri-layer-list,
#measure-container .esri-measurement,
#sketch-container .esri-sketch { background: transparent; font-family: 'Inter', sans-serif; }

/* Opacity slider inside each Layer List item — retint from Esri blue */
#layer-list-container .esri-slider__track-position,
#layer-list-container .esri-slider__segment--filled { background-color: var(--primary) !important; }
#layer-list-container .esri-slider__thumb { border-color: var(--primary) !important; }
#layer-list-container .esri-slider__thumb:focus,
#layer-list-container .esri-slider__thumb:hover { box-shadow: 0 0 0 3px var(--primary-tint) !important; }
/* Plain "Opacity" caption in place of the 0/1 range labels we hid */
#layer-list-container .esri-slider::before {
  content: "Opacity";
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 10.5px;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

/* Visibility toggle icon (eye/no-eye) — retint to match theme */
#layer-list-container .esri-layer-list__item-toggle .esri-icon,
#layer-list-container calcite-icon { color: var(--primary) !important; }

/* Drag handle in the reorderable Layer List — retint to match theme */
#layer-list-container calcite-handle {
  --calcite-handle-icon-color: var(--teal);
  --calcite-color-icon-color: var(--teal);
}

/* ── FILTER PANE ──────────────────────────────────────────── */
.filter-section { margin-bottom: 18px; }
.filter-section-title {
  font-size: 10.5px; font-weight: 600; color: var(--primary);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.filter-section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.filter-field { margin-bottom: 10px; }
.filter-field:last-child { margin-bottom: 0; }
.filter-field-label {
  display: block;
  font-size: 11px; color: var(--ink-muted);
  margin-bottom: 4px;
}

.filter-input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  transition: border-color 0.15s, background 0.15s;
}
.filter-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}
.filter-input::placeholder { color: var(--ink-muted); opacity: 0.7; }

.filter-range { display: flex; align-items: center; gap: 6px; }
.filter-input-sm { width: 0; flex: 1; }
.filter-range-sep { color: var(--ink-muted); font-size: 11px; flex-shrink: 0; }

.filter-chip-row { display: flex; flex-direction: column; gap: 6px; }
.filter-chip {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  text-align: left;
  font-size: 12px;
  color: var(--ink-muted);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-chip::before {
  content: '';
  width: 13px; height: 13px;
  border-radius: 4px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.filter-chip.active { color: var(--ink); border-color: var(--primary); background: var(--primary-tint); }
.filter-chip.active::before { background: var(--primary); border-color: var(--primary); }

.filter-reset {
  width: 100%;
  font-size: 11.5px; font-weight: 600; color: var(--ink-muted);
  padding: 10px 0 2px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.filter-reset:hover { color: var(--primary); }

/* Searchable multi-select dropdown (Land Use / Development / Status / Market) */
.filter-dd { position: relative; }
.filter-dd-trigger {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  transition: border-color 0.15s;
}
.filter-dd-trigger:hover { border-color: var(--primary); }
.filter-dd.open .filter-dd-trigger { border-color: var(--primary); background: var(--surface); }
.filter-dd-summary { color: var(--ink-muted); }
.filter-dd.has-selection .filter-dd-summary { color: var(--primary); font-weight: 600; }
.filter-dd-chevron { color: var(--ink-muted); flex-shrink: 0; transition: transform 0.15s; }
.filter-dd.open .filter-dd-chevron { transform: rotate(180deg); }

.filter-dd-panel {
  position: relative;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-tight);
  overflow: hidden;
}
.filter-dd-search {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-muted);
}
.filter-dd-search-input {
  flex: 1;
  border: none; background: none; outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--ink);
}
.filter-dd-search-input::placeholder { color: var(--ink-muted); opacity: 0.7; }

.filter-dd-list { max-height: 190px; overflow-y: auto; padding: 4px; }
.filter-dd-loading, .filter-dd-empty {
  padding: 10px 8px; font-size: 11.5px; color: var(--ink-muted); font-style: italic;
}
.filter-dd-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px; color: var(--ink);
  cursor: pointer;
}
.filter-dd-item:hover { background: var(--surface-alt); }
.filter-dd-item input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.filter-dd-item.dd-hidden { display: none; }

/* ── TOAST ────────────────────────────────────────────────── */
#toast {
  position: absolute;
  bottom: 20px; left: calc(50% + var(--dock-w) / 2);
  transform: translateX(-50%) translateY(8px);
  background: var(--primary-dark);
  color: #F6F4EC;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--unverified); }

/* ── SIDE PANEL — parcel details ──────────────────────────── */
#side-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: var(--panel-w);
  z-index: 65;
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: -8px 0 32px rgba(34,67,47,0.16);
}
#side-panel.open { transform: translateX(0); }

#panel-header {
  position: relative;
  padding: 16px 44px 12px 16px;
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 70%, var(--teal) 140%);
  color: #fff;
}
.panel-close { position: absolute; top: 10px; right: 10px; color: rgba(255,255,255,0.75); }
.panel-close:hover { color: #fff; background: rgba(255,255,255,0.14); }

.panel-lot-no {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 20px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1.15;
}
.panel-parcel-no { font-size: 12px; color: rgba(255,255,255,0.78); margin-top: 2px; line-height: 1.2; }

.verify-badge {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  margin-top: 8px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.16); color: #fff;
}
.verify-badge.verified   { background: var(--verified);   color: #fff; }
.verify-badge.unverified { background: var(--unverified); color: #fff; }

/* Drawing list — shows ~3 cards, scrolls internally for the rest */
.drawing-scroll {
  max-height: 168px;
  overflow-y: auto;
  padding-right: 4px; /* keeps cards clear of the scrollbar */
}

/* Fixed footer — never scrolls away with the rest of the panel */
#panel-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ── GENERATE LAND RECORD BUTTON ─────────────────────────── */
.generate-record-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.generate-record-btn:hover { background: var(--primary-dark); }

/* ── PANEL PAGER (multiple overlapping lots at one click point) ── */
.panel-pager {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}
.pager-btn {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.16);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.pager-btn:hover { background: rgba(255,255,255,0.3); }
.pager-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.pager-label {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}

#panel-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
#panel-body::-webkit-scrollbar { width: 4px; }
#panel-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

.section { padding: 15px 18px; border-bottom: 1px solid var(--surface-alt); }
.section:last-child { border-bottom: none; }

.section-title {
  font-size: 10.5px; font-weight: 600; color: var(--primary);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.field {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--surface-alt);
}
.field:last-child { border-bottom: none; }
.fk { font-size: 11.5px; color: var(--ink-muted); white-space: nowrap; flex-shrink: 0; }
.fv { font-size: 12.5px; color: var(--ink); font-weight: 500; text-align: right; word-break: break-word; }

/* ── DRAWINGS — vertical list, forced downloads ───────────── */
.drawing-placeholder, .drawing-empty {
  font-size: 12px; color: var(--ink-muted); font-style: italic; padding: 4px 0;
}
.drawing-loading {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--ink-muted); padding: 4px 0;
}
.drawing-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.pdf-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 11px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 7px;
  transition: border-color 0.15s, background 0.15s;
}
.pdf-card:last-child { margin-bottom: 0; }
.pdf-card:hover { border-color: var(--primary); background: var(--primary-tint); }

.pdf-card-icon {
  width: 30px; height: 30px;
  background: var(--primary-tint);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.pdf-card-name {
  flex: 1; font-size: 11.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 720px) {
  #side-panel { width: 100%; }
  .brand-chip span { display: none; }
  #user-name { display: none; }
  .view-toggle span { display: none; }
}

/* ── GENERATE LAND RECORD BUTTON ─────────────────────────── */
.generate-record-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.generate-record-btn:hover { background: var(--primary-dark); }
