/* BPFRG US Radio — Modern dark theme */
:root {
  --bg: #0b0f19;
  --bg-elevated: #131a2b;
  --bg-card: #1a2236;
  --border: #2a3550;
  --text: #e8eef7;
  --text-muted: #8b9bb8;
  --accent: #3ddc97;
  --accent-dim: #2bb87a;
  --accent-glow: rgba(61, 220, 151, 0.25);
  --danger: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 90px; /* space for player bar */
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 1.75rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.nav {
  display: flex;
  gap: 0.35rem;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

/* Search section */
.search-section {
  padding: 1.75rem 0 1rem;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg) 100%);
}

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.search-box input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

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

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box button {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  border-radius: var(--radius);
  width: 52px;
  font-size: 1.2rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.search-box button:hover {
  background: var(--accent-dim);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.filter-group label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.filter-group select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

.filter-group select:focus {
  border-color: var(--accent);
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tag-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.tag-chip:hover,
.tag-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* Results */
.results-section {
  padding: 1.5rem 0 3rem;
}

.results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.results-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
}

.results-count {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.station-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.station-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.station-card.playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.station-top {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.station-favicon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

.station-favicon.fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--bg-elevated);
}

.station-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.station-location {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.station-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.station-tag {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.station-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border);
}

.station-actions {
  display: flex;
  gap: 0.4rem;
}

.play-btn, .fav-btn {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.play-btn:hover, .fav-btn:hover {
  background: var(--accent-dim);
  transform: scale(1.05);
}

.fav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.fav-btn.active {
  color: #ffd700;
  border-color: #ffd700;
}

.bitrate {
  font-variant-numeric: tabular-nums;
}

/* Loading / Error */
.loading, .error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.loading.hidden, .error.hidden, .map-view.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.error {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 2rem;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#pageInfo {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Map note */
.map-note {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

/* Player bar */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  z-index: 200;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
}

.player-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.now-playing {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.player-favicon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg);
}

.player-favicon.hidden {
  display: none;
}

.player-info {
  min-width: 0;
}

.player-info strong {
  display: block;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.control-btn {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.control-btn:hover:not(:disabled) {
  background: var(--accent-dim);
  transform: scale(1.05);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#volumeSlider {
  width: 90px;
  accent-color: var(--accent);
}

/* Responsive */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .player-inner {
    flex-wrap: wrap;
  }

  #volumeSlider {
    width: 70px;
  }

  .stations-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== MAP VIEW (Leaflet) ===== */
.map-view {
  display: flex;
  min-height: 480px;
  position: relative;
  border-top: 1px solid var(--border);
}
.map-view.hidden { display: none !important; }
.map-container {
  flex: 1;
  min-height: 420px;
  background: #0d1520;
  z-index: 1;
}
.leaflet-container { background: #0d1520; font-family: var(--font); }
.leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--bg-card); }
.leaflet-popup-content { margin: 0.75rem 0.9rem; font-size: 0.85rem; }
.leaflet-popup-content strong { display: block; margin-bottom: 0.25rem; }
.leaflet-popup-content button {
  margin-top: 0.5rem;
  background: var(--accent);
  color: #0b0f19;
  border: none;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
}
.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.station-marker {
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  box-shadow: 0 0 10px var(--accent-glow);
}
.station-marker.playing {
  background: #ffd700;
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.6);
  width: 18px;
  height: 18px;
}
.map-sidebar {
  width: 320px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  overflow: hidden;
}
.map-sidebar-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.map-sidebar-header h2 { font-size: 1rem; font-weight: 600; }
.map-stations-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.map-station-item {
  display: flex;
  gap: 0.65rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.map-station-item:hover { background: var(--bg-card); }
.map-station-item.playing {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.map-station-item img,
.map-station-item .fallback-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}
.map-station-item .fallback-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.map-station-item .info { min-width: 0; flex: 1; }
.map-station-item .info strong {
  display: block;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-station-item .info span {
  font-size: 0.72rem;
  color: var(--text-muted);
}
@media (max-width: 900px) {
  .map-view { flex-direction: column; }
  .map-sidebar {
    width: 100%;
    max-height: 260px;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .map-container { min-height: 300px; }
}
.results-section.hidden { display: none !important; }

#sleepTimer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  max-width: 110px;
}
.share-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn.copied { border-color: var(--accent); color: var(--accent); }
