/* =========================================================================
   India Geoportal Explorer — styles
   Visual language inspired by studio.geolibre.app: light neutral chrome,
   card-based panels, thin borders, a single accent color, small round
   floating tool buttons over the map.
   ========================================================================= */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-soft-2: #eef0f3;
  --border: #e2e5ea;
  --border-strong: #d3d7dd;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --text-faint: #9aa1ab;
  --accent: #146c5b;
  --accent-strong: #0f5346;
  --accent-soft: #e4f2ee;
  --saffron: #ff9933;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 2px 10px rgba(20, 24, 30, 0.08);
  --shadow-float: 0 4px 18px rgba(20, 24, 30, 0.16);
  --topbar-h: 58px;
  --statusbar-h: 30px;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg-soft);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button { font-family: inherit; cursor: pointer; }

/* ---------------------------------------------------------------------
   Top bar
   --------------------------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 500;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.topbar-center { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}
.icon-btn:hover { background: var(--bg-soft-2); }
.icon-btn.round { width: 40px; height: 40px; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-float); border: 1px solid var(--border); }
.icon-btn.round:hover { background: var(--bg-soft); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 180deg, var(--saffron) 0 33%, #ffffff 33% 66%, #128a3e 66% 100%);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14.5px; font-weight: 650; }
.brand-text small { font-size: 11px; color: var(--text-muted); }

.search-box { width: min(420px, 90%); }
.embedded-geocoder.leaflet-control-geocoder {
  width: 100%;
  box-shadow: none !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 999px !important;
  background: var(--bg-soft) !important;
  overflow: hidden;
}
.embedded-geocoder .leaflet-control-geocoder-form input {
  width: 100%; border: none; background: transparent; padding: 8px 14px; font-size: 13.5px; outline: none;
}
.embedded-geocoder .leaflet-control-geocoder-icon {
  background-color: transparent !important;
  background-image: none !important;
  position: relative;
}
.embedded-geocoder .leaflet-control-geocoder-icon::before {
  content: "";
  position: absolute; inset: 0; margin: auto; width: 15px; height: 15px;
  border: 1.6px solid var(--text-muted); border-radius: 50%;
}
.embedded-geocoder .leaflet-control-geocoder-icon::after {
  content: "";
  position: absolute; width: 6px; height: 1.6px; background: var(--text-muted);
  transform: rotate(45deg); right: 8px; bottom: 10px;
}
.embedded-geocoder .leaflet-control-geocoder-alternatives {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  margin-top: 4px; box-shadow: var(--shadow-card); overflow: hidden;
}
.embedded-geocoder .leaflet-control-geocoder-alternatives li a { padding: 8px 12px; font-size: 13px; color: var(--text); }
.embedded-geocoder .leaflet-control-geocoder-alternatives li:hover a { background: var(--accent-soft); }

.basemap-switch {
  display: flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px; padding: 3px;
}
.basemap-btn {
  border: none; background: transparent; padding: 6px 12px; font-size: 12.5px; border-radius: 999px; color: var(--text-muted); font-weight: 600;
}
.basemap-btn.active { background: var(--accent); color: #fff; }
.basemap-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   App body / layout
   --------------------------------------------------------------------- */
.app-body { height: calc(100% - var(--topbar-h)); display: flex; }

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.sidebar {
  width: 320px;
  flex: none;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease, margin-left 0.22s ease;
  z-index: 400;
}
.sidebar.collapsed { width: 0; margin-left: -1px; overflow: hidden; }

.sidebar-header {
  height: 44px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; font-size: 12.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}

.text-btn { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; }
.text-btn:hover { text-decoration: underline; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font-size: inherit; text-decoration: underline; }

.sidebar-scroll { flex: 1 1 auto; overflow-y: auto; padding: 12px; }

.basemap-card {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px; margin-bottom: 14px;
}
.basemap-card-row { display: flex; align-items: center; justify-content: space-between; }
.opacity-row { margin-top: 8px; }

.category { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px; overflow: hidden; background: var(--bg); }
.category-header {
  width: 100%; display: grid; grid-template-columns: 20px 1fr auto 16px; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg); border: none; text-align: left;
}
.category-header:hover { background: var(--bg-soft); }
.category-icon { color: var(--accent); display: flex; }
.category-title { font-size: 13.5px; font-weight: 650; }
.category-count {
  font-size: 11px; color: var(--text-muted); background: var(--bg-soft-2); border-radius: 999px; padding: 1px 7px;
}
.category-chevron { transition: transform 0.18s ease; color: var(--text-faint); }
.category.open .category-chevron { transform: rotate(180deg); }

