/* =============================================================
   Podcast Player – Styles
   Mobile-First, Westrans Branding, Funktional & Responsive
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --- CSS Custom Properties – Westrans Branding --- */
:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #242424;
  --bg-tertiary: #333333;
  --bg-card: #2a2a2a;
  --bg-player: #1e1e1e;

  --text-primary: #f0f0f0;
  --text-secondary: #a9a8aa;
  --text-muted: #707070;

  --accent: #b6112b;
  --accent-light: #d4243e;
  --accent-glow: rgba(182, 17, 43, 0.25);
  --accent-gradient: linear-gradient(135deg, #b6112b, #d4243e);

  --border: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --player-height: 160px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

/* =============================================================
   Channel Header
   ============================================================= */
.channel-header {
  padding: 20px 20px 16px;
  padding-top: calc(20px + env(safe-area-inset-top, 0px));
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg-primary) 60%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.channel-logo {
  height: 32px;
  width: auto;
  margin-bottom: 8px;
  opacity: 0.9;
}

.channel-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.channel-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Red accent bar (Westrans style) */
.channel-header::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 10px auto 0;
}

/* =============================================================
   Podcast List
   ============================================================= */
.podcast-list {
  padding: 0 16px;
  padding-bottom: calc(var(--player-height) + 24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.podcast-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.podcast-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition);
}

.podcast-item:hover,
.podcast-item:active {
  background: var(--bg-tertiary);
  transform: scale(0.985);
}

.podcast-item.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.podcast-item.active::before {
  opacity: 0.08;
}

.podcast-cover {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  position: relative;
  z-index: 1;
}

.podcast-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.podcast-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.podcast-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.podcast-meta .duration::before {
  content: '🕐 ';
}

.podcast-meta .plays::before {
  content: '▶ ';
}

.podcast-item .now-playing-indicator {
  display: none;
  position: relative;
  z-index: 1;
}

.podcast-item.active .now-playing-indicator {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 20px;
}

.now-playing-indicator span {
  display: block;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: equalizer 0.8s ease-in-out infinite;
}

.now-playing-indicator span:nth-child(1) { height: 60%; animation-delay: 0s; }
.now-playing-indicator span:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.now-playing-indicator span:nth-child(3) { height: 40%; animation-delay: 0.4s; }

@keyframes equalizer {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

/* Played indicator (resume dot) */
.podcast-item .resume-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* =============================================================
   Bottom Player
   ============================================================= */
.player-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-player);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding-bottom: var(--safe-bottom);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
}

.player-container.visible {
  transform: translateY(0);
}

/* --- Player Top: Current Track Info --- */
.player-track {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 8px;
}

.player-track-cover {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.player-track-info {
  flex: 1;
  min-width: 0;
}

.player-track-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-quality-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* --- Progress Bar --- */
.player-progress-container {
  padding: 0 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.player-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.player-progress-buffer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.player-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.player-progress-bar::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 12px;
  height: 12px;
  background: var(--accent-light);
  border-radius: var(--radius-full);
  transform: translate(50%, -50%) scale(0);
  transition: transform var(--transition);
  box-shadow: var(--shadow-glow);
}

.player-progress-container:hover .player-progress-bar::after,
.player-progress-container:active .player-progress-bar::after {
  transform: translate(50%, -50%) scale(1);
}

.player-progress-container:hover .player-progress-bar,
.player-progress-container:active .player-progress-bar {
  height: 6px;
}

.player-time {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* --- Controls --- */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 8px 16px 14px;
}

.player-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
  padding: 8px;
  border-radius: var(--radius-full);
  position: relative;
}

.player-btn:hover {
  color: var(--accent-light);
}

.player-btn:active {
  transform: scale(0.9);
}

.player-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.player-btn.btn-play-pause {
  width: 56px;
  height: 56px;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.player-btn.btn-play-pause svg {
  width: 28px;
  height: 28px;
}

.player-btn.btn-play-pause:active {
  transform: scale(0.92);
}

.player-btn .skip-label {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  bottom: -2px;
}

/* --- Buffering Overlay --- */
.player-buffering {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.7);
  z-index: 5;
  align-items: center;
  justify-content: center;
}

.player-buffering.active {
  display: flex;
}

.buffering-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

/* =============================================================
   Loading / Empty States
   ============================================================= */
.loading-state,
.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.loading-state .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.error-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* =============================================================
   Push Notification Banner
   ============================================================= */
.push-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
}

.push-banner.visible {
  transform: translateY(0);
}

.push-banner .push-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.push-banner .push-text strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

.push-banner button {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.push-banner .btn-allow {
  background: var(--accent-gradient);
  color: #fff;
}

.push-banner .btn-dismiss {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* =============================================================
   PWA Install Hint Banner
   ============================================================= */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  padding-bottom: calc(16px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.install-banner.visible {
  transform: translateY(0);
}

.install-banner .install-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.install-banner .install-text strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

.install-banner button {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

/* =============================================================
   Responsive
   ============================================================= */
@media (min-width: 640px) {
  .podcast-list {
    max-width: 600px;
    margin: 0 auto;
  }

  .player-container {
    max-width: 600px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .player-container.visible {
    transform: translateX(-50%) translateY(0);
  }

  .channel-header {
    max-width: 600px;
    margin: 0 auto;
  }
}

/* =============================================================
   Fade-in Animation
   ============================================================= */
.fade-in {
  animation: fadeIn 0.4s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.podcast-item {
  animation: fadeIn 0.4s ease both;
}

.podcast-item:nth-child(1) { animation-delay: 0.05s; }
.podcast-item:nth-child(2) { animation-delay: 0.1s; }
.podcast-item:nth-child(3) { animation-delay: 0.15s; }
.podcast-item:nth-child(4) { animation-delay: 0.2s; }
.podcast-item:nth-child(5) { animation-delay: 0.25s; }
.podcast-item:nth-child(6) { animation-delay: 0.3s; }
.podcast-item:nth-child(7) { animation-delay: 0.35s; }
.podcast-item:nth-child(8) { animation-delay: 0.4s; }
