/* ===========================
   2026 Theme Variables
   =========================== */
:root {
  --bg-deep: #030508;
  --bg-surface: #0b101a;
  --card-glass: rgba(20, 25, 40, 0.6);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #3b82f6; /* Electric Blue */
  --accent-glow: rgba(59, 130, 246, 0.3);
  --success: #10b981;
  --radius: 20px;

  /* Radar Palette */
  --radar-accent: #ffaa33;
  --radar-accent-strong: #ff9900;
  --radar-glass: #050505;
}

/* ===========================
   Base & Typography
   =========================== */
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-deep);
  /* Subtle Vignette & Gradient */
  background-image:
    radial-gradient(circle at 50% 0%, #172033 0%, transparent 60%),
    radial-gradient(circle at 80% 10%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 24px; }
h2 { font-size: 20px; color: var(--text-main); margin-bottom: 12px; }
h3 { font-size: 16px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 16px; }

a { text-decoration: none; color: inherit; transition: opacity 0.2s; }
a:hover { opacity: 0.8; }

/* ===========================
   Components: Glass Card
   =========================== */
.glass-panel {
  background: var(--card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.2);
}

/* ===========================
   Header & Controls
   =========================== */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo { width: 40px; height: 40px; border-radius: 10px; }

/* The Control Bar Container */
.controls-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px;
  width: 100%; /* Ensure bar takes full width available */
}

/* ===========================
   Pill / Input Styling
   =========================== */
.pill-input {
  width: 100%;
  box-sizing: border-box;
  appearance: none;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  /* CRITICAL FIX: Forces native dropdowns to be dark */
  color-scheme: dark;

  /* Add a custom arrow icon for selects */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 32px; /* Space for the arrow */
}

/* Remove arrow for text inputs (like Date) */
input[type="text"].pill-input {
  background-image: none;
  padding-right: 16px;
}

.pill-input:hover {
  background-color: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

.pill-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Style the internal dropdown items (Chrome/Firefox/Edge) */
.pill-input option {
  background-color: #0b101a; /* Dark background */
  color: #f1f5f9;            /* Light text */
  padding: 10px;
}

/* Responsive constraints */
.control-group {
  position: relative;
  flex-grow: 1;
  min-width: 140px; /* Prevent selects from becoming too narrow */
}

/* Date input needs more space */
.control-group:has(#range) {
  flex-grow: 3;
  min-width: 220px;
}

/* Mobile Adjustment for Controls */
@media (max-width: 700px) {
  /* 1. Stack controls vertically */
  .controls-bar {
    flex-direction: column;
    align-items: stretch; /* Force items to fill width */
    gap: 12px; /* More space between buttons on mobile */
  }

  /* 2. Force groups to be full width */
  .control-group {
    width: 100% !important;
    min-width: 100% !important;
    flex: none; /* Disable flex scaling */
  }

  /* 3. Make inputs bigger and cleaner */
  .pill-input {
    width: 100%;
    font-size: 16px; /* Prevents iOS auto-zoom & improves readability */
    padding: 12px 16px; /* Larger touch target */
    background-position: right 16px center; /* Move arrow slightly left */
  }

  /* Ensure the update button is also full width and easy to tap */
  .btn-action {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    margin-top: 4px;
  }
}

/* Primary Button */
.btn-action {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--accent-glow);
  transition: transform 0.1s;
  white-space: nowrap;
}
.btn-action:active { transform: scale(0.96); }

/* ===========================
   Bento Grid Layout
   =========================== */
.bento-grid {
  display: grid;
  grid-template-columns: 2fr 1fr; /* Map takes 2/3, Sidebar 1/3 */
  gap: 24px;
}

@media (max-width: 900px) {
  .bento-grid { grid-template-columns: 1fr; }
}

/* Map Container */
#map {
  height: 500px;
  width: 100%;
  border-radius: var(--radius);
  background: #050505;
  /* Fix layout stacking context */
  isolation: isolate;
}

/* ===========================
   Tabbed Sidebar
   =========================== */
.tab-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.tab-btn.active {
  background: rgba(59, 130, 246, 0.15); /* Tinted Accent */
  color: var(--accent);
  border: 1px solid var(--accent-glow);
}

.tab-content {
  display: none;
  animation: fade-in 0.2s ease-out;
}

.tab-content.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===========================
   Rank Lists (Tiles)
   =========================== */
.rank-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

/* Dynamic border on the left based on score color */
.rank-tile::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--col);
  opacity: 0.8;
}

.rank-tile:hover {
  background: rgba(255,255,255,0.05);
  transform: translateX(4px);
}

.tile-content { flex: 1; min-width: 0; }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; }
.tile-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-score { font-family: 'Roboto Mono', monospace; font-size: 12px; color: var(--col); }

.tile-badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.mini-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}

/* ===========================
   Charts & Stats
   =========================== */
