/* ==========================================================================
   Worship Night Application Stylesheet
   Modern, responsive, mobile-first audio player & lyric sheet
   ========================================================================== */

:root {
  --bg-app: #0c0e14;
  --bg-sidebar: #131722;
  --bg-surface: #1a202c;
  --bg-surface-hover: #242c3d;
  --bg-active: rgba(229, 169, 60, 0.12);
  --bg-player: rgba(17, 21, 30, 0.96);
  
  --accent: #e5a93c;
  --accent-hover: #f5bc51;
  --accent-dim: rgba(229, 169, 60, 0.25);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(229, 169, 60, 0.5);
  
  --header-height: 64px;
  --player-height: 82px;
  --sidebar-width: 380px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, Georgia, serif;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Shell */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* Top App Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  flex-shrink: 0;
}

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

.header-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #e5a93c, #9d6812);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(229, 169, 60, 0.3);
}

.header-titles h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
}

.header-titles p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

.service-badge {
  background: var(--bg-surface);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.sidebar-toggle-btn {
  display: none; /* Shown on mobile */
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
}

/* Main Two-Column Layout */
.app-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height) - var(--player-height));
  height: calc(100dvh - var(--header-height) - var(--player-height));
  position: relative;
  overflow: hidden;
}

/* Sidebar: Set List */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.sidebar-count {
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--bg-active);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.sidebar-close-btn {
  display: none;
}

.song-list-scroll {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  padding: 0.5rem 0.75rem;
}

.song-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Song Item in Sidebar */
.song-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  user-select: none;
}

.song-item:hover {
  background: var(--bg-surface-hover);
}

.song-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.song-item.active {
  background: var(--bg-active);
  border-color: var(--border-active);
}

.item-left {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  position: relative;
}

