/* --------------------------------------------------
   Radionance — Global UI
-------------------------------------------------- */

:root {
  --bg: #020617;
  --bg-soft: #0b1120;
  --bg-card: #111827;
  --bg-hover: #1e293b;
  --accent: #22c55e;
  --accent-soft: #22c55e33;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 12px 40px rgba(0,0,0,0.45);
  --transition: 0.18s ease;
}

body[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-soft: #e2e8f0;
  --bg-card: #ffffff;
  --bg-hover: #e5e7eb;
  --text: #020617;
  --text-muted: #4b5563;
  --shadow: 0 10px 30px rgba(15,23,42,0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  min-height: 100vh;
}

/* Utility */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------
   Sidebar
-------------------------------------------------- */

.sidebar {
  width: 240px;
  background: var(--bg-soft);
  border-right: 1px solid #1f2937;
  padding: 1.2rem;
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 20;
}

body[data-theme="light"] .sidebar {
  border-right-color: #cbd5e1;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.branding {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.branding-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: conic-gradient(from 160deg, #22c55e, #0ea5e9, #6366f1, #22c55e);
  padding: 2px;
}

.branding-icon-inner {
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.branding-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.branding-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn .material-icons-outlined {
  font-size: 1.1rem;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 1rem;
  border-top: 1px solid #1f2937;
}

body[data-theme="light"] .sidebar-footer {
  border-top-color: #cbd5e1;
}

/* Mobile overlay backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.2s ease;
}

/* Only apply drawer transforms on mobile */
@media (max-width: 900px) {
  .sidebar {
    left: 0;
    transform: translateX(0);
    transition: transform 0.2s ease;
  }
  .sidebar.drawer-hidden {
    transform: translateX(-100%);
  }
  .sidebar.drawer-visible {
    transform: translateX(0);
  }
  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* --------------------------------------------------
   Main + Topbar
-------------------------------------------------- */

.main {
  margin-left: 240px;
  padding: 1rem 2rem 4.5rem;
  width: calc(100% - 240px);
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.topbar-menu,
.topbar-theme {
  display: none;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.icon-btn {
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: var(--bg-card);
  color: var(--text);
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn .material-icons-outlined {
  font-size: 1.2rem;
}

body[data-theme="light"] .icon-btn {
  border-color: #cbd5e1;
}

/* --------------------------------------------------
   Global Loading
-------------------------------------------------- */

.global-loading {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  box-shadow: var(--shadow);
  z-index: 10;
}

.global-loading span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------
   Views / Sections
-------------------------------------------------- */

.views {
  margin-top: 0.5rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-header {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header h2 {
  font-size: 1.2rem;
}

.chip-btn {
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.chip-btn .material-icons-outlined {
  font-size: 1rem;
}

body[data-theme="light"] .chip-btn {
  border-color: #cbd5e1;
}

/* --------------------------------------------------
   Station cards
-------------------------------------------------- */

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}

.station-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 0.8rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 230px;
  max-height: 230px;
}

.station-card:hover {
  background: var(--bg-hover);
  transform: translateY(-3px);
}

/* Artwork */
.station-art {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, #22c55e33, transparent),
              radial-gradient(circle at 80% 50%, #0ea5e933, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.8rem;
  font-weight: 600;
  position: relative;
}

.station-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mini EQ */
.station-card.playing .station-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15,23,42,0.75), transparent 60%);
}

.station-card.playing .eq-mini {
  opacity: 1;
  transform: translateY(0);
}

.eq-mini {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transform: translateY(4px);
  transition: 0.2s ease;
}

.eq-mini span {
  width: 3px;
  height: 12px;
  background: var(--accent);
  border-radius: 999px;
  animation: eqPulse 0.7s infinite;
}

.eq-mini .bar2 { animation-delay: 0.15s; }
.eq-mini .bar3 { animation-delay: 0.3s; }
.eq-mini .bar4 { animation-delay: 0.45s; }

@keyframes eqPulse {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

/* Text */
.station-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.station-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.station-title,
.station-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-tags {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  overflow: hidden;
}

.tag-pill {
  background: #1f2937;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

body[data-theme="light"] .tag-pill {
  background: #e5e7eb;
}

/* Favorite */
.favorite-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.2s ease;
  user-select: none;
}

.favorite-btn:hover {
  transform: scale(1.15);
}

.favorite-btn.hearted {
  color: var(--danger);
  transform: scale(1.2);
}

/* --------------------------------------------------
   Pills (genres / countries)
-------------------------------------------------- */

.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pill {
  background: var(--bg-card);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid #1f2937;
  cursor: pointer;
  transition: var(--transition);
}

.pill:hover {
  background: var(--bg-hover);
  color: var(--text);
}

body[data-theme="light"] .pill {
  border-color: #cbd5e1;
}

/* --------------------------------------------------
   Search
-------------------------------------------------- */

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-bar input,
.search-bar select {
  padding: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid #1f2937;
  background: var(--bg-card);
  color: var(--text);
}

body[data-theme="light"] .search-bar input,
body[data-theme="light"] .search-bar select {
  border-color: #cbd5e1;
}

.search-bar button {
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --------------------------------------------------
   Pagination
-------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.pagination-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --------------------------------------------------
   Status Text
-------------------------------------------------- */

.status-text {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --------------------------------------------------
   Player (bottom bar)
-------------------------------------------------- */

.player-bar {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  background: var(--bg-soft);
  border-top: 1px solid #1f2937;
  padding: 0.5rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 10;
}

body[data-theme="light"] .player-bar {
  border-top-color: #cbd5e1;
}

.player-nowplaying {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  min-width: 0;
}

.player-art {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, #22c55e33, transparent),
              radial-gradient(circle at 80% 50%, #0ea5e933, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
}

.player-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-info {
  min-width: 0;
}

.player-info #playerTitle {
  font-size: 0.95rem;
  font-weight: 600;
}

.player-info #playerSubtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nowplaying-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.player-info .truncate {
  max-width: 100%;
}

/* Play/Pause */
.circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.circle-btn .material-icons-outlined {
  font-size: 1.5rem;
}

/* Player EQ */
.player-eq {
  width: 28px;
  height: 18px;
  display: flex;
  gap: 2px;
  align-items: flex-end;
  opacity: 0.15;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.player-eq span {
  flex: 1;
  border-radius: 999px;
  background: var(--accent);
  animation: eqPulse 0.7s infinite;
}

.player-eq .bar2 { animation-delay: 0.1s; }
.player-eq .bar3 { animation-delay: 0.2s; }
.player-eq .bar4 { animation-delay: 0.3s; }

.player-eq.active {
  opacity: 1;
}

.player-volume {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.player-volume span {
  font-size: 0.75rem;
  min-width: 3ch;
  text-align: right;
}

.player-volume input {
  width: 90px;
}

/* --------------------------------------------------
   Expanded Now Playing (hidden by default)
-------------------------------------------------- */

.nowplaying-expanded {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.nowplaying-expanded.visible {
  transform: translateY(0);
}

.np-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.np-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.np-art {
  width: 100%;
  max-width: 350px;
  aspect-ratio: 1;
  margin: 1.5rem auto 1rem;
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, #22c55e33, transparent),
              radial-gradient(circle at 80% 50%, #0ea5e933, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.np-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.np-info {
  text-align: center;
  margin-bottom: 1rem;
  padding: 0 0.5rem;
}

.np-song {
  font-size: 1.3rem;
  font-weight: 600;
}

.np-artist {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.np-station {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.np-controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.np-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.np-volume span {
  font-size: 0.8rem;
  min-width: 3ch;
  text-align: right;
}

/* --------------------------------------------------
   Responsive
-------------------------------------------------- */

@media (max-width: 900px) {
  .main {
    margin-left: 0;
    width: 100%;
    padding: 0.75rem 1rem 4.5rem;
  }

  .topbar-menu,
  .topbar-theme {
    display: inline-flex;
  }

  .player-bar {
    left: 0;
  }

  .station-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}
