/* ============================================
   SkyListen — Dark Theme Flight Tracker
   ============================================ */

:root {
  --bg: #080c12;
  --bg-panel: rgba(12, 18, 28, 0.85);
  --bg-card: rgba(20, 30, 48, 0.6);
  --bg-hover: rgba(0, 212, 255, 0.08);
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.3);
  --accent-glow: rgba(0, 212, 255, 0.15);
  --orange: #ff8c00;
  --orange-dim: rgba(255, 140, 0, 0.3);
  --green: #00e676;
  --green-dim: rgba(0, 230, 118, 0.3);
  --red: #ff4444;
  --yellow: #ffd740;
  --text: #e0e8f0;
  --text-dim: rgba(224, 232, 240, 0.5);
  --text-muted: rgba(224, 232, 240, 0.3);
  --border: rgba(224, 232, 240, 0.08);
  --font-mono: 'Share Tech Mono', monospace;
  --font-body: 'Barlow', -apple-system, sans-serif;
  --panel-width: 320px;
  --header-height: 48px;
}

body.light-mode {
  --bg: #f0f2f5;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-card: rgba(230, 235, 242, 0.6);
  --bg-hover: rgba(21, 101, 192, 0.08);
  --accent: #1565c0;
  --accent-dim: rgba(21, 101, 192, 0.3);
  --accent-glow: rgba(21, 101, 192, 0.15);
  --text: #1a1a2e;
  --text-dim: rgba(26, 26, 46, 0.6);
  --text-muted: rgba(26, 26, 46, 0.35);
  --border: rgba(26, 26, 46, 0.12);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* ---- Loading Screen ---- */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  position: relative;
}

.radar-ring {
  width: 120px;
  height: 120px;
  border: 2px solid var(--accent-dim);
  border-radius: 50%;
  margin: 0 auto 24px;
  animation: radar-pulse 2s ease-out infinite;
}

.radar-ring-2 {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  animation-delay: 1s;
}

@keyframes radar-pulse {
  0% { transform: translateX(-50%) scale(0.3); opacity: 1; }
  100% { transform: translateX(-50%) scale(1.5); opacity: 0; }
}

.radar-ring:first-child {
  animation-name: radar-pulse-first;
}

@keyframes radar-pulse-first {
  0% { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.loading-title {
  font-family: var(--font-mono);
  font-size: 28px;
  letter-spacing: 8px;
  color: var(--accent);
  margin-bottom: 8px;
}

.loading-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ---- Header ---- */

#header {
  height: var(--header-height);
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  position: relative;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 4px;
  color: var(--accent);
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  letter-spacing: 1px;
}

.header-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.header-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.header-btn:active {
  transform: scale(0.95);
}

.header-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.header-btn.spinning svg {
  animation: spin 0.8s linear;
}

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

.live-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--green);
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--green-dim); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px transparent; }
}

.live-status.demo .status-dot {
  background: var(--yellow);
}

.live-status.demo .status-text {
  color: var(--yellow);
}

/* ---- Main Layout ---- */

#main {
  display: flex;
  height: calc(100vh - var(--header-height));
  position: relative;
}

/* ---- Map ---- */

#map {
  flex: 1;
  z-index: 1;
}

/* Google Maps dark theme controls */
.gm-style .gm-control-active {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
}

.gm-style .gm-control-active:hover {
  background: var(--bg-card) !important;
  color: var(--accent) !important;
}

.gm-style .gmnoprint,
.gm-style .gm-style-cc {
  opacity: 0.5;
}

/* Aircraft icon hover */
.aircraft-icon {
  transition: transform 0.15s ease;
  cursor: pointer;
}

.aircraft-icon:hover {
  transform: scale(1.2);
}

/* Callsign hover tooltip */
.map-tooltip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #1a1a2e;
  white-space: nowrap;
  padding: 0;
}

/* Strip InfoWindow chrome — arrow + padding + close button */
.gm-style-iw-c {
  padding: 6px 10px !important;
  padding-top: 6px !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  max-height: none !important;
}

/* Remove the top spacer that reserves room for the close button */
.gm-style-iw-chr {
  display: none !important;
}

.gm-style-iw-d {
  overflow: hidden !important;
  padding: 0 !important;
}

/* Hide the close button */
.gm-style-iw-c button.gm-ui-hover-effect {
  display: none !important;
}