.track-num {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.song-item.active .track-num {
  display: none;
}

/* Animated Sound Wave for Active Track */
.sound-wave-icon {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.song-item.active .sound-wave-icon {
  display: flex;
}

.sound-wave-icon span {
  width: 3px;
  height: 4px;
  background-color: var(--accent);
  border-radius: 1px;
}

.sound-wave-icon.playing span {
  animation: wave-anim 0.8s ease-in-out infinite alternate;
}

.sound-wave-icon.playing span:nth-child(1) { animation-delay: 0.0s; height: 10px; }
.sound-wave-icon.playing span:nth-child(2) { animation-delay: 0.2s; height: 14px; }
.sound-wave-icon.playing span:nth-child(3) { animation-delay: 0.4s; height: 7px; }

@keyframes wave-anim {
  0% { height: 3px; }
  100% { height: 14px; }
}

.item-meta {
  flex: 1;
  min-width: 0;
}

.item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

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

.song-item.active .item-title {
  color: var(--accent);
}

.item-key-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.song-item.active .item-key-badge {
  border-color: var(--border-active);
  color: var(--accent);
}

.item-sub-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.item-lead {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-time {
  color: var(--text-muted);
  font-size: 0.74rem;
  margin-left: auto;
}

.item-duration {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: 0.5rem;
}

/* Intermission Card in Sidebar */
.intermission-item {
  margin: 0.6rem 0;
}

.intermission-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
}

.intermission-icon {
  font-size: 1.2rem;
}

.intermission-text strong {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.intermission-text span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Main Area: Lyrics Display */
.lyrics-view {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  overflow: hidden;
  position: relative;
}

/* Floating Action Toolbar in Lyrics Panel */
.lyrics-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(12, 14, 20, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
}

.action-btn.primary {
  background: var(--accent);
  color: #1a150a;
  border-color: var(--accent);
  font-weight: 600;
}

.action-btn.primary:hover {
  background: var(--accent-hover);
}

.font-controls {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.font-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.font-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.font-btn + .font-btn {
  border-left: 1px solid var(--border);
}

/* Lyrics Scroll Area */
.lyrics-scroll-area {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 2.5rem 3rem 5rem;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* Song Header Details */
.song-header-info {
  margin-bottom: 2rem;
}

.header-pre-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.track-badge {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.time-badge, .key-badge, .duration-badge {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.main-song-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}

.vocal-credits {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.92rem;
  color: var(--text-secondary);
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.vocal-credits strong {
  color: var(--text-primary);
}

/* Personnel Breakdown */
.personnel-details {
  margin-bottom: 2.5rem;
}

.personnel-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.personnel-label {
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.4rem;
}

/* Formatted Lyrics Typography */
.lyrics-content {
  font-family: var(--font-serif);
  line-height: 1.75;
  color: #e5e7eb;
  transition: font-size 0.15s ease;
}

.lyric-section {
  margin-bottom: 2rem;
}

.section-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.65rem;
  opacity: 0.9;
}

.lyric-line {
  margin-bottom: 0.2rem;
}

.no-lyrics {
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   Sticky Mini-Player (Bottom Pinned)
   ========================================================================== */
#audio-element {
  display: none;
}

.mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--player-height);
  background: var(--bg-player);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  grid-template-rows: auto auto;
  grid-template-areas:
    "info controls right"
    "info timeline right";
  align-items: center;
  row-gap: 2px;
  padding: 0.5rem 1.5rem;
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

/* Left: Track Info */
.player-track-info {
  grid-area: info;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.player-track-tile {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e2535, #141722);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.95rem;
  flex-shrink: 0;
}

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

.player-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.player-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playback-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.control-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.control-btn.play-main {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #12151c;
  box-shadow: 0 2px 10px rgba(229, 169, 60, 0.4);
}

.control-btn.play-main:hover {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.control-btn.play-main:active {
  transform: scale(0.96);
}

/* Scrubber Timeline Row */
.timeline-row {
  grid-area: timeline;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 580px;
  min-width: 0;
  margin: 0 auto;
}

.time-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  width: 36px;
  text-align: center;
}

/* Custom Seek & Volume Range Inputs */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  min-width: 0;
  width: auto;
  height: 4px;
  border-radius: 2px;
  background: #2d3748;
  outline: none;
  cursor: pointer;
  position: relative;
  transition: height 0.15s;
}

.range-slider:hover {
  height: 6px;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s;
}

.range-slider:hover::-webkit-slider-thumb {
  transform: scale(1.2);
}

.seek-bar {
  background: linear-gradient(to right, var(--accent) var(--seek-progress, 0%), #2d3748 var(--seek-progress, 0%));
}

.vol-bar {
  background: linear-gradient(to right, var(--text-secondary) var(--vol-progress, 100%), #2d3748 var(--vol-progress, 100%));
}

/* Right: Auxiliary Controls (Volume, Autoplay, Loop) */
.player-right {
  grid-area: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

.toggle-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.toggle-icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.toggle-icon-btn.active {
  color: var(--accent);
  background: var(--bg-active);
}

.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 110px;
}

/* Drawer Backdrop for Mobile */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1150;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.open {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 960px) {
  :root {
    --sidebar-width: 320px;
  }
  
  .mini-player {
    grid-template-columns: 220px 1fr 180px;
  }
}

@media (max-width: 840px) {
  :root {
    --header-height: 56px;
    --player-height: 88px;
  }

  .app-header {
    padding: 0 1rem;
  }

  .header-icon {
    display: none;
  }

  .header-titles h1 {
    font-size: 1.05rem;
  }

  .header-titles p {
    font-size: 0.72rem;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    width: 88%;
    max-width: 360px;
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: 0.5rem;
    transition: all 0.15s ease;
  }

  .sidebar-close-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
  }

  .song-list-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding: 0.75rem 0.75rem 5rem;
  }

  .lyrics-scroll-area {
    padding: 1.25rem 1rem 5.5rem;
  }

  .lyrics-toolbar {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  .action-btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }

  .font-btn {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
  }

  .main-song-title {
    font-size: 1.8rem;
  }

  /* Spotify-style mobile mini-player layout */
  .mini-player {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    grid-template-areas: 
      "info controls"
      "timeline timeline";
    row-gap: 4px;
    column-gap: 8px;
    padding: 0.45rem 1rem 0.55rem;
    height: var(--player-height);
  }

  .player-track-info {
    grid-area: info;
    min-width: 0;
  }

  .playback-controls {
    grid-area: controls;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  .timeline-row {
    grid-area: timeline;
    width: 100%;
    max-width: 100%;
    gap: 0.4rem;
  }

  .player-right {
    display: none;
  }
}

@media (max-width: 520px) {
  .header-titles p {
    display: none;
  }

  .service-badge {
    display: none;
  }

  .player-track-info {
    max-width: 190px;
  }

  .player-track-tile {
    width: 34px;
    height: 34px;
    font-size: 0.82rem;
  }

  .control-btn {
    width: 32px;
    height: 32px;
  }

  .control-btn.play-main {
    width: 38px;
    height: 38px;
  }
}
