/* ================================
   BASE STYLES
=================================== */
* {
  box-sizing: border-box;
}

:root {
  --bg: #f2efe8;
  --panel: #ffffff;
  --panel-muted: #f8f4ed;
  --ink: #1c1b19;
  --muted: #6b6760;
  --brand: #1f4e5f;
  --brand-light: #2f7f90;
  --accent-jump: #e08c3a;
  --accent-winds: #2a7f9d;
  --accent-air: #2a9d8f;
  --good: #2f7d32;
  --warn: #d07a2b;
  --bad: #c3473a;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', 'Space Grotesk', system-ui, sans-serif;
  display: flex;
  height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

/* ================================
   SIDEBAR
=================================== */
#sidebar {
  width: 340px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, var(--panel-muted) 0%, var(--panel) 100%);
  border-radius: 0;
  overflow: hidden;
  box-shadow: 2px 0 10px rgba(28, 27, 25, 0.08);
}

/* Header */
.sidebar-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: white;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(31, 78, 95, 0.35);
}

.sidebar-header h1 {
  margin: 0 0 4px 0;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-family: 'Space Grotesk', 'IBM Plex Sans', system-ui, sans-serif;
}

.tagline {
  font-size: 0.75rem;
  opacity: 0.9;
  font-weight: 300;
}

/* Content */
.sidebar-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* ================================
   STATUS STRIP
=================================== */
.status-strip {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.95));
  border-bottom: 1px solid rgba(28, 27, 25, 0.08);
  flex-wrap: wrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: space-between;
}

.status-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

/* ================================
   CARDS
=================================== */
.card {
  background: var(--panel);
  border-radius: 8px;
  padding: 0;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(28, 27, 25, 0.08);
  border-left: 3px solid var(--brand-light);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.card-jump-run {
  border-left-color: var(--accent-jump);
}

.card-winds {
  border-left-color: var(--accent-winds);
}

.card-aircraft {
  border-left-color: var(--accent-air);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid rgba(28, 27, 25, 0.08);
  background: linear-gradient(to bottom, var(--panel-muted), var(--panel));
}

.card-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  flex: 1;
}

.card-body {
  padding: 12px;
}

/* ================================
   DROPZONE
=================================== */
.dz-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(195, 71, 58, 0.2);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.2);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(244, 67, 54, 0.1);
  }
}

/* ================================
   JUMP RUN
=================================== */
.jump-run-display {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: white;
  padding: 12px;
  border-radius: 6px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(31, 78, 95, 0.25);
  margin-bottom: 10px;
}

.jump-run-display:last-of-type {
  margin-bottom: 0;
}

.jump-run-main {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
  line-height: 1;
}

.jump-run-label {
  font-size: 0.7rem;
  opacity: 0.9;
  margin-top: 4px;
  font-weight: 300;
  letter-spacing: 1px;
}

/* ================================
   WINDS TABLE
=================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

thead {
  background: linear-gradient(to bottom, var(--panel-muted), #efe9e1);
}

th {
  padding: 5px 8px;
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
  border-bottom: 2px solid rgba(28, 27, 25, 0.15);
}

td {
  padding: 4px 8px;
  text-align: right;
  border-bottom: 1px solid rgba(28, 27, 25, 0.06);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.6);
}

tbody tr:hover {
  background: rgba(47, 127, 144, 0.12);
}

tbody tr.altitude-highlight {
  background: rgba(224, 140, 58, 0.18) !important;
  font-weight: 600;
}

/* Wind direction arrow */
.wind-dir {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wind-arrow {
  font-size: 0.9rem;
}

/* Wind speed color coding */
.wind-speed-low {
  color: var(--good);
  font-weight: 600;
}

.wind-speed-med {
  color: var(--warn);
  font-weight: 600;
}

.wind-speed-high {
  color: var(--bad);
  font-weight: 600;
}

/* Wind speed bar */
.wind-speed-cell {
  position: relative;
  padding-bottom: 10px;
}

.wind-speed-value {
  position: relative;
  z-index: 1;
}

.wind-speed-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 4px;
  height: 4px;
  border-radius: 999px;
  opacity: 0.7;
  transform-origin: left center;
  transform: scaleX(0);
}

.wind-speed-cell.wind-speed-low .wind-speed-bar {
  background: linear-gradient(90deg, rgba(47, 125, 50, 0.3), rgba(47, 125, 50, 0.9));
}

.wind-speed-cell.wind-speed-med .wind-speed-bar {
  background: linear-gradient(90deg, rgba(208, 122, 43, 0.3), rgba(208, 122, 43, 0.9));
}

.wind-speed-cell.wind-speed-high .wind-speed-bar {
  background: linear-gradient(90deg, rgba(195, 71, 58, 0.3), rgba(195, 71, 58, 0.9));
}