/* Smaller arrow */
.gm-style-iw-tc {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* ---- Panel ---- */

.panel {
  width: var(--panel-width);
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---- Flight Card ---- */

.flight-content {
  min-height: 120px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
  gap: 12px;
}

.empty-plane {
  color: var(--text-muted);
}

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, rgba(30, 45, 65, 0.6) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Flight data display */
.flight-callsign {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.flight-country {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.flight-data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.data-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.data-value {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
  line-height: 1;
}

.data-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
}

.flight-phase-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.phase-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.phase-ground { background: rgba(255, 215, 64, 0.15); color: var(--yellow); border: 1px solid rgba(255, 215, 64, 0.3); }
.phase-departing { background: rgba(0, 230, 118, 0.15); color: var(--green); border: 1px solid rgba(0, 230, 118, 0.3); }
.phase-approach { background: rgba(0, 212, 255, 0.15); color: var(--accent); border: 1px solid rgba(0, 212, 255, 0.3); }
.phase-enroute { background: rgba(224, 232, 240, 0.08); color: var(--text-dim); border: 1px solid var(--border); }

.flight-facility {
  font-size: 13px;
  color: var(--text-dim);
}

.flight-facility strong {
  color: var(--text);
  font-weight: 500;
}

.flight-mount {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.flight-aircraft-info {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flight-aircraft-type {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* ---- Route Display ---- */

.flight-route {
  margin-top: 8px;
}

.flight-route-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.flight-route-airport {
  text-align: center;
  flex: 1;
}

.flight-route-code {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--text);
  letter-spacing: 2px;
  font-weight: 500;
}

.flight-route-city {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.flight-route-plane {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  color: var(--orange);
}

.flight-route-plane svg {
  width: 22px;
  height: 22px;
}

/* Progress bar */
.flight-progress {
  margin-top: 10px;
  position: relative;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: visible;
}

.flight-progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 2px;
  position: relative;
  transition: width 0.5s ease;
}

.flight-progress-plane {
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text);
  line-height: 0;
}

.flight-progress-plane svg {
  width: 16px;
  height: 16px;
}

.flight-progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.flight-progress-remaining {
  text-align: right;
}

.flight-photo {
  margin-bottom: 12px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  background: var(--bg-card);
}

.flight-photo img {
  width: 100%;
  display: block;
}

.flight-photo-credit {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 6px;
  border-top-left-radius: 4px;
}

.flight-photo-credit a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.flight-photo-credit a:hover {
  text-decoration: underline;
}

/* Flight card transition */
.flight-content.transitioning {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.flight-content.entering {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ---- Audio Player ---- */

.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.play-btn:not(:disabled):hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--accent-glow);
  box-shadow: 0 0 16px var(--accent-glow);
}

.play-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
  flex-shrink: 0;
}

.wave-bar {
  width: 3px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: background 0.3s ease;
}

.waveform.active .wave-bar {
  background: var(--accent);
  animation: wave 0.8s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }
.wave-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes wave {
  0%, 100% { height: 6px; }
  50% { height: 24px; }
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--text-muted);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 64px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-dim);
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-dim);
}

.player-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.player-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.player-dot.live {
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

.player-dot.connecting {
  background: var(--accent);
  animation: blink 0.6s ease-in-out infinite;
}

.player-dot.error {
  background: var(--red);
}

.player-dot.paused {
  background: var(--text-muted);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ---- Quick Tune ---- */

.quick-tune-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.qt-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.qt-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.qt-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), inset 0 0 12px var(--accent-glow);
}

.qt-name {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qt-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Quick Jump ---- */

.quick-jump-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.qj-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.qj-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.qj-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow), inset 0 0 12px var(--accent-glow);
}

.qj-icao {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  letter-spacing: 1px;
}

.qj-name {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Panel Footer ---- */

.panel-footer {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: auto;
}

/* ---- Panel Toggle (mobile) ---- */

.panel-toggle {
  display: none;
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.panel-toggle:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.panel-toggle svg {
  transition: transform 0.3s ease;
}

.panel-toggle.open svg {
  transform: rotate(180deg);
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .panel {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .panel.open {
    transform: translateX(0);
  }

  .panel-toggle {
    display: flex;
  }
}

/* ---- Arrival/Departure Board ---- */

.section-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.board-airport-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 1px;
}

.board-notify-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.board-notify-btn:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.board-notify-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

.board-content {
  max-height: 240px;
  overflow-y: auto;
}

.board-content::-webkit-scrollbar {
  width: 3px;
}

.board-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.board-table th {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-align: left;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  font-weight: 400;
}

.board-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.board-row:hover {
  background: var(--bg-hover);
}

.board-row td {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 6px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.board-row td:first-child {
  color: var(--text);
}

.board-phase {
  font-size: 9px;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.board-phase-ground { background: rgba(255, 215, 64, 0.15); color: var(--yellow); }
.board-phase-departing { background: rgba(0, 230, 118, 0.15); color: var(--green); }
.board-phase-approach { background: rgba(0, 212, 255, 0.15); color: var(--accent); }

.board-empty {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

/* ---- Scrollbar ---- */

.panel::-webkit-scrollbar {
  width: 4px;
}

.panel::-webkit-scrollbar-track {
  background: transparent;
}

.panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.panel::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
