/* style.css */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg-color: #f4f6f9;
  --surface-color: #ffffff;
  --surface-hover: #f0f2f5;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --accent-color: #3b82f6;
  --border-color: #e5e7eb;
  --player-bg: rgba(255, 255, 255, 0.95);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.15);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-color: #111827;
  --surface-color: #1f2937;
  --surface-hover: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --accent-color: #60a5fa;
  --border-color: #374151;
  --player-bg: rgba(31, 41, 55, 0.95);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 -10px 25px -3px rgba(0, 0, 0, 0.4);
}

[data-theme="oled"] {
  --bg-color: #000000;
  --surface-color: #121212;
  --surface-hover: #222222;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --border-color: #222222;
  --player-bg: rgba(18, 18, 18, 0.95);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  scrollbar-width: thin;
  accent-color: var(--accent-color);
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  padding-bottom: 100px; /* Space for sticky player */
  transition: background-color 0.3s ease;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: var(--bg-color);
  position: sticky;
  top: -1px;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background-color: var(--accent-color);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.user-profile {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background-color: var(--surface-color);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
}

.user-profile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-fallback {
  font-size: 20px;
  color: var(--text-secondary);
}

/* Typography & Utils */
.text-accent {
  color: var(--accent-color);
}
.text-muted {
  color: var(--text-secondary);
}
.hidden {
  display: none !important;
}

/* Sections */
.section-container {
  padding: 0 20px 24px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

/* Horizontal Scroll (Featured) */
.horizontal-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
}

.horizontal-scroll::-webkit-scrollbar {
  display: none;
}

.featured-card {
  flex: 0 0 140px;
  background-color: var(--surface-color);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  scroll-snap-align: start;
  cursor: pointer;
  transition:
    transform 0.2s,
    background-color 0.2s;
  border: 1px solid var(--border-color);
}

.featured-card:active {
  transform: scale(0.96);
  background-color: var(--surface-hover);
}

.card-img-wrapper {
  width: 100px;
  height: 100px;
  margin: 0 auto 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-img-wrapper i {
  font-size: 40px;
  color: var(--text-secondary);
}

.featured-card h3 {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.featured-card p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Vertical List (All Stations) */
.vertical-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  background-color: var(--surface-color);
  padding: 12px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition:
    transform 0.2s,
    background-color 0.2s;
}

.list-item:active {
  transform: scale(0.98);
  background-color: var(--surface-hover);
}

.list-item-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  margin-right: 16px;
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.list-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-item-img i {
  font-size: 24px;
  color: var(--text-secondary);
}

.list-item-info {
  flex: 1;
  overflow: hidden;
}

.list-item-info h3 {
  display: -webkit-box;
  font-size: clamp(0.875rem, 2vw, 1rem);
  font-weight: 600;
  width: 100%;
  margin-bottom: 4px;

  overflow: hidden;
  text-overflow: ellipsis;

  word-break: break-all;
  overflow-wrap: anywhere;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;

  min-width: 0;
  line-height: 1.3;
  max-height: calc(1.3em * 2);
}

.list-item-info p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.list-item-action {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
}

/* Bottom Sticky Player */
.bottom-player {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background-color: var(--player-bg);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  z-index: 50;
  overflow: hidden;
  animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.progress-bar-container {
  height: 3px;
  width: 100%;
  background-color: transparent;
}

.infinite-loading {
  height: 100%;
  background-color: var(--accent-color);
  width: 50%;
  animation: slideProgress 1.5s infinite linear;
}

@keyframes slideProgress {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(250%);
  }
}

.player-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  overflow: hidden;
}

.player-artwork {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--surface-hover);
  position: relative;
  overflow: hidden;
}

.player-artwork img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.equalizer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 8px;
}

.equalizer .bar {
  width: 4px;
  background-color: var(--accent-color);
  animation: eq 0.8s ease-in-out infinite alternate;
}
.equalizer .bar:nth-child(1) {
  height: 40%;
  animation-delay: 0.1s;
}
.equalizer .bar:nth-child(2) {
  height: 70%;
  animation-delay: 0.3s;
}
.equalizer .bar:nth-child(3) {
  height: 50%;
  animation-delay: 0.5s;
}

@keyframes eq {
  0% {
    height: 20%;
  }
  100% {
    height: 80%;
  }
}

.player-text {
  flex: 1;
  overflow: hidden;
}

