/* ============================================
   THEME VARIABLES
============================================ */

:root {
  --bg: #ffffff;
  --bg-elevated: #f3f4f6;
  --text: #111827;
  --text-muted: #6b7280;
  --border-subtle: #d1d5db;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.15);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.15);
}

:root.dark {
  --bg: #050816;
  --bg-elevated: #0b1020;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border-subtle: #1b2238;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.55);
}

/* ============================================
   GLOBAL
============================================ */

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s ease, color 0.25s ease;
}

/* ============================================
   TOPBAR
============================================ */

.topbar {
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #a5b4fc, #4f46e5);
  box-shadow: 0 0 18px rgba(129, 140, 248, 0.9);
}

.brand-text {
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 15px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================
   LAYOUT
============================================ */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.map-panel {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 480px;
}

/* ============================================
   MAP TOOLBAR (NEW)
============================================ */

.map-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  gap: 8px;
}

.map-toolbar-left,
.map-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#isp-filter,
#rating-filter,
.search-input {
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  outline: none;
}

.search-input {
  min-width: 160px;
}

#isp-filter:focus,
#rating-filter:focus,
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

/* ============================================
   PANELS
============================================ */

.panel-section {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.panel-section h2 {
  margin: 0 0 6px;
  font-size: 15px;
}

.hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   FORM
============================================ */

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

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row label {
  font-size: 12px;
  color: var(--text-muted);
}

.form-row input,
.form-row select {
  background: var(--bg);
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  padding: 7px 9px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.form-row input:focus,
.form-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.location-indicator {
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px dashed var(--border-subtle);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-muted);
}

.form-message {
  margin-top: 6px;
  font-size: 12px;
  min-height: 16px;
}

/* ============================================
   BUTTONS
============================================ */

.btn {
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, transform 0.08s ease,
    box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.55);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(79, 70, 229, 0.7);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.6);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  padding-inline: 10px;
}

.btn-ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ============================================
   STATS
============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 9px;
  border: 1px solid var(--border-subtle);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 600;
}

/* ============================================
   LEGEND
============================================ */

.legend {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
}

.legend-smooth {
  background: #22c55e;
}

.legend-ok {
  background: #eab308;
}

.legend-bad {
  background: #f97316;
}

.legend-unusable {
  background: #ef4444;
}

/* ============================================
   FOOTER
============================================ */

.footer {
  padding: 8px 16px 12px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

/* ============================================
   LEAFLET OVERRIDES
============================================ */

.leaflet-container {
  background: var(--bg);
}

.marker-cluster-small {
  background-color: rgba(129, 140, 248, 0.3);
}
.marker-cluster-small div {
  background-color: rgba(129, 140, 248, 0.9);
  color: white;
}

/* ============================================
   RESPONSIVE
============================================ */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  #map {
    min-height: 360px;
  }

  .footer {
    flex-direction: column;
    gap: 4px;
  }

  .map-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .map-toolbar-left,
  .map-toolbar-right {
    justify-content: space-between;
  }

  .search-input {
    flex: 1;
  }
}
