/* Live Traffic page styles */

.live-traffic-page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--space-4) var(--space-5);
  box-sizing: border-box;
}

.lt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.lt-header h2 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  margin: 0;
}

.lt-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.lt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: var(--space-3);
  align-items: stretch;
}

@media (max-width: 1100px) {
  .lt-grid { grid-template-columns: 1fr; }
}

.lt-map-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--color-surface);
}

#lt-map {
  height: calc(100vh - 150px);
  min-height: 520px;
  width: 100%;
}

.lt-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  background: rgba(18, 22, 30, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--color-text);
  font-size: var(--text-sm);
  min-width: 160px;
}

.lt-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.lt-toggle input { cursor: pointer; }

.lt-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 500;
  background: rgba(18, 22, 30, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--color-text);
  font-size: var(--text-xs);
  min-width: 140px;
}

.lt-legend-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: var(--text-sm);
}

.lt-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.lt-sw {
  display: inline-block;
  width: 14px;
  height: 6px;
  border-radius: 2px;
}

.lt-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
  max-height: calc(100vh - 150px);
}

.lt-panel {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.lt-incidents-panel { flex: 1 1 50%; overflow-y: auto; }
.lt-closures-panel { flex: 1 1 50%; overflow-y: auto; }

.lt-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  flex-shrink: 0;
}

.lt-panel-head h3 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.lt-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: 600;
}

.lt-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.lt-list::-webkit-scrollbar { width: 6px; }
.lt-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.lt-incident-card,
.lt-closure-card {
  border-left: 3px solid #888;
  padding: 6px 9px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
  transition: background 0.15s;
  cursor: pointer;
}

.lt-incident-card:hover,
.lt-closure-card:hover {
  background: rgba(255, 255, 255, 0.05);
}

.lt-incident-title,
.lt-closure-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.lt-incident-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.lt-incident-meta,
.lt-closure-meta {
  font-size: var(--text-xs);
  color: var(--color-text-dim);
  margin-top: 2px;
}

.lt-closure-card {
  border-left-color: #dc2626;
}

.lt-closure-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}

.lt-disclaimer {
  margin-top: var(--space-2);
  font-size: 10px;
  color: var(--color-text-dim);
  text-align: right;
  opacity: 0.6;
}

/* Fix Leaflet popup styling to match app theme */
.leaflet-popup-content-wrapper {
  background: rgba(18, 22, 30, 0.96);
  color: var(--color-text);
  border-radius: var(--radius-md);
}

.leaflet-popup-tip {
  background: rgba(18, 22, 30, 0.96);
}

.leaflet-popup-content {
  font-size: var(--text-sm);
  margin: 10px 12px;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--color-text-muted);
}

/* --- Tabs --- */
.lt-tabs {
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  padding: 3px;
  flex: 0 0 auto;
}

.lt-tab {
  appearance: none;
  background: transparent;
  color: var(--color-text-muted);
  border: none;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lt-tab:hover {
  color: var(--color-text);
}

.lt-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.lt-tab-panel {
  animation: lt-fade-in 0.15s ease-out;
}

@keyframes lt-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- History tab --- */
.lt-history-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
}

.lt-history-controls .form-group {
  margin: 0;
  min-width: 140px;
}

.lt-history-controls .lt-ctl-seg {
  flex: 1 1 260px;
  min-width: 240px;
}

.lt-history-controls .lt-ctl-seg .form-input {
  width: 100%;
}

.lt-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.lt-kpi {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.lt-kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.lt-kpi-value {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-text);
}

.lt-kpi-unit {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-left: 4px;
  font-weight: 400;
}

.lt-chart-wrap {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  height: calc(100vh - 380px);
  min-height: 360px;
  position: relative;
}

.lt-chart-wrap canvas {
  max-height: 100%;
}

.lt-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* --- Segments tab --- */
.lt-segments-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: var(--space-3);
  align-items: stretch;
}

@media (max-width: 1100px) {
  .lt-segments-layout { grid-template-columns: 1fr; }
}

.lt-segments-map-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--color-surface);
  min-height: 420px;
}

#lt-seg-map {
  height: calc(100vh - 220px);
  min-height: 420px;
  width: 100%;
}

.lt-segments-side {
  background: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 220px);
}

.lt-segments-toolbar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.lt-segments-toolbar .btn { flex: 1; }

.lt-segments-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}

.lt-seg-card {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  transition: background 0.15s;
}

.lt-seg-card:hover { background: rgba(255, 255, 255, 0.05); }

.lt-seg-card.inactive { opacity: 0.55; }

.lt-seg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lt-seg-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.lt-seg-road {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.lt-seg-coords {
  font-size: 11px;
  color: var(--color-text-dim);
  font-family: var(--font-mono, monospace);
  margin-top: 4px;
}

.lt-seg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
}

.lt-seg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}
.lt-seg-dot.active { background: #22c55e; }

.lt-pick-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: rgba(59, 130, 246, 0.95);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 90%;
}

.lt-pick-hint .btn {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.lt-pick-hint .btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Closures: status dot + impact pill (Phase 3 + 4) ─────────────── */
.lt-closure-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.lt-closure-status {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.lt-impact {
  color: var(--color-accent);
  font-weight: 500;
}

/* ── Alerts tab (Phase 5) ─────────────────────────────────────────── */
.lt-alerts-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 900px) { .lt-alerts-layout { grid-template-columns: 1fr; } }

.lt-alerts-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px;
}
.lt-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.lt-section-head h3 { margin: 0; font-size: var(--text-base); }

.lt-rule-card, .lt-event-card {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--color-surface-2, transparent);
}
.lt-rule-card.inactive { opacity: 0.55; }
.lt-rule-head, .lt-event-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.lt-rule-name, .lt-event-title { font-weight: 600; font-size: var(--text-sm); }
.lt-rule-meta, .lt-event-meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.lt-event-msg { font-size: var(--text-xs); color: var(--color-text); margin-top: 4px; }
.lt-rule-actions { display: flex; gap: 4px; flex-shrink: 0; }

.lt-event-card.open { border-left: 3px solid var(--color-danger); }
.lt-event-card.resolved { opacity: 0.7; border-left: 3px solid var(--color-success, #22c55e); }

/* ── Reports tab (Phase 6) ────────────────────────────────────────── */
.lt-reports-wrap {
  max-width: 720px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 18px;
}
.lt-reports-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.lt-reports-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.lt-reports-wrap h4 { margin: 0 0 12px 0; font-size: var(--text-sm); }

/* ── Public traffic page (Phase 7) ────────────────────────────────── */
.public-traffic-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #0a0e1a;
  color: #e2e8f0;
}
.public-traffic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.public-traffic-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.public-traffic-header a {
  color: #60a5fa;
  text-decoration: none;
  font-size: 13px;
}
.public-traffic-body { flex: 1; min-height: 0; position: relative; }
#public-map { width: 100%; height: 100%; }
.public-traffic-legend {
  position: absolute;
  bottom: 18px; right: 18px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #e2e8f0;
  z-index: 500;
}
.public-traffic-legend-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px;
}
.public-traffic-legend .sw {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
}
