/* ============================================================
   Spectral Glimpse — styles
   Dark techy theme
   ============================================================ */

/* ---- Reset + base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  overflow: hidden;
}

/* ---- App shell ---- */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* ---- Map ---- */
#map {
  flex: 1;
  height: 100%;
  background: #1a1f2e;
  cursor: crosshair;
}

/* Leaflet dark overrides */
.leaflet-container { background: #1a1f2e; }
.leaflet-control-zoom a {
  background: #13161f !important;
  color: #94a3b8 !important;
  border-color: rgba(255,255,255,0.08) !important;
}
.leaflet-control-zoom a:hover {
  background: #1a1f2e !important;
  color: #e2e8f0 !important;
}
.leaflet-control-attribution {
  background: rgba(15,17,23,0.7) !important;
  color: #334155 !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: #475569 !important; }

/* ---- Map UI overlays ---- */
#map-label {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1000;
  background: rgba(15,17,23,0.88);
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 9px 13px;
  pointer-events: none;
}
#map-label .title {
  font-size: 22px;
  font-weight: 500;
  color: #e2e8f0;
  letter-spacing: -0.01em;
}
#map-label .tagline {
  font-size: 10px;
  color: #475569;
  margin-top: 2px;
}

#click-hint {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(15,17,23,0.85);
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  transition: opacity 0.3s;
  pointer-events: none;
}
#click-hint.hidden { opacity: 0; }

/* Click marker */
.click-marker-dot {
  width: 12px;
  height: 12px;
  background: #38bdf8;
  border: 2px solid #fff;
  border-radius: 50%;
  position: relative;
}
.click-marker-dot::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  border: 1.5px solid rgba(56,189,248,0.4);
  border-radius: 50%;
  animation: ring 2s infinite;
}
@keyframes ring {
  0%,100% { opacity: 0.6; transform: translate(-50%,-50%) scale(1); }
  50%      { opacity: 0.1; transform: translate(-50%,-50%) scale(1.4); }
}

/* ---- Sidebar ---- */
#sidebar {
  width: 320px;
  height: 100%;
  background: #13161f;
  border-left: 0.5px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 900;
  flex-shrink: 0;
}
#sidebar.open { transform: translateX(0); }

/* Sidebar header */
#sidebar-header {
  padding: 14px 16px 12px;
  border-bottom: 0.5px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
#sidebar-coords {
  font-size: 10px;
  color: #475569;
  font-family: "SF Mono", "Fira Code", monospace;
  margin-bottom: 3px;
}
#sidebar-location {
  font-size: 14px;
  font-weight: 500;
  color: #e2e8f0;
}
#sidebar-date {
  display: inline-block;
  margin-top: 6px;
  background: rgba(56,189,248,0.1);
  border: 0.5px solid rgba(56,189,248,0.25);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  color: #38bdf8;
}

/* Loading state */
#sidebar-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: #334155;
  font-size: 13px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(56,189,248,0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards scroll area */
#cards-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
#cards-scroll::-webkit-scrollbar { width: 3px; }
#cards-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}

/* Index card */
.index-card {
  background: #1a1f2e;
  border: 0.5px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  transition: border-color 0.2s;
}
.index-card:hover {
  border-color: rgba(255,255,255,0.14);
}

.card-name {
  font-size: 10px;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.card-body {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.gauge-side { flex-shrink: 0; }
.spark-side { flex: 1; min-width: 0; }

.card-interp {
  font-size: 10px;
  color: #475569;
  line-height: 1.55;
  border-top: 0.5px solid rgba(255,255,255,0.05);
  padding-top: 6px;
}

/* Sidebar footer */
#sidebar-footer {
  padding: 9px 16px;
  border-top: 0.5px solid rgba(255,255,255,0.07);
  font-size: 10px;
  color: #1e293b;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#sidebar-footer a {
  color: #334155;
  text-decoration: none;
}
#sidebar-footer a:hover { color: #475569; }

/* ---- Error state ---- */
.error-msg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-size: 12px;
  color: #475569;
  text-align: center;
  line-height: 1.6;
}

/* ---- Responsive — narrow screens ---- */
@media (max-width: 600px) {
  #sidebar {
    position: absolute;
    right: 0; top: 0;
    height: 100%;
    width: 100%;
    max-width: 340px;
  }
}

/* ---- Modal overlay ---- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#modal {
  background: #13161f;
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  width: min(560px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
#modal-overlay.open #modal {
  transform: scale(1);
}

#modal::-webkit-scrollbar { width: 3px; }
#modal::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}

#modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.06);
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
  line-height: 1;
}
#modal-close:hover {
  background: rgba(255,255,255,0.12);
  color: #e2e8f0;
}

#modal-index-name {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
#modal-index-label {
  font-size: 22px;
  font-weight: 500;
  color: #e2e8f0;
  margin-bottom: 6px;
}
#modal-description {
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.07);
}

.modal-gauges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 20px;
}
.modal-gauge-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.modal-gauge-sublabel {
  font-size: 10px;
  color: #475569;
}

#modal-chart-wrap {
  background: #1a1f2e;
  border: 0.5px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}
#modal-chart-title {
  font-size: 10px;
  color: #475569;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

.modal-trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 14px;
}
.trend-up   { background: rgba(74,222,128,0.1);  border: 0.5px solid rgba(74,222,128,0.25);  color: #4ade80; }
.trend-down { background: rgba(251,146,60,0.1);  border: 0.5px solid rgba(251,146,60,0.25);  color: #fb923c; }
.trend-flat { background: rgba(148,163,184,0.1); border: 0.5px solid rgba(148,163,184,0.25); color: #94a3b8; }

#modal-interpretation {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.65;
  background: #1a1f2e;
  border: 0.5px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px;
}
#modal-interpretation .interp-label {
  font-size: 10px;
  color: #475569;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
