/* ── SoakSIM Dashboard ── innealta.com.au ───────────────────────────── */
:root {
  --primary: #1a6b4f;
  --primary-light: #28a77d;
  --primary-dark: #12503b;
  --accent: #f59e0b;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 14px rgba(0,0,0,.10);
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Header ─────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 1000;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

header .brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header .brand span {
  font-size: 0.8rem;
  opacity: 0.7;
  font-weight: 400;
}

header nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: 0.82rem;
  margin-left: 1.2rem;
  transition: color .2s;
}
header nav a:hover { color: #fff; }

/* ── Layout ─────────────────────────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin-bottom: 0.6rem;
  font-weight: 700;
}

/* ── Form controls ──────────────────────────────────────────────────── */
.field { margin-bottom: 0.55rem; }

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.field input, .field select {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(40,167,125,.15);
}

.row { display: flex; gap: 0.5rem; }
.row .field { flex: 1; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all .2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(26,107,79,.25);
}
.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 12px rgba(26,107,79,.3);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: rgba(26,107,79,.06); }

.btn-danger-outline {
  background: transparent;
  border: 1.5px solid var(--danger);
  color: var(--danger);
}
.btn-danger-outline:hover { background: rgba(239,68,68,.06); }

.btn-run {
  width: 100%;
  padding: 0.7rem;
  font-size: 0.95rem;
}

/* ── Catchments ─────────────────────────────────────────────────────── */
.catchment-entry {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  margin-bottom: 0.5rem;
  position: relative;
}
.catchment-entry .remove-catch {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  opacity: .6;
  padding: 0;
  line-height: 1;
}
.catchment-entry .remove-catch:hover { opacity: 1; }

/* ── Main Content ───────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 340px;
  border-bottom: 1px solid var(--border);
}

.results-area {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
}

.tab-btn {
  padding: 0.6rem 1.2rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover { background: #f8fafc; }

/* ── Design summary ─────────────────────────────────────────────────── */
.design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
}

.metric-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 0.7rem;
  text-align: center;
}

.metric-card .value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}

.metric-card .label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.config-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.config-tag {
  background: var(--primary);
  color: #fff;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── Chart ──────────────────────────────────────────────────────────── */
.chart-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  margin-bottom: 0.8rem;
}

.chart-wrap canvas {
  width: 100% !important;
  max-height: 280px;
}

/* ── Loading overlay ────────────────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 9999;
  place-items: center;
}

.loading-overlay.active { display: grid; }

.spinner-card {
  background: #fff;
  padding: 2rem 2.5rem;
  border-radius: 14px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 0.8rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Placeholder ────────────────────────────────────────────────────── */
.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

.placeholder svg {
  width: 56px;
  height: 56px;
  opacity: .3;
  margin-bottom: 0.6rem;
}

.placeholder p {
  font-size: 0.9rem;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
footer a { color: var(--primary); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Checkbox toggle ────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--primary);
  width: 1rem;
  height: 1rem;
}

/* ── Duration checkbox grid ─────────────────────────────────────────── */
.duration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.2rem 0.4rem;
  max-height: 12rem;
  overflow-y: auto;
  padding: 0.3rem 0;
}
.dur-check {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  cursor: pointer;
  padding: 0.15rem 0;
}
.dur-check input[type="checkbox"] {
  accent-color: var(--primary);
  width: 0.85rem;
  height: 0.85rem;
  margin: 0;
}
.dur-check span {
  white-space: nowrap;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
  .sidebar { max-height: 50vh; }
  #map { height: 240px; }
}
