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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0f172a;
  color: #f1f5f9;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Map ──────────────────────────────────────────────────────────────────── */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  z-index: 1100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #f1f5f9;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.topbar-logo-img { width: 26px; height: 26px; border-radius: 6px; }

.filter-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.filter-strip::-webkit-scrollbar { display: none; }

.filter-btn {
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s, transform .1s;
  background: rgba(255,255,255,0.1);
  color: #cbd5e1;
}
.filter-btn:hover { opacity: .85; }
.filter-btn.active { background: #e2e8f0; color: #0f172a; }
.filter-btn[data-type="Accident"].active     { background: #ef4444; color: #fff; }
.filter-btn[data-type="Road Works"].active   { background: #f59e0b; color: #fff; }
.filter-btn[data-type="Vehicle Breakdown"].active { background: #6366f1; color: #fff; }
.filter-btn[data-type="Heavy Traffic"].active     { background: #f97316; color: #fff; }
.filter-btn[data-type="Road Block"].active   { background: #dc2626; color: #fff; }

.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 8px;
  color: #f1f5f9;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.topbar-btn:hover { background: rgba(255,255,255,0.18); }

/* ── Panel ────────────────────────────────────────────────────────────────── */
.panel {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 360px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transform: translateX(0);
  transition: transform .3s ease;
}
.panel.hidden { transform: translateX(100%); }

.panel-header {
  padding: 12px 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.panel-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 10px;
}
.panel-tabs::-webkit-scrollbar { display: none; }

.ptab {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.ptab:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.ptab.active { background: rgba(255,255,255,0.12); color: #f1f5f9; }

.panel-close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2px;
}

.panel-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
.panel-close:hover { color: #f1f5f9; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Panel open button ────────────────────────────────────────────────────── */
.panel-open-btn {
  position: fixed;
  top: 62px;
  right: 12px;
  z-index: 1049;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #f1f5f9;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: none;
}
.panel-open-btn.visible { display: block; }

/* ── Incident cards ───────────────────────────────────────────────────────── */
.incident-count {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 10px;
}

.incident-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s;
}
.incident-card:hover { background: rgba(255,255,255,0.09); }
.incident-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.incident-emoji { font-size: 18px; line-height: 1; }
.incident-type {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  flex: 1;
}
.incident-desc {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
}

/* ── Travel times ─────────────────────────────────────────────────────────── */
.tt-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tt-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.tt-route { font-size: 11px; color: #64748b; margin-top: 2px; }
.tt-time {
  font-size: 18px;
  font-weight: 700;
  color: #22d3ee;
  white-space: nowrap;
}
.tt-unit { font-size: 10px; color: #64748b; }

/* ── Faulty lights ────────────────────────────────────────────────────────── */
.fl-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.fl-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.fl-badge {
  background: #fbbf24;
  color: #0f172a;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.fl-id { font-size: 12px; font-weight: 600; color: #e2e8f0; }
.fl-msg { font-size: 11px; color: #94a3b8; line-height: 1.4; }
.fl-dates { font-size: 10px; color: #475569; margin-top: 4px; }

/* ── Speed band legend ────────────────────────────────────────────────────── */
.speed-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.speed-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #94a3b8;
}
.speed-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.speed-meta {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
}

/* ── Loading / empty states ───────────────────────────────────────────────── */
.pane-loading {
  font-size: 12px;
  color: #64748b;
  padding: 16px 0;
  text-align: center;
}

/* ── Map markers ──────────────────────────────────────────────────────────── */
.incident-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  animation: pulse-glow 3s infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 12px rgba(239, 68, 68, 0.4); }
}

.faulty-light-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 16px;
  background: rgba(251, 191, 36, 0.95);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ── Leaflet overrides ────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.96) !important;
  color: #f1f5f9 !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
  min-width: 200px;
  max-width: 280px;
}
.leaflet-popup-content { margin: 12px 14px !important; }
.leaflet-popup-tip { background: rgba(15, 23, 42, 0.96) !important; }
.leaflet-popup-close-button { color: #64748b !important; }
.leaflet-popup-close-button:hover { color: #f1f5f9 !important; }
.leaflet-container a.leaflet-popup-close-button { color: #94a3b8 !important; }

.popup-emoji { font-size: 24px; text-align: center; margin-bottom: 6px; }
.popup-type { font-size: 13px; font-weight: 700; color: #e2e8f0; margin-bottom: 4px; }
.popup-desc { font-size: 12px; color: #94a3b8; line-height: 1.5; }

/* ── Weather widget ───────────────────────────────────────────────────────── */
#weather-circle {
  position: fixed;
  bottom: 80px;
  right: 14px;
  width: 42px;
  height: 42px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#weather-emoji { font-size: 22px; line-height: 1; }

/* ── Telegram button ──────────────────────────────────────────────────────── */
.telegram-btn {
  position: fixed;
  bottom: 28px;
  right: 14px;
  width: 42px;
  height: 42px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 1000;
  text-decoration: none;
}
.telegram-btn img { width: 26px; height: 26px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .panel { width: 100%; top: 52px; }
  .topbar-logo-text { display: none; }
}