.player-text h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-text p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.player-controls {
  display: flex;
  align-items: center;
}

.btn-control {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.1s,
    color 0.2s;
}

.btn-control:active {
  transform: scale(0.9);
}

.rotating {
  display: inline-block;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.search-bar i {
  color: var(--text-secondary);
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
}

/* View Toggles */
.view-toggles {
  display: flex;
  gap: 4px;
  background-color: var(--surface-color);
  padding: 2px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.toggle-btn {
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
}

.toggle-btn.active {
  background-color: var(--accent-color);
  color: white;
}

/* Grid Layouts (Overrides for standard list items) */
.vertical-list.grid-2,
.vertical-list.grid-3 {
  display: grid;
  gap: 12px;
}

.vertical-list.grid-2 {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

.vertical-list.grid-3 {
  grid-template-columns: repeat(3, minmax(100px, 1fr));
}

.vertical-list.grid-2 .list-item,
.vertical-list.grid-3 .list-item {
  flex-direction: column;
  text-align: center;
  padding: 16px 12px;
}

.vertical-list.grid-2 .list-item-img,
.vertical-list.grid-3 .list-item-img {
  margin-right: 0;
  margin-bottom: 12px;
}

.vertical-list.grid-2 .list-item-img {
  width: 64px;
  height: 64px;
}
.vertical-list.grid-3 .list-item-img {
  width: 48px;
  height: 48px;
}

/* Favorite Button & Actions */
.list-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vertical-list.grid-2 .list-item-actions,
.vertical-list.grid-3 .list-item-actions {
  margin-top: 12px;
}

.btn-favorite {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition:
    color 0.2s,
    transform 0.2s;
}
.btn-favorite.active {
  color: #ef4444;
}
.btn-favorite:active {
  transform: scale(0.8);
}

/* --- SPA Routing & Views --- */
.app-view {
  display: none;
  animation: fadeIn 0.2s ease-out;
}
.app-view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Dynamic Header --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-back {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  display: none;
  padding: 4px;
}

/* --- Bottom Navigation --- */
body {
  padding-bottom: 160px; /* Space for both sticky player and bottom nav */
}

.bottom-player {
  bottom: 75px; /* Lift player above nav */
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65px;
  background-color: var(--bg-color);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  text-decoration: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  width: 100%;
  padding: 8px 0;
  transition: color 0.2s;
}

.nav-item i {
  font-size: 24px;
}

.nav-item.active {
  color: var(--accent-color);
}

/* --- Me & Admin Panel --- */
.menu-list {
  background-color: var(--surface-color);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-bottom: 24px;
}
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}
.menu-item:last-child {
  border-bottom: none;
}
.menu-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}
.menu-item-left i {
  color: var(--accent-color);
  font-size: 20px;
}
.menu-item i.ri-arrow-right-s-line {
  color: var(--text-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background-color: var(--surface-color);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-align: center;
}
.stat-card h3 {
  font-size: 24px;
  color: var(--accent-color);
  margin-bottom: 4px;
}
.stat-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--surface-color);
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}
.admin-form
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  width: 100%;
}
.admin-form button {
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  background-color: var(--accent-color);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: transparent;
  color: var(--text-primary);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.btn-secondary:hover {
  background-color: var(--surface-hover);
}

/* Custom Confirm Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}
.modal-content {
  background: var(--surface-color);
  padding: 24px;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  text-align: center;
}
.modal-content h3 {
  margin-bottom: 24px;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.modal-actions {
  display: flex;
  gap: 12px;
}
.btn-danger {
  background-color: #ef4444;
  color: white;
  border: none;
  padding: 12px;
  border-radius: var(--radius-md);
  flex: 1;
  cursor: pointer;
  font-weight: 600;
}

/* Program Banners */
.program-banner-card {
  flex: 0 0 280px;
  height: 140px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  scroll-snap-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}
.program-banner-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.program-banner-card:active img {
  transform: scale(1.05);
}
.program-banner-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  padding: 12px;
  color: white;
}
.program-banner-overlay h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.program-banner-overlay p {
  font-size: 0.75rem;
  opacity: 0.9;
}

/* Admin Tabs Styling */
.admin-tab-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.admin-tab-btn.active {
  color: var(--accent-color);
  border-bottom-color: var(--accent-color);
}
.admin-tab-content {
  display: block;
  animation: fadeIn 0.2s ease-out;
}
.admin-tab-content.hidden {
  display: none !important;
}
