/* ====================================================================
   CUMBERLAND EMERGENCY TRAFFIC OPERATIONS - DASHBOARD CSS
   Optimized and consolidated for 4K displays
   ==================================================================== */

/* ==================================================================== 
   1. ROOT VARIABLES & RESETS
   ==================================================================== */

:root {
  --bg: #05070b;
  --panel: #10131b;
  --panel-soft: #151924;
  --accent: #60a5fa;
  --accent-warn: #facc15;
  --accent-bad: #f97373;
  --accent-good: #22c55e;
  --ink: #e5e7eb;
  --ink-muted: #9ca3af;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(circle at top, #111827 0, #020617 55%);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
}

body.no-scroll {
  overflow: hidden;
}

/* ====================================================================
   2. LAYOUT CONTAINERS
   ==================================================================== */

.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100vw;
  padding: 12px;
  gap: 12px;
  overflow: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  border-radius: 24px;
  background: linear-gradient(90deg, #020617, #020617 40%, #0b1220 100%);
  box-shadow: var(--shadow);
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
}

.title-main {
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

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

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.quick-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
}

.badge.ok {
  border-color: rgba(34, 197, 94, 0.8);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.badge.warn {
  border-color: rgba(250, 204, 21, 0.8);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.5);
}

.badge.bad {
  border-color: rgba(248, 113, 113, 0.9);
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.7);
}

.main-grid {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 42% 58%;
  grid-template-rows: auto;
  gap: 12px;
  min-height: 0;
  height: auto;
  overflow: visible;
  align-items: start;
}

/* ====================================================================
   3. PANEL STYLES
   ==================================================================== */

