/* BPFRG World Radio — dark theme + map */
: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;
  --sidebar-w: 340px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 80px;
  display: flex;
  flex-direction: column;
}

.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: 1000;
  flex-shrink: 0;
}

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

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

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

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

.tagline {
  font-size: 0.72rem;
  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 */
.search-section {
  padding: 1rem 0 0.85rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 500;
}

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

.search-box input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  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: 48px;
  font-size: 1.1rem;
  cursor: pointer;
  font-weight: 600;
}

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

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

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

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

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

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

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

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

/* ===== MAP VIEW ===== */
.map-view {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.map-view.hidden { display: none; }

.map-container {
  flex: 1;
  min-height: 420px;
  background: #0d1520;
  z-index: 1;
}

/* Leaflet dark tweaks */
.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;
}

.leaflet-control-attribution {
  background: rgba(19, 26, 43, 0.85) !important;
  color: var(--text-muted) !important;
  font-size: 0.65rem !important;
}

/* Custom marker */
.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 */
.map-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  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);
}

/* Browse / list views */
.results-section {
  padding: 1.25rem 0 2.5rem;
  flex: 1;
}

.results-section.hidden { display: none; }

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

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

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

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

.station-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  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.75rem;
  align-items: flex-start;
}

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

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

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

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

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

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

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

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

.play-btn, .fav-btn {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  border-radius: 7px;
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
  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;
}

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

.loading.hidden, .error.hidden { display: none; }

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

@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.1rem;
  margin-top: 1.75rem;
}

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

.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.85rem; }

/* Player bar */
.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 0.65rem 0;
  z-index: 2000;
  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.7rem;
  min-width: 0;
  flex: 1;
}

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

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

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

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

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

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

.control-btn {
  background: var(--accent);
  color: #0b0f19;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

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

/* Responsive */
@media (max-width: 900px) {
  .map-view {
    flex-direction: column;
  }
  .map-sidebar {
    width: 100%;
    max-height: 280px;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .map-container {
    min-height: 320px;
  }
}

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav { width: 100%; }
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .stations-grid {
    grid-template-columns: 1fr;
  }
  #volumeSlider { width: 65px; }
}