/* ================================
   AIRCRAFT
=================================== */
.aircraft-display {
  margin-top: 8px;
  padding: 10px;
  background: rgba(42, 157, 143, 0.12);
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.aircraft-display strong {
  color: var(--accent-air);
  font-size: 0.85rem;
}

.aircraft-icon {
  font-size: 20px;
  line-height: 20px;
  text-align: center;
  background: transparent !important;
  border: none !important;
}

.aircraft-icon-inner {
  font-size: 24px;
  line-height: 24px;
  text-shadow: 0 0 6px rgba(42, 157, 143, 1),
               0 2px 4px rgba(0, 0, 0, 0.8);
  filter: drop-shadow(0 0 4px rgba(42, 157, 143, 0.8));
  transition: transform 2s linear;
  display: inline-block;
}

/* ================================
   UTILITY CLASSES
=================================== */
.small {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

.timestamp {
  font-size: 0.7rem;
  color: #8d877f;
  margin-top: 8px;
  text-align: center;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-top: 4px;
}

.status-good {
  background: rgba(47, 125, 50, 0.15);
  color: var(--good);
}

.status-warning {
  background: rgba(208, 122, 43, 0.18);
  color: var(--warn);
}

.status-neutral {
  background: rgba(110, 106, 97, 0.15);
  color: #5e5a54;
}

.hidden {
  display: none !important;
}

/* ================================
   ERROR BANNER
=================================== */
.error-banner {
  padding: 8px 10px;
  margin: 8px 16px;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.4;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-banner.error {
  background: rgba(195, 71, 58, 0.15);
  border-left: 3px solid var(--bad);
  color: #8a2e28;
}

.error-banner.warning {
  background: rgba(208, 122, 43, 0.15);
  border-left: 3px solid var(--warn);
  color: #9c4f12;
}

.error-banner.info {
  background: rgba(47, 127, 144, 0.16);
  border-left: 3px solid var(--brand-light);
  color: #11414c;
}

.error-banner.success {
  background: rgba(47, 125, 50, 0.15);
  border-left: 3px solid var(--good);
  color: #1f5a2f;
}

/* ================================
   LOADING SPINNER
=================================== */
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(28, 27, 25, 0.2);
  border-top-color: var(--brand-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 6px;
  vertical-align: middle;
}

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

/* ================================
   MAP
=================================== */
#map {
  flex: 1;
}

/* Smooth aircraft position transitions */
.leaflet-marker-icon.aircraft-icon {
  transition: transform 2s linear;
}

/* Traffic dots use JavaScript interpolation for smooth movement */

/* Enhanced jump run styling */
.jump-run-glow {
  filter: blur(2px);
}

.jump-run-main {
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.25));
}

/* Custom Dropzone Marker */
.dz-marker-icon {
  background: transparent !important;
  border: none !important;
}

.dz-marker-outer {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dz-marker-outer::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(244, 67, 54, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: dzPulse 2s ease-out infinite;
}

.dz-marker-inner {
  font-size: 28px;
  line-height: 28px;
  text-shadow: 0 0 8px rgba(244, 67, 54, 0.8),
               0 2px 4px rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 0 4px rgba(244, 67, 54, 1));
  z-index: 1;
}

@keyframes dzPulse {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.5;
  }
  100% {
    transform: scale(0.8);
    opacity: 1;
  }
}

/* Traffic markers with subtle glow */
.traffic-marker {
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.6));
}

/* Enhanced jump plane trail */
.jump-plane-trail {
  filter: drop-shadow(0 0 3px rgba(42, 157, 143, 0.8));
}

/* ================================
   RESPONSIVE DESIGN - MOBILE FIRST
=================================== */

/* Very small phones (320px - 480px) */
@media (max-width: 480px) {
  /* Reduce all padding/spacing */
  .sidebar-content { padding: 12px; }
  .card { padding: 8px; margin-bottom: 8px; }

  /* Scale down typography */
  .sidebar-header h1 { font-size: 1.1rem; }
  .sidebar-header p { font-size: 0.75rem; }
  .jump-run-main { font-size: 1.4rem; }
  .jump-run-label { font-size: 0.7rem; }

  /* Optimize sidebar height */
  #sidebar { max-height: 40vh; }
  #map { min-height: 60vh; }

  /* Table optimizations */
  table { font-size: 0.75rem; }
  td { padding: 3px 6px; }
}

/* Small phones and phablets (481px - 640px) */
@media (max-width: 640px) {
  .sidebar-content { padding: 14px; }
  .card { padding: 10px; margin-bottom: 10px; }

  .sidebar-header h1 { font-size: 1.2rem; }
  .jump-run-main { font-size: 1.6rem; }

  #sidebar { max-height: 45vh; }
  #map { min-height: 55vh; }
}

/* Tablets and large phones (641px - 768px) */
@media (max-width: 768px) {
  body { flex-direction: column; }

  #sidebar {
    width: 100% !important;
    max-width: 100%;
    max-height: 50vh;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  #map {
    flex: 1;
    min-height: 50vh;
  }

  .sidebar-header {
    border-radius: 0;
  }

  .card {
    margin-left: 0;
    margin-right: 0;
  }
}

/* Landscape mobile devices */
@media (max-width: 768px) and (orientation: landscape) {
  #sidebar {
    max-height: 40vh;  /* Reduce sidebar in landscape */
  }

  #map {
    min-height: 60vh;  /* More space for map */
  }

  /* Make cards more compact in landscape */
  .card { padding: 8px; margin-bottom: 8px; }
  .sidebar-content { padding: 12px; }
}

/* Small tablets and large phones landscape (769px - 1024px) */
@media (max-width: 1024px) {
  #sidebar {
    width: 300px;  /* Slightly narrower sidebar */
  }

  /* Slightly reduce padding on medium screens */
  .sidebar-content { padding: 14px; }
  .card { padding: 11px; }
}

/* Desktop (1025px+) */
@media (min-width: 1025px) {
  #sidebar {
    width: 340px;  /* Full sidebar width */
  }
}

/* Table overflow protection for very narrow screens */
@media (max-width: 375px) {
  table {
    min-width: 280px;  /* Prevent table from becoming too cramped */
  }
}