.category-body {
  display: grid; grid-template-rows: 0fr; overflow: hidden; transition: grid-template-rows 0.22s ease;
}
.category.open .category-body { grid-template-rows: 1fr; }
.category-body-inner { min-height: 0; overflow: hidden; }

.layer-row { padding: 9px 12px; border-top: 1px solid var(--border); }
.layer-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.layer-name { font-size: 13px; font-weight: 500; color: var(--text); }
.layer-row-sub { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.layer-attribution { font-size: 10.5px; color: var(--text-faint); flex: none; min-width: 80px; }
.mini-opacity { flex: 1 1 auto; accent-color: var(--accent); height: 3px; }
.layer-row-time { margin-top: 6px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-muted); }
.layer-row-time select { font-size: 12px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg); }

.sidebar-footer-note { padding: 10px 4px 4px; font-size: 11px; line-height: 1.5; color: var(--text-faint); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background 0.15s ease;
}
.switch .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%;
  transition: transform 0.15s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch.small { width: 32px; height: 18px; }
.switch.small .slider::before { height: 14px; width: 14px; }
.switch.small input:checked + .slider::before { transform: translateX(14px); }

/* ---------------------------------------------------------------------
   Map area
   --------------------------------------------------------------------- */
.map-wrap { flex: 1 1 auto; position: relative; display: flex; flex-direction: column; min-width: 0; }
#map { flex: 1 1 auto; background: #dfe6e2; }

.map-tools {
  position: absolute; top: 16px; right: 14px; z-index: 450; display: flex; flex-direction: column; gap: 8px;
}

.legend-panel {
  position: absolute; right: 14px; bottom: 46px; z-index: 450; width: 260px; max-height: 46vh;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-float);
  display: flex; flex-direction: column; overflow: hidden;
}
.legend-panel.hidden { display: none; }
.legend-panel-header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 700;
}
.legend-content { padding: 10px 12px; overflow-y: auto; }
.legend-empty { font-size: 12px; color: var(--text-faint); margin: 4px 0; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12px; }
.legend-item img { max-width: 120px; max-height: 60px; }

.status-bar {
  height: var(--statusbar-h); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--bg); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted);
}
.status-spacer { flex: 1 1 auto; }
.status-credit { color: var(--text-faint); }

/* Leaflet control tweaks */
.leaflet-control-zoom { border: 1px solid var(--border) !important; box-shadow: var(--shadow-float) !important; border-radius: var(--radius-sm) !important; overflow: hidden; }
.leaflet-control-zoom a { color: var(--text) !important; }
.leaflet-control-scale-line { background: rgba(255,255,255,0.85) !important; border-color: var(--border-strong) !important; color: var(--text) !important; }

/* ---------------------------------------------------------------------
   Banner
   --------------------------------------------------------------------- */
.app-banner {
  position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 900;
  background: #1a1d21; color: #fff; font-size: 12.5px; padding: 9px 14px; border-radius: 999px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-float); max-width: 90vw;
}
.app-banner button { background: none; border: none; color: #fff; font-size: 16px; line-height: 1; opacity: 0.7; }
.app-banner button:hover { opacity: 1; }

/* ---------------------------------------------------------------------
   About modal
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 30, 0.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--bg); border-radius: var(--radius-lg); max-width: 620px; width: 100%; max-height: 82vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-float); overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-body { padding: 6px 20px 20px; overflow-y: auto; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.modal-body h3 { font-size: 13px; margin: 18px 0 6px; color: var(--accent-strong); }
.modal-body p { margin: 8px 0; }
.modal-body ul { margin: 8px 0; padding-left: 20px; }
.modal-body li { margin-bottom: 6px; }
.modal-body a { color: var(--accent); }
.modal-body code { background: var(--bg-soft-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 860px) {
  :root { --topbar-h: 52px; }
  .topbar-center { display: none; }
  .sidebar { position: absolute; top: var(--topbar-h); bottom: 0; left: 0; width: 86vw; max-width: 340px; box-shadow: var(--shadow-float); }
  .sidebar.collapsed { width: 0; }
  .basemap-switch .basemap-btn { padding: 6px 8px; font-size: 11px; }
  .brand-text small { display: none; }
}
