/* ============================================================
   Ottoman Anatolia Schooling — HGIS Web Map
   style.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
}

/* ── Layout ─────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
#header {
  background: #16213e;
  border-bottom: 2px solid #c8a96e;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

#header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #f0d9a8;
  white-space: nowrap;
}

#header p.subtitle {
  font-size: 0.75rem;
  color: #a0a8c0;
  margin-top: 2px;
}

#header-left { flex: 1; min-width: 0; }

#header-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#header-right a {
  font-size: 0.75rem;
  color: #c8a96e;
  text-decoration: none;
  border: 1px solid #c8a96e44;
  border-radius: 4px;
  padding: 4px 10px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
#header-right a:hover {
  background: #c8a96e22;
  color: #f0d9a8;
}

/* ── Main area ───────────────────────────────────────────── */
#main {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: 280px;
  min-width: 240px;
  background: #16213e;
  border-right: 1px solid #2a3060;
  overflow-y: auto;
  padding: 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-section { }

.sidebar-section h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #c8a96e;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2a3060;
}

/* Layer toggles */
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 0.82rem;
  color: #c8d0e0;
  user-select: none;
}
.layer-toggle input[type="checkbox"] { cursor: pointer; accent-color: #c8a96e; }
.layer-toggle .swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Choropleth legend */
#choropleth-legend {
  font-size: 0.75rem;
  color: #a0a8c0;
}
#choropleth-legend .legend-title {
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: #c8d0e0;
}
.legend-scale {
  display: flex;
  height: 10px;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.67rem;
}

/* Stats panel */
#stats-panel {
  font-size: 0.8rem;
  line-height: 1.6;
  color: #a0a8c0;
  min-height: 40px;
}
#stats-panel b { color: #f0d9a8; }
#stats-panel .stat-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dotted #2a3060;
  padding: 2px 0;
}
#stats-panel .stat-row:last-child { border-bottom: none; }

/* ── Map ─────────────────────────────────────────────────── */
#map {
  flex: 1;
  min-width: 0;
  background: #0f3460;
}

/* ── Leaflet overrides ───────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: #1e2a4a;
  color: #e0e0e0;
  border: 1px solid #c8a96e44;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.leaflet-popup-tip { background: #1e2a4a; }
.leaflet-popup-content {
  margin: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  min-width: 180px;
  max-width: 280px;
}
.leaflet-popup-content h4 {
  color: #f0d9a8;
  font-size: 0.9rem;
  margin-bottom: 6px;
  border-bottom: 1px solid #c8a96e44;
  padding-bottom: 4px;
}
.leaflet-popup-content .tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.leaflet-popup-content table { width: 100%; border-collapse: collapse; }
.leaflet-popup-content td {
  padding: 2px 4px;
  vertical-align: top;
}
.leaflet-popup-content td:first-child {
  color: #a0a8c0;
  white-space: nowrap;
  padding-right: 10px;
}

.leaflet-control-zoom a {
  background: #16213e !important;
  color: #c8a96e !important;
  border-color: #2a3060 !important;
}
.leaflet-control-zoom a:hover { background: #1e2a4a !important; }

.leaflet-control-attribution {
  background: rgba(22,33,62,0.85) !important;
  color: #606880 !important;
  font-size: 0.65rem !important;
}
.leaflet-control-attribution a { color: #8090b0 !important; }

/* Kaza hover highlight */
.kaza-hover { cursor: pointer; }

/* ── Loading overlay ─────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  flex-direction: column;
  gap: 14px;
  transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid #2a3060;
  border-top-color: #c8a96e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading p {
  color: #a0a8c0;
  font-size: 0.85rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 680px) {
  #sidebar { display: none; }
  #header h1 { font-size: 0.9rem; }
  #header .subtitle { display: none; }
}
