/* =====================================================
   SKYGLASS — Global Tracker Styles
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #020817;
  --surface:     rgba(10, 20, 40, 0.72);
  --border:      rgba(56, 189, 248, 0.18);
  --accent:      #38bdf8;
  --accent-dim:  rgba(56, 189, 248, 0.15);
  --accent2:     #818cf8;
  --accent2-dim: rgba(129, 140, 248, 0.15);
  --accent3:     #f59e0b;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --radius:      14px;
  --blur:        18px;
  --font:        'Outfit', system-ui, sans-serif;
  --trans:       all 0.25s cubic-bezier(.4,0,.2,1);
}

html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); font-family: var(--font); color: var(--text); }

/* =============== MAP =============== */
#map { position: fixed; inset: 0; z-index: 1; }
.leaflet-container { background: #020817 !important; }

/* =============== HEADER =============== */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px;
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--border);
}

#header-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.1rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
}

#header-stats {
  display: flex; align-items: center; gap: 22px;
  flex: 1;
}

.stat-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.82rem;
}
.stat-icon { font-size: 1rem; opacity: 0.75; }
.stat-value { font-weight: 600; color: var(--accent); font-size: 0.92rem; min-width: 34px; }
.stat-label { color: var(--text-muted); }

.pulse-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.8); }
}

/* =============== LAYER TOGGLES =============== */
#layer-toggles {
  display: flex; gap: 8px; flex-shrink: 0;
}
.toggle-btn {
  padding: 5px 13px; border-radius: 20px; font-family: var(--font);
  font-size: 0.78rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border);
  background: transparent; color: var(--text-muted);
  transition: var(--trans);
}
.toggle-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.toggle-btn[data-layer="satellites"].active {
  background: var(--accent2-dim);
  border-color: var(--accent2);
  color: var(--accent2);
}
.toggle-btn:hover { opacity: 0.85; }

/* =============== DETAIL PANEL =============== */
#detail-panel {
  position: fixed; top: 70px; right: 20px;
  width: 280px;
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  z-index: 200;
  transition: var(--trans);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
#detail-panel.hidden { opacity: 0; pointer-events: none; transform: translateX(20px); }

#panel-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1rem; transition: var(--trans);
}
#panel-close:hover { color: var(--accent); }

#panel-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
}
#panel-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  background: var(--accent-dim); flex-shrink: 0;
}
#panel-icon.satellite { background: var(--accent2-dim); }

#panel-callsign { font-size: 1.05rem; font-weight: 700; color: var(--text); }
#panel-subtitle  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

#panel-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.panel-data-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 9px;
  padding: 10px;
}
.panel-data-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 4px; }
.panel-data-value { font-size: 0.92rem; font-weight: 600; color: var(--text); }

/* =============== MAP MARKERS =============== */
.flight-icon, .sat-icon {
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: transform 0.15s ease;
  filter: drop-shadow(0 0 4px rgba(56,189,248,0.7));
  cursor: pointer;
}
.sat-icon {
  filter: drop-shadow(0 0 5px rgba(129,140,248,0.8));
  font-size: 13px;
}
.flight-icon:hover, .sat-icon:hover { transform: scale(1.4); }

/* =============== LOADING OVERLAY =============== */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.7s ease;
}
#loading-overlay.fade-out { opacity: 0; pointer-events: none; }

#loading-content {
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
#loading-logo { animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading-title {
  font-size: 2rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: 0.06em;
}
#loading-sub { color: var(--text-muted); font-size: 0.88rem; }
#loading-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid rgba(56,189,248,0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
#loading-steps { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.load-step {
  font-size: 0.8rem; color: var(--text-muted);
  transition: color 0.3s;
  text-align: left;
}
.load-step.done { color: #22c55e; }

/* =============== LEAFLET POPUP OVERRIDE =============== */
.leaflet-popup-content-wrapper {
  background: rgba(10, 20, 40, 0.92) !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  color: var(--text) !important;
  font-family: var(--font) !important;
  box-shadow: 0 4px 30px rgba(0,0,0,.6) !important;
}
.leaflet-popup-tip { background: rgba(10,20,40,0.92) !important; }
.leaflet-popup-content { font-size: 0.82rem !important; line-height: 1.6 !important; }

/* =============== RESPONSIVE =============== */
@media (max-width: 600px) {
  #header-stats .stat-label { display: none; }
  #header { gap: 10px; padding: 8px 12px; }
  #detail-panel { width: calc(100vw - 28px); right: 14px; top: 64px; }
  #layer-toggles { display: none; }
}
