/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: #f4f5f7;
  color: #111;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ───────────────────────────────────────────────────────── */
.navbar {
  background: #fff !important;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 32px;
  min-height: 52px;
  box-shadow: none;
}
.navbar-brand {
  color: #111 !important;
  font-weight: 700;
  padding: 0;
  display: flex !important;
  align-items: center;
  height: 52px;
}
.navbar-brand:hover { color: #111 !important; }
.navbar-nav { gap: 2px; }
.nav-link {
  color: #555 !important;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 14px !important;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover  { color: #111 !important; background: #f4f5f7; }
.nav-link.active { color: #fff !important; background: #111 !important; border-radius: 6px; }

/* ── Main content ─────────────────────────────────────────────────── */
.main-content { padding: 20px 32px; }

/* ── Section blocks ───────────────────────────────────────────────── */
.section-block {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 12px;
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #bbb;
  margin: 0;
}

/* ── Controls panel (sidebar) ─────────────────────────────────────── */
.controls-panel {
  background: #fafafa;
  border: 1px solid #ebebeb;
  border-radius: 8px;
  padding: 16px;
}

/* Prevent Bootstrap tab-content overflow from interfering with fixed sidebar */
.tab-content { overflow: visible !important; padding: 0 !important; margin: 0 !important; }
.tab-pane    { overflow: visible !important; padding: 0 !important; margin: 0 !important; }
[role="tabpanel"] { padding: 0 !important; margin: 0 !important; }
/* Remove Shiny's default body top padding that creates gap under navbar */
body { padding-top: 0 !important; margin-top: 0 !important; }

/* Map tab - picker dropdowns must clear absolutePanel */
.panel-absolute { overflow: visible !important; }
.vscomp-dropbox-container { z-index: 99999 !important; }
.control-group-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #bbb;
  margin-bottom: 6px;
}
.control-divider {
  border: none;
  border-top: 1px solid #ebebeb;
  margin: 14px 0;
}
.controls-panel .form-control,
.controls-panel .form-select {
  font-size: 11px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  background: #fff;
}
.controls-panel .form-control:focus,
.controls-panel .form-select:focus {
  border-color: #111;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.07);
  outline: none;
}
.controls-panel .control-label {
  font-size: 10px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
/* Compact picker button */
.controls-panel .dropdown-toggle {
  font-size: 11px !important;
  padding: 4px 8px !important;
  height: 30px !important;
  line-height: 1.4 !important;
}
/* Compact picker dropdown items */
.controls-panel .dropdown-menu li a {
  font-size: 11px !important;
  padding: 3px 10px !important;
}
/* Compact actions box buttons */
.controls-panel .bs-actionsbox .btn {
  font-size: 10px !important;
  padding: 2px 6px !important;
}
/* Dropdown z-index */
.controls-panel .dropdown-menu {
  z-index: 99999 !important;
}

/* ── Stat pills ───────────────────────────────────────────────────── */
.stat-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-pills-row { margin-bottom: 16px; }

/* ── Form controls global ─────────────────────────────────────────── */
.control-label { font-size: 11px; font-weight: 600; color: #666; }
.form-control, .form-select {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: #111;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.07);
  outline: none;
}

/* ── Chart toggle ─────────────────────────────────────────────────── */
.btn-group .btn-outline-dark {
  font-size: 11px !important;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 6px;
  border: 1px solid #ddd;
  color: #555;
  background: #fff;
  transition: all 0.15s;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn-dark {
  background: #111;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.15s;
}
.btn-dark:hover, .btn-dark:focus { background: #333; box-shadow: none; }

/* ── Cards (bslib) ────────────────────────────────────────────────── */
.card { border-radius: 8px; border: 1px solid #e8e8e8; box-shadow: none; }
.card-header { border-radius: 8px 8px 0 0 !important; }

/* ── Reactable ────────────────────────────────────────────────────── */
.rt-search { font-size: 10px; padding: 2px; }
.rt-pagination { font-size: 11px; display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; }
.rt-pagination-nav { display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; }
.rt-table { table-layout: fixed; width: 100%; }
.rt-td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-pagination-button {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #e8e8e8;
  background: #fff;
  color: #555;
  min-width: 28px;
}
.rt-pagination-button:hover { background: #f4f5f7; color: #111; }
.rt-pagination-button[disabled] { opacity: 0.35; cursor: default; }
.rt-page-info { font-size: 11px; color: #999; }

/* ── Region tags ──────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px !important;
  font-weight: 600;
  white-space: nowrap;
}
.status-metro    { background: #0868ac; color: white; }
.status-regional { background: #f79832; color: white; }
.status-outside  { background: #e8e8e8; color: #555; }
.status-na       { background: #111111; color: white; }
.status-male     { background: #e8f0fb; color: #1a56a0; }
.status-female   { background: #fde8f5; color: #a0217a; }

/* ── Map tab - remove gap between navbar and map ──────────────────── */
.tab-content > .tab-pane.active:has(#mymap) {
  padding: 0 !important;
  margin: 0 !important;
}
.leaflet-container { background-color: white !important; margin: 0 !important; }
.leaflet .legend { line-height: 12px; font-size: 11px; }

/* ── Map absolutePanel styling ────────────────────────────────────── */
.panel-absolute .irs--shiny .irs-bar    { background: #111; border-color: #111; }
.panel-absolute .irs--shiny .irs-handle { background: #111; border-color: #111; }
.panel-absolute .irs--shiny .irs-single { background: #111; font-size: 10px; }

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ── Errors ───────────────────────────────────────────────────────── */
.shiny-output-error { visibility: hidden; }
.shiny-output-error:before { visibility: hidden; }
