/* Slopbin Map/GIS Analyzer — styles.css */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #1c2033;
  --muted: #6b7280;
  --border: #e2e6ef;
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --accent: #f59e0b;
  --ok: #10b981;
  --warn: #f59e0b;
  --err: #ef4444;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
}
html.dark {
  --bg: #0d1020;
  --surface: #161a2c;
  --surface-2: #1d2238;
  --text: #e7e9f3;
  --muted: #9aa1b5;
  --border: #2a3050;
  --primary: #818cf8;
  --primary-strong: #6366f1;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 900; }
.header-inner { display: flex; align-items: center; gap: 14px; padding: 12px 20px; }
.logo { font-weight: 800; font-size: 20px; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.logo span { color: var(--primary); }
.header-tag { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; }
.header-inner .btn { margin-left: auto; }

/* buttons & inputs */
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover { border-color: var(--primary); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: var(--surface-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; white-space: nowrap; }
.input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; width: 100%;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

/* hero / landing */
.hero-section { padding: 64px 0 40px; }
.hero-title { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -.03em; margin: 0 0 10px; text-align: center; }
.hero-sub { text-align: center; color: var(--muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto 34px; }
.drop-zone {
  max-width: 720px; margin: 0 auto; text-align: center;
  border: 2px dashed var(--border); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow);
  padding: 56px 24px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.dragging {
  border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  transform: translateY(-1px);
}
.drop-icon { font-size: 44px; margin-bottom: 8px; }
.drop-title { font-size: 1.35rem; font-weight: 700; }
.drop-or { color: var(--muted); margin: 10px 0 14px; }
.sample-row { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.sample-note { color: var(--muted); font-size: .9rem; }
.privacy-banner { text-align: center; color: var(--muted); margin-top: 26px; font-size: .95rem; }

/* SEO content */
.seo-content { max-width: 760px; margin: 64px auto 0; color: var(--text); }
.seo-content h2 { font-size: 1.4rem; letter-spacing: -.01em; margin: 34px 0 10px; }
.seo-content p, .seo-content li { color: var(--muted); }
.seo-content details {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; margin: 8px 0;
}
.seo-content summary { font-weight: 600; cursor: pointer; }
.seo-content details p { margin: 8px 0 2px; }
.usecase-list { columns: 2; column-gap: 28px; }
@media (max-width: 600px) { .usecase-list { columns: 1; } }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.panel-title { font-size: 1rem; font-weight: 700; margin: 0 0 12px; }
.analyze-panel { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.analyze-status { font-weight: 600; }
.analyze-sub { color: var(--muted); font-size: .9rem; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--surface-2); border-top-color: var(--primary);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.warn-panel { border-color: var(--warn); margin-bottom: 16px; }
.warn-panel .panel-title { color: var(--warn); }
.coord-row { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.coord-row label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.coord-row .input { min-width: 220px; }
.hint { color: var(--muted); font-size: .9rem; }

/* summary bar */
.summary-bar {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 18px; margin-bottom: 16px;
}
.sum-item { display: flex; flex-direction: column; align-items: center; min-width: 54px; }
.sum-num { font-weight: 800; font-size: 1.25rem; }
.sum-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.sum-checks { flex-direction: row; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.sum-checks span { color: var(--muted); font-size: .88rem; }
.sum-name { font-size: .85rem; color: var(--muted); font-style: italic; margin-right: auto; }

/* workspace grid */
.workspace-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 16px; }
.main-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1000px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .side-col { order: 2; }
  .main-col { order: 1; }
}

/* controls */
.ctrl { margin-bottom: 12px; }
.ctrl label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .03em; }
.popup-fields-ctrl { position: relative; }
.pop {
  position: absolute; z-index: 950; top: 38px; left: 0; width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 12px;
}
.pop-title { font-size: .85rem; font-weight: 600; margin-bottom: 8px; }

/* filters */
.filters-panel .toggle-btn { width: 100%; text-align: left; background: none; border: none; cursor: pointer; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.filters-panel:not(.open) #filters-body { display: none; }
.filter-block { margin-bottom: 14px; }
.filter-label { font-size: .82rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; display: flex; justify-content: space-between; }
.filter-val { font-weight: 500; color: var(--text); }
.range-row { display: flex; flex-direction: column; gap: 2px; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .92rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.check-solo { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.check-inline { flex-direction: row; }

/* quality & insights */
.quality-list { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.quality-list li { padding: 4px 0; line-height: 1.45; }
.q-ok .q-ico { color: var(--ok); }
.q-warn .q-ico { color: var(--warn); }
.q-ico { margin-right: 4px; font-weight: 700; }
.insight { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.insight:last-child { border-bottom: none; }
.insight-k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.insight-v { font-weight: 600; }

/* map */
.map-card { padding: 12px; }
.map-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.map-search { max-width: 240px; }
.showing { color: var(--muted); font-size: .85rem; margin-left: auto; }
.map-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.map-card.fs { position: fixed; inset: 0; z-index: 1200; border-radius: 0; }
#map-wrap { position: relative; }
#map { height: 540px; border-radius: 10px; z-index: 1; background: var(--surface-2); }
.map-card.fs #map { height: calc(100vh - 62px); }
.legend {
  position: absolute; z-index: 800; right: 12px; bottom: 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; font-size: .82rem; min-width: 150px; max-width: 230px;
  box-shadow: var(--shadow); max-height: 60%; overflow: auto;
}
.legend-title { font-weight: 700; margin: 4px 0 6px; }
.legend-gradient { height: 10px; border-radius: 5px; background: linear-gradient(90deg, rgb(79,70,229), rgb(245,158,11)); }
.legend-ends { display: flex; justify-content: space-between; color: var(--muted); margin-top: 2px; }
.legend-item { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.legend-item em { color: var(--muted); font-style: normal; font-size: .75rem; }
.legend-swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend-sizes { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 4px 0; }
.legend-bubble { border-radius: 50%; background: var(--primary); opacity: .75; }

/* popup styling */
.leaflet-popup-content-wrapper { border-radius: 12px; }
.pp-title { font-weight: 700; font-size: .95rem; margin-bottom: 2px; }
.pp-loc { color: var(--muted); font-size: .82rem; margin-bottom: 6px; }
.pp-row { display: flex; justify-content: space-between; gap: 16px; padding: 2.5px 0; border-top: 1px dashed rgba(128,128,128,.25); font-size: .85rem; }
.pp-k { color: var(--muted); }

/* table */
.table-panel { overflow: hidden; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.table-scroll { overflow: auto; max-height: 420px; border: 1px solid var(--border); border-radius: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 5; cursor: pointer; user-select: none; }
.sort-ico { color: var(--muted); font-size: .7rem; margin-left: 4px; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--surface-2); }
.row-selected { background: color-mix(in srgb, var(--primary) 14%, var(--surface)) !important; }
.row-unmapped { color: var(--muted); opacity: .65; }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 10px; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.pager { display: flex; gap: 6px; }

/* privacy section */
.privacy-section { margin: 40px auto 10px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.privacy-section h2 { margin: 0 0 10px; font-size: 1.2rem; }
.privacy-section p { color: var(--muted); }

/* footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 22px 0 34px; color: var(--muted); font-size: .9rem; }
.site-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }

/* toasts */
#toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 480px); }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--primary); border-radius: 10px; box-shadow: var(--shadow);
  padding: 11px 16px; font-size: .9rem; width: 100%;
  animation: toast-in .25s ease; transition: opacity .35s, transform .35s;
}
.toast.out { opacity: 0; transform: translateY(8px); }
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-error { border-left-color: var(--err); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* mobile */
.mobile-only { display: none; }
@media (max-width: 760px) {
  .hero-section { padding: 40px 0 30px; }
  .drop-zone { padding: 40px 16px; }
  .map-toolbar { gap: 6px; }
  .map-search { max-width: none; flex: 1 1 100%; }
  #map { height: 62vh; }
  .map-actions .btn-sm { flex: 1 1 44%; }
  .showing { margin-left: 0; width: 100%; }
  .mobile-only { display: block; }
  .side-col { order: 2; }
  .summary-bar { gap: 10px; }
  .sum-name { width: 100%; }
  .btn, .btn-sm { min-height: 44px; }
  .check input { width: 20px; height: 20px; }
}
@media (max-width: 760px) {
  /* On mobile the map comes first; filters/controls collapse into stacked panels */
  .workspace-grid .side-col .controls-panel { order: -1; }
  .filters-panel:not(.open) { padding-bottom: 8px; }
}

/* leaflet control theming */
.leaflet-bar a { background: var(--surface); color: var(--text); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--primary) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-container { font: inherit; }