.panel {
  background: radial-gradient(circle at top left, #111827 0, #020617 60%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-secondary {
  background: radial-gradient(circle at bottom right, #020617 0, #020617 60%);
}

.panel-header {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(55, 65, 81, 0.8);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.82rem;
  color: var(--ink);
}

.panel-subtitle,
.subtle {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.panel-body {
  padding: 6px 8px;
  flex: initial;
  min-height: auto;
  overflow: visible;
}

/* ====================================================================
   4. LEFT COLUMN
   ==================================================================== */

.left-col,
.left-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow: visible;
}

.camera-panel,
.cameras-panel {
  flex: 0 0 540px;
  min-height: 540px;
  max-height: 540px;
  display: flex;
  flex-direction: column;
}

/* ============================================
   FIX CAMERA SIZE BY SCREEN HEIGHT
   ============================================ */

/* Small/medium laptop screens */
@media (max-height: 1000px) {

  .camera-panel,
  .cameras-panel {
    flex: 0 0 360px !important;
    min-height: 360px !important;
  }
}

/* Medium desktop screens */
@media (min-height: 1001px) and (max-height: 1400px) {

  .camera-panel,
  .cameras-panel {
    flex: 0 0 430px !important;
    min-height: 430px !important;
  }
}

/* Large screens / 4K wallboards */
@media (min-height: 1401px) {

  .camera-panel,
  .cameras-panel {
    flex: 0 0 540px !important;
    min-height: 540px !important;
  }
}

/* Closures List */
.closures-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.closure-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(55, 65, 81, 0.8);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.closure-street {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin-bottom: 4px;
}

.closure-reason {
  font-size: 0.85rem;
  color: var(--ink-muted);
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
}

.closure-reason strong {
  color: var(--ink);
  font-weight: 500;
}

.closure-dates {
  font-size: 0.8rem;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin-top: 2px;
}

.closure-dates strong {
  color: var(--ink);
  font-weight: 500;
}

.closure-empty {
  padding: 20px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

/* Incidents List */
.incidents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.incident-item {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(55, 65, 81, 0.7);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.incident-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.incident-badge.minor {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.incident-badge.moderate {
  background: rgba(250, 204, 21, 0.12);
  color: #fde047;
}

.incident-badge.major {
  background: rgba(248, 113, 113, 0.15);
  color: #fecaca;
}

.incident-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.incident-meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.25;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.incident-time {
  font-size: 0.75rem;
  color: #aab1b7;
  font-variant-numeric: tabular-nums;
}

/* ====================================================================
   5. RIGHT COLUMN (MAP)
   ==================================================================== */

.right-col,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  height: auto;
}

.map-panel {
  flex: 0 0 auto !important;
  min-height: 0 !important;
  height: auto !important;
  display: flex;
  flex-direction: column;
}

.map-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1 1 auto !important;
  width: 100%;
  height: 100% !important;
  min-height: 0 !important;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(55, 65, 81, 0.9);
}



/* ====================================================================
   6. CAMERA ELEMENTS
   ==================================================================== */

#cams-grid,
.cams-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.cam-card {
  width: 100%;
  flex: 1;
  background: #000;
  border-radius: 12px;
  border: 1px solid rgba(55, 65, 81, 0.6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cam-header {
  padding: 8px 12px;
  background: rgba(2, 6, 23, 0.8);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid rgba(55, 65, 81, 0.4);
  position: relative;
}

.cam-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.cam-meta {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.cam-view {
  flex: 1;
  display: flex;
  background: #000;
  min-height: 0;
}

.cam-view-inner {
  flex: 1;
  display: flex;
}

.cam-view-inner img,
.cam-view-inner iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.cam-view-inner video {
  width: 100%;
  height: auto;
  flex: 1;
  border: 0;
  object-fit: cover;
}

.cam-expand-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  border: 1px solid rgba(55, 65, 81, 0.5);
  transition: background 120ms, border-color 120ms;
}

.cam-expand-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  border-color: rgba(96, 165, 250, 0.8);
}

.cam-expand-btn:active {
  transform: scale(0.96);
}

/* ====================================================================
   7. FULLSCREEN CAMERA
   ==================================================================== */

.cam-fullscreen {
  position: fixed !important;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  flex-direction: column;
  border-radius: 0 !important;
  box-shadow: none !important;
  animation: camFadeIn 180ms ease-out;
}

.cam-fullscreen .cam-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 0.25));
  border-bottom: 1px solid rgba(55, 65, 81, 0.5);
  z-index: 10001;
}

.cam-fullscreen .cam-view {
  flex: 1;
  min-height: 0;
}

.cam-fullscreen video,
.cam-fullscreen .cam-view-inner video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-fullscreen .cam-expand-btn {
  opacity: 0;
  pointer-events: none;
}

@keyframes camFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ====================================================================
   8. MARKER ANIMATIONS
   ==================================================================== */

.marker-pulse {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(96, 165, 250, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
  }
}

/* ====================================================================
   9. RESPONSIVE - 1000px+ (Desktop / 4K)
   ==================================================================== */

@media (min-width: 1000px) {

  html,
  body {
    font-size: 19px;
  }

  .title-main {
    font-size: 1.1rem;
  }

  .title-sub {
    font-size: 0.92rem;
  }

  .clock {
    font-size: 1rem;
    padding: 6px 12px;
  }

  .badge {
    font-size: 0.8rem;
  }

  .panel-title {
    font-size: 0.95rem;
    letter-spacing: 0.18em;
  }

  .panel-subtitle {
    font-size: 0.86rem;
  }

  .closure-street {
    font-size: 1rem;
  }

  .closure-reason {
    font-size: 0.88rem;
  }

  .closure-dates {
    font-size: 0.82rem;
  }

  .incidents-list {
    max-height: 46vh;
  }

  .incident-badge {
    font-size: 0.75rem;
  }

  .incident-title {
    font-size: 0.95rem;
  }

  .incident-meta {
    font-size: 0.82rem;
  }
}

@media (min-width: 1400px) {
  body {
    font-size: 20px;
  }

  .incident-title {
    font-size: 1.2rem;
  }

  .incident-meta {
    font-size: 1rem;
  }

  .panel-title {
    font-size: 1.25rem;
  }
}

/* ====================================================================
   11. DESKTOP MAP SIZING
   ==================================================================== */

@media (min-width: 1000px) {
  .map-panel {
    flex: 0 0 500px !important;
    max-height: 500px;
  }
}

/* ====================================================================
   12. RESPONSIVE - MOBILE
   ==================================================================== */

/* ===============================
   MOBILE FIX: CLEAN SINGLE-COLUMN LAYOUT
   =============================== */
@media (max-width: 999px) {
  .wrapper {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* Collapse to 1 column */
  .main-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: visible !important;
  }

  /* Correct ordering */
  .right-col {
    order: 1;
    /* Camera + Map FIRST on mobile */
    width: 100%;
  }

  .left-col {
    order: 2;
    /* Incidents + Closures AFTER */
    width: 100%;
  }

  /* Fix camera height */
  .camera-panel,
  .cameras-panel {
    flex: 0 0 280px !important;
    min-height: 280px !important;
    max-height: 280px !important;
  }

  .cam-view,
  .cam-view-inner video {
    height: 100% !important;
    object-fit: cover !important;
  }

  /* Fix map height */
  .map-panel {
    flex: 0 0 340px !important;
    min-height: 340px !important;
    max-height: 340px !important;
  }

  .map-body {
    padding: 0 !important;
  }

  #map {
    height: 100% !important;
  }

  /* Tighten spacing in text panels */
  .panel-body {
    padding: 10px 12px !important;
  }

  .incident-item {
    padding: 12px 14px !important;
  }

  /* Remove huge top/bottom padding that causes jumpy scroll */
  .panel {
    padding: 0 !important;
  }

  .cam-card {
    height: 100%;
  }

  .cam-header {
    padding: 10px 14px;
  }

  .cam-name {
    font-size: 1rem;
  }

  .cam-meta {
    font-size: 0.78rem;
  }
}

/* ====================================================================
   13. LEAFLET MAP OVERRIDES
   ==================================================================== */

#map {
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
}

.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.95);
  color: var(--ink);
  border-radius: 8px;
}

.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.95);
}

/* ============================================================
   FINAL FIX: STOP LEFT COLUMN FROM BEING CLIPPED
   ============================================================ */

.wrapper {
  height: auto !important;
  min-height: 100vh !important;
  overflow-y: visible !important;
}

.main-grid {
  height: auto !important;
  min-height: auto !important;
  align-items: start !important;
  overflow: visible !important;
}

.left-col {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.right-col {
  height: auto !important;
  min-height: auto !important;
  overflow: visible !important;
}

.left-col .panel {
  flex: 0 0 auto !important;
  min-height: auto !important;
  height: auto !important;
}

.left-col .panel-body {
  flex: 0 0 auto !important;
  min-height: auto !important;
  height: auto !important;
  overflow: visible !important;
}