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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  background: #1a1a2e;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── Map ── */
#map {
  position: absolute;
  inset: 0;
}

/* ── Shared panel base ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1d3557;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  border-radius: 8px 8px 0 0;
  user-select: none;
}

/* ── Language switcher (top-right) ── */
/* z-index above #side-panel (20) so it stays reachable even when the side
   panel is open; #side-panel's own top offset is pushed down below it (see
   its rule) so the two never visually overlap. */
#lang-switcher {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
  display: flex;
  gap: 4px;
  background: #fff;
  border: 2px solid #1d3557;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
}

#lang-switcher button {
  padding: 5px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #1d3557;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

#lang-switcher button:hover { background: #f0f4ff; }

#lang-switcher button.active {
  background: #1d3557;
  color: #fff;
}

/* ── Language-switch legal disclaimer modal ── */
#lang-disclaimer-modal[hidden] { display: none; }

#lang-disclaimer-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lang-disclaimer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

#lang-disclaimer-box {
  position: relative;
  max-width: 420px;
  margin: 0 20px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  padding: 22px 24px;
  text-align: center;
}

#lang-disclaimer-box h2 {
  font-size: 15px;
  color: #1d3557;
  margin-bottom: 10px;
}

#lang-disclaimer-box p {
  font-size: 12px;
  color: #333;
  line-height: 1.5;
  margin-bottom: 16px;
}

#lang-disclaimer-box button {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  background: #1d3557;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#lang-disclaimer-box button:hover { background: #16283f; }

/* ── Layer panel (top-left) ── */
#layer-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 230px;
  background: #fff;
  border: 2px solid #1d3557;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  z-index: 10;
  overflow: hidden;
}

#layer-panel .panel-header {
  border-radius: 8px 8px 0 0;
  font-size: 11px;
}

#layer-toggles {
  padding: 8px 0;
  max-height: 320px;
  overflow-y: auto;
}

/* ── Layer groups (by source .gpkg file) ── */
.layer-group {
  border-bottom: 1px solid #eee;
}

.layer-group:last-child { border-bottom: none; }

.layer-group summary {
  padding: 6px 14px;
  font-size: 10px;
  font-weight: 700;
  color: #1d3557;
  background: #f4f7fb;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.2px;
}

.layer-group summary::-webkit-details-marker { display: none; }

.layer-group summary::before {
  content: '▶';
  font-size: 8px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.layer-group[open] > summary::before { transform: rotate(90deg); }

.layer-group-body { padding: 4px 0; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  cursor: pointer;
  color: #333;
  transition: background 0.15s;
  line-height: 1.3;
  font-size: 11px;
}

.layer-row:hover { background: #f0f4ff; }

.layer-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #1d3557;
}

#admin-link {
  display: block;
  padding: 7px 14px;
  font-size: 10px;
  color: #888;
  text-decoration: none;
  border-top: 1px solid #eee;
}

#admin-link:hover { color: #1d3557; }

/* top is set dynamically in app.js (positionCareiAziBtn), just below
   #layer-panel's actual rendered height — that panel's height varies with
   how many layer groups/toggles are loaded, so it can't be a fixed offset. */
#carei-azi-btn {
  position: absolute;
  left: 10px;
  width: 230px;
  padding: 10px 14px;
  border: 2px solid #1d3557;
  border-radius: 8px;
  background: #1d3557;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  z-index: 10;
}

#carei-azi-btn:hover { background: #16283f; }

/* ── Side panel (right) ── */
#side-panel {
  position: absolute;
  top: 54px; /* clears the language switcher fixed at top:10px so they never overlap */
  right: -420px;
  width: 420px;
  height: calc(100vh - 54px);
  background: #fff;
  box-shadow: -3px 0 15px rgba(0,0,0,0.25);
  z-index: 20;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
  overflow: hidden;
}

#side-panel.open { right: 0; }

#side-panel .panel-header {
  flex-shrink: 0;
  border-radius: 0;
  font-size: 11px;
}

#panel-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#close-panel {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.15s;
}

#close-panel:hover { opacity: 1; }

#report-btn {
  flex-shrink: 0;
  margin-left: 8px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 5px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: background 0.15s;
}

#report-btn:hover { background: rgba(255,255,255,0.25); }

#report-btn.hidden { display: none; }

#panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.hint {
  padding: 20px 16px;
  color: #888;
  text-align: center;
  font-size: 11px;
}

/* ── Section (details/summary) ── */
#panel-content details {
  border-bottom: 1px solid #eee;
}

#panel-content details:last-child { border-bottom: none; }

#panel-content summary {
  padding: 12px 16px;
  font-weight: 700;
  color: #1d3557;
  cursor: pointer;
  background: #f4f7fb;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#panel-content summary::before {
  content: '▶';
  font-size: 11px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

#panel-content details[open] > summary::before { transform: rotate(90deg); }

#panel-content summary::-webkit-details-marker { display: none; }

.section-body { padding: 4px 0; }

/* Each row is a mini dropdown: collapsed to one line, click to expand the value. */
.row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px;
  padding: 10px 16px;
  align-items: baseline;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

.row:hover { background: #f7f9fc; }

.row:last-child { border-bottom: none; }

.row-label {
  color: #444;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.row-value {
  color: #222;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row.expanded {
  align-items: start;
}

.row.expanded .row-value {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
}

/* ── Search panel (bottom-left) ── */
#search-panel {
  position: absolute;
  bottom: 20px;
  left: 10px;
  width: 230px;
  background: #fff;
  border: 2px solid #1d3557;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
  z-index: 10;
  overflow: hidden;
}

#search-panel .panel-header {
  border-radius: 8px 8px 0 0;
  font-size: 11px;
  justify-content: flex-start;
  gap: 6px;
}

#search-body { padding: 10px; }

.search-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.search-tab {
  flex: 1;
  padding: 5px 4px;
  font-size: 10px;
  font-weight: 600;
  color: #1d3557;
  background: #f4f7fb;
  border: 1px solid #dde3ee;
  border-radius: 5px;
  cursor: pointer;
}

.search-tab:hover { background: #eef2f9; }

.search-tab.active {
  background: #1d3557;
  color: #fff;
  border-color: #1d3557;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-form[hidden] { display: none; }

.search-form input,
.search-form select {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #dde3ee;
  border-radius: 5px;
  font-family: inherit;
}

.search-form input:focus,
.search-form select:focus {
  outline: none;
  border-color: #1d3557;
}

.search-form button {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #1d3557;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.search-form button:hover { background: #163049; }

#search-results {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
}

#search-results .hint { padding: 8px 2px; font-size: 11px; text-align: left; }

.search-result-row {
  padding: 7px 8px;
  border: 1px solid #eee;
  border-radius: 5px;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 11px;
  color: #333;
  transition: background 0.15s;
}

.search-result-row:last-child { margin-bottom: 0; }

.search-result-row:hover { background: #f0f4ff; }

.search-result-row .result-layer {
  display: block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #1d3557;
  margin-bottom: 2px;
}

/* ── Loading overlay ── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 46, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  color: #fff;
  font-size: 15px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #a8dadc;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* ── MapLibre attribution tweak ── */
.maplibregl-ctrl-attrib {
  font-size: 10px !important;
}