.chart-container {
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 320px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.region-title { font-size: 18px; font-weight: 700; color: white; }
.region-subtitle { font-size: 13px; color: var(--text-muted); }

/* ===========================
   Daily Grid (Horizontal Scroll)
   =========================== */
.daily-scroller {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none; /* Firefox */
  min-height: 200px;
}
.daily-scroller::-webkit-scrollbar { display: none; }

.daily-card {
  width: 220px;
  flex-shrink: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* ===========================
   Footer & Social
   =========================== */
.footer-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-top: 1px solid var(--border-glass);
  padding-top: 24px;
  margin-top: 24px;
  gap: 20px;
}

.social-links { display: flex; gap: 12px; }
.social-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  transition: 0.2s;
  color: var(--text-main);
}
.social-icon:hover { background: var(--text-main); color: var(--bg-deep); }
.social-icon svg { width: 16px; height: 16px; }

/* ===========================
   Leaflet/Map Overrides
   =========================== */
.leaflet-container { background: #050505 !important; font-family: inherit; }
.leaflet-popup-content-wrapper {
  background: rgba(11, 16, 26, 0.95);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
}
.leaflet-popup-tip { background: var(--bg-surface); }

/* Fix Leaflet Marker Visibility */
.leaflet-div-icon {
  background: transparent !important;
  border: none !important;
}

/* Ensure inner marker fills the Leaflet container */
.sr-marker {
  width: 100%;
  height: 100%;
  display: block;
  box-sizing: border-box;
  border: 2px solid #0b1020; /* Dark border to contrast with map */
  opacity: 1.0;
  z-index: 1000; /* Force on top of any radar effects */
}

/* Force Circle Shape */
.sr-circle .sr-circle-inner { border-radius: 50% !important; }

/* Force Square Shape (with slight rounded corners) */
.sr-square .sr-square-inner { border-radius: 4px !important; }

/* Base Location Marker */
.sr-base-pin {
  background: transparent !important;
  border: none !important;
}

.sr-base-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3b82f6; /* Accent color */
  border: 2px solid #fff;
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
  box-sizing: border-box;
}

/* ===========================
   Radar Mode (Overlay)
   =========================== */
#map.radar{
  position: relative;
  overflow: hidden;
  background: var(--radar-glass);
  box-shadow:
    0 0 0 2px #2a1a07 inset,
    0 0 35px 8px color-mix(in srgb, var(--radar-accent) 60%, transparent) inset,
    0 0 50px 10px #1a0d03;
}

#map.radar .leaflet-pane.leaflet-tile-pane{
  opacity: .7;
  filter: brightness(.9) saturate(.95);
}

/* UI container */
#map.radar .radar-ui{
  position:absolute; inset:0; pointer-events:none;
  /* Z-index handled by Leaflet Pane in JS now, but keeping this safe */
  z-index: 350;
}

/* Concentric rings */
#map.radar .radar-rings {
  position:absolute; inset:0;
  background: repeating-radial-gradient(circle at 50% 50%,
    color-mix(in srgb, var(--radar-accent) 25%, transparent) 0px,
    transparent 1px, transparent 6%);
  mix-blend-mode: screen;
  opacity:.75;
}

/* Crosshair */
#map.radar .radar-cross{
  position:absolute; inset:0;
  background:
    linear-gradient(color-mix(in srgb, var(--radar-accent) 25%, transparent) 0 0) 50% 0/1px 100% no-repeat,
    linear-gradient(color-mix(in srgb, var(--radar-accent) 25%, transparent) 0 0) 0 50%/100% 1px no-repeat;
  mix-blend-mode: screen;
}

#map.radar .radar-sweep {
  position: absolute;

  /* The Gradient (Orange, More Transparent) */
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 280deg,
    color-mix(in srgb, var(--radar-accent) 20%, transparent) 320deg,       /* Tail: Was 40%, now 20% */
    color-mix(in srgb, var(--radar-accent-strong) 65%, transparent) 358deg,/* Peak: Was 95%, now 65% */
    transparent 360deg
  );

  /* Radial Mask */
  -webkit-mask-image: radial-gradient(circle at center, black 0%, black 35%, transparent 75%);
  mask-image: radial-gradient(circle at center, black 0%, black 35%, transparent 75%);

  filter: blur(1px);
  animation: sr-radar-rotate 20s linear infinite;

  mix-blend-mode: screen;
  pointer-events: none;
}

@keyframes sr-radar-rotate { to { transform: rotate(360deg); } }

/* Vignette */
#map.radar .radar-vignette{
  position:absolute; inset:0;
  background: radial-gradient(closest-corner at 50% 50%,
              transparent 0 98%,
              rgba(0,0,0,.28) 100%);
  pointer-events:none;
}

/* Marker Animation (Pulse) */
.sr-anim.sr-marker { animation: sr-breathe 3s ease-in-out infinite; }

@keyframes sr-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.0); }
  50%      { box-shadow: 0 0 10px 2px rgba(59,130,246,0.4); }
}

