﻿* { box-sizing: border-box; margin: 0; padding: 0; }

/* Default Theme Variables (VLC) */
:root {
  --bg: #1e1e1e; --bg-dark: #161616; --bg-panel: #252525; --bg-hover: #2f2f2f;
  --accent: #ff8800; --accent-hover: #ffa733; --text: #e0e0e0; --text-dim: #999; --border: #333;
}

/* Theme Overrides */
body[data-theme="spotify"] {
  --bg: #121212; --bg-dark: #000000; --bg-panel: #181818; --bg-hover: #282828;
  --accent: #1db954; --accent-hover: #1ed760; --text: #ffffff; --text-dim: #b3b3b3; --border: #282828;
}

body[data-theme="cyberpunk"] {
  --bg: #0b0b13; --bg-dark: #05050a; --bg-panel: #13131f; --bg-hover: #1f1f35;
  --accent: #ff00ff; --accent-hover: #ff55ff; --text: #e0e0ff; --text-dim: #7a7a9a; --border: #2a1b3d;
}

html, body {
  height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif; overflow: hidden;
  display: flex; flex-direction: column; transition: background 0.3s, color 0.3s;
}

/* Top Bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-dark); padding: 8px 16px; border-bottom: 1px solid var(--border);
  height: 52px; flex-shrink: 0; z-index: 100;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 1.1rem; }
.logo { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; }
.btn-open {
  background: var(--accent); color: black; border: none; padding: 6px 14px;
  border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
}
.btn-open:hover { background: var(--accent-hover); }

/* Main Layout */
.main { display: flex; flex: 1; overflow: hidden; }
.player-area { flex: 1; display: flex; flex-direction: column; background: black; position: relative; }
.video-surface { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }

/* Video */
#media { width: 100%; height: 100%; object-fit: contain; background: black; display: none; z-index: 10; outline: none; }

/* Visualizer */
.visualizer {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 340px; height: 340px; z-index: 1; pointer-events: none;
}

/* Turntable */
.turntable {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(circle at center, #1c1c1c, #050505);
  z-index: 5;
}
.vinyl {
  position: relative; flex: 0 0 auto; width: min(300px, 40vh); height: min(300px, 40vh);
  border-radius: 50%;
  background: repeating-radial-gradient(circle at center, #0a0a0a 0 3px, #1a1a1a 3px 6px);
  box-shadow: 0 15px 40px rgba(0,0,0,0.9), inset 0 0 10px rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center; will-change: transform;
  z-index: 2;
}
.vinyl-art { width: 46%; height: 46%; border-radius: 50%; object-fit: cover; border: 4px solid #111; background: #000; z-index: 2; }
.vinyl-hole {
  position: absolute; width: 14px; height: 14px; background: #0a0a0a;
  border-radius: 50%; border: 1px solid #333; z-index: 10;
}
.track-info { position: absolute; bottom: 10%; width: 90%; text-align: center; z-index: 10; }
.poster-title { font-size: 1.4rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poster-artist { color: var(--text-dim); font-size: 1rem; margin-top: 6px; }

/* Subtitles */
.subtitle-container {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
  width: 90%; text-align: center; z-index: 9999; pointer-events: none;
}
.subtitle-text {
  display: inline-block; background: rgba(0, 0, 0, 0.85); color: #fff;
  padding: 8px 16px; border-radius: 6px; font-size: 1.3rem; font-weight: 500;
}

/* Lyrics */
.lyrics-container { margin-top: 10px; max-height: 80px; overflow-y: auto; text-align: center; scrollbar-width: none; }
.lyrics-container::-webkit-scrollbar { display: none; }
.lyric-line { color: var(--text-dim); font-size: 0.95rem; padding: 2px 0; transition: color 0.3s, font-size 0.3s; }
.lyric-line.active { color: var(--accent); font-size: 1.1rem; font-weight: bold; text-shadow: 0 0 8px var(--accent); }

/* Controls */
.controls { background: var(--bg-dark); border-top: 1px solid var(--border); padding: 8px 16px 12px; flex-shrink: 0; z-index: 20; }
.seek-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.time { font-size: 0.75rem; color: var(--text-dim); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.seek { flex: 1; -webkit-appearance: none; appearance: none; height: 4px; background: #444; border-radius: 2px; outline: none; cursor: pointer; }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.seek::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: none; cursor: pointer; }

.transport { display: flex; align-items: center; justify-content: center; gap: 12px; position: relative; }
.ctrl { background: transparent; color: var(--text); border: none; font-size: 1.2rem; cursor: pointer; padding: 6px 10px; border-radius: 4px; transition: background 0.15s, color 0.15s; }
.ctrl:hover { background: var(--bg-hover); color: var(--accent); }
.ctrl-main { background: var(--accent); color: black; font-size: 1.4rem; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0; }
.ctrl-main:hover { background: var(--accent-hover); color: black; }
.ctrl-small { font-size: 1rem; }
.ctrl.active { color: var(--accent); text-shadow: 0 0 8px var(--accent); }

.volume-group { position: absolute; right: 40px; display: flex; align-items: center; gap: 6px; }
.volume { -webkit-appearance: none; appearance: none; width: 80px; height: 4px; background: #444; border-radius: 2px; outline: none; cursor: pointer; }
.volume::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); cursor: pointer; }
.volume::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: none; }
#btnFullscreen { position: absolute; right: 0; }

/* Playlist */
.playlist-panel { width: 320px; background: var(--bg-panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; z-index: 20; }
.playlist-header { display: flex; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; color: var(--text-dim); }
.count { background: var(--bg-dark); padding: 1px 8px; border-radius: 10px; font-size: 0.75rem; }
.search-container { padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-dark); }
#searchBar { width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 20px; font-size: 0.85rem; outline: none; }
#searchBar:focus { border-color: var(--accent); }
.playlist { flex: 1; overflow-y: auto; list-style: none; }
.playlist li { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; border-bottom: 1px solid var(--border); position: relative; padding-right: 40px; }
.playlist li:hover { background: var(--bg-hover); }
.playlist li.playing { background: rgba(255, 255, 255, 0.05); border-left: 3px solid var(--accent); padding-left: 11px; }
.playlist li img { width: 36px; height: 36px; border-radius: 3px; object-fit: cover; background: #333; flex-shrink: 0; }
.playlist li .meta { overflow: hidden; flex: 1; }
.playlist li .title { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist li .artist { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist li.playing .artist { color: var(--accent); }

/* Delete Button */
.delete-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: transparent; color: #ff5555; border: none; font-size: 1.2rem;
  cursor: pointer; padding: 5px; border-radius: 4px; opacity: 0.5; transition: opacity 0.2s, background 0.2s;
}
.playlist li:hover .delete-btn { opacity: 1; background: rgba(255, 85, 85, 0.2); }

/* Scrollbar */
.playlist::-webkit-scrollbar { width: 8px; }
.playlist::-webkit-scrollbar-track { background: var(--bg-dark); }
.playlist::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* Drag Overlay */
.drop-overlay { position: fixed; inset: 0; background: rgba(22, 22, 22, 0.85); backdrop-filter: blur(8px); z-index: 9999; display: none; align-items: center; justify-content: center; border: 4px dashed var(--accent); margin: 20px; border-radius: 12px; pointer-events: none; }
.drop-overlay.active { display: flex; }
.drop-message { text-align: center; }
.drop-message h2 { font-size: 2rem; margin: 10px 0; color: var(--accent); }
.drop-message p { font-size: 1rem; color: var(--text-dim); }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 100px);
  background: rgba(30, 30, 30, 0.95); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 20px; display: flex; align-items: center; gap: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); z-index: 10000;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
  opacity: 0; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-art { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: #333; }
.toast-info { display: flex; flex-direction: column; gap: 4px; }
.toast-title { font-weight: 600; font-size: 1rem; color: var(--text); max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-artist { font-size: 0.85rem; color: var(--text-dim); max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Phase 10: Settings Drawer ===== */
.settings-drawer {
  position: fixed; top: 52px; right: -320px; width: 320px; height: calc(100vh - 52px);
  background: var(--bg-panel); border-left: 1px solid var(--border);
  z-index: 1000; transition: right 0.3s ease; box-shadow: -5px 0 20px rgba(0,0,0,0.5);
}
.settings-drawer.open { right: 0; }
.settings-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.settings-header h2 { font-size: 1.1rem; color: var(--text); margin: 0; }
.settings-content { padding: 20px; }
.setting-group { margin-bottom: 20px; }
.setting-group label { display: block; font-size: 0.9rem; color: var(--text-dim); margin-bottom: 8px; }
.setting-group select { width: 100%; padding: 8px; background: var(--bg-dark); color: var(--text); border: 1px solid var(--border); border-radius: 4px; outline: none; }
.setting-group input[type="checkbox"] { margin-right: 8px; accent-color: var(--accent); }

/* Responsive */
@media (max-width: 800px) {
  .main { flex-direction: column; }
  .playlist-panel { width: 100%; max-height: 40vh; border-left: none; border-top: 1px solid var(--border); }
  .visualizer { width: 280px; height: 280px; }
  .toast-title, .toast-artist { max-width: 150px; }
  .settings-drawer { width: 100%; right: -100%; }
}

/* ===== Phase 11: Equalizer Styling ===== */
.eq-sliders {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 15px;
}
.eq-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.eq-band span:first-child {
  width: 50px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.eq-band span:last-child {
  width: 30px;
  text-align: right;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: bold;
}
.eq-band input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.eq-band input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.eq-band input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* ===== Phase 12: Theater Mode ===== */
.playlist-panel {
  transition: margin-right 0.4s ease, transform 0.4s ease;
}

/* When Theater Mode is active, push the playlist off-screen */
body.theater-mode .playlist-panel {
  margin-right: -320px; /* Slide out */
}

/* Adjust video surface when in theater mode */
body.theater-mode .video-surface {
  border-radius: 0;
}

/* ===== Premium SVG Icon Styling ===== */
.ctrl svg {
  pointer-events: none; /* Prevents the SVG from blocking button clicks */
  transition: fill 0.2s, stroke 0.2s;
}

/* Ensure the main Play button is perfectly centered */
.ctrl-main {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ctrl-main svg {
  width: 26px;
  height: 26px;
}

/* Active state colors for shuffle/repeat */
.ctrl.active svg {
  stroke: var(--accent);
  color: var(--accent);
  filter: drop-shadow(0 0 5px var(--accent));
}

/* ===== Splash Screen ===== */
.splash-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

/* When this class is added, the splash screen fades out */
.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-logo {
  width: 450px;
  max-width: 80vw;
  height: auto;
  animation: splashZoom 2s ease-out forwards;
  filter: drop-shadow(0 0 20px rgba(138, 43, 226, 0.4));
}

/* Loading bar underneath the logo */
.splash-loader {
  margin-top: 40px;
  width: 200px;
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.splash-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: loadBar 2.5s ease-in-out forwards;
}

/* Animations */
@keyframes splashZoom {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes loadBar {
  0% { width: 0%; }
  50% { width: 60%; }
  100% { width: 100%; }
}

/* Apply the 30% curved edges to the splash logo */
.splash-logo {
  width: 450px;
  max-width: 80vw;
  height: auto;
  border-radius: 30%; /* This is the magic line that curves the edges */
  background: white; /* Ensures the background stays white */
  box-shadow: 0 10px 30px rgba(0,0,0,0.8); /* Adds a premium shadow */
}

/* =========================================
   MOBILE RESPONSIVENESS (Phones & Tablets)
   ========================================= */
@media (max-width: 768px) {
  
  /* 1. Stack the layout vertically */
  .main {
    flex-direction: column;
  }

  /* 2. Shrink the player area to 55% height */
  .player-area {
    flex: 0 0 55vh; 
    height: 55vh;
  }

  /* 3. Expand the playlist to fill the rest */
  .playlist-panel {
    width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    margin-top: -10px; /* Slight overlap for a premium sheet look */
    z-index: 30;
  }

  /* 4. Scale down the vinyl so it fits */
  .vinyl {
    width: min(220px, 35vh);
    height: min(220px, 35vh);
  }
  .visualizer {
    width: 260px;
    height: 260px;
  }
  .track-info {
    bottom: 5%;
  }
  .poster-title {
    font-size: 1.1rem;
  }
  .poster-artist {
    font-size: 0.85rem;
  }

  /* 5. Fix overlapping controls */
  .controls {
    padding: 10px 12px;
  }
  .transport {
    gap: 8px; /* Tighter spacing */
  }
  
  /* Hide the volume slider/icon on mobile - phones have physical buttons */
  .volume-group {
    display: none !important; 
  }
  
  /* Make the fullscreen button normal flow instead of absolute */
  #btnFullscreen {
    position: static;
    margin-left: auto; 
  }

  /* 6. Make the search bar fit */
  #searchBar::placeholder {
    color: transparent; /* Hide the Ctrl+F text */
  }
  #searchBar {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23999" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
    background-repeat: no-repeat;
    background-position: 12px center;
    padding-left: 36px;
  }

  /* 7. Always show delete button (no hover on touch screens) */
  .delete-btn {
    opacity: 1;
    background: rgba(255, 85, 85, 0.1);
  }

  /* 8. Fix Theater Mode on mobile */
  body.theater-mode .playlist-panel {
    margin-right: 0;
    transform: translateY(100%); /* Slide down instead of right */
  }
  body.theater-mode .player-area {
    flex: 1;
    height: 100vh;
  }
  body.theater-mode .vinyl {
    width: min(280px, 45vh);
    height: min(280px, 45vh);
  }
}

/* Extra small phones */
@media (max-width: 400px) {
  .ctrl {
    padding: 4px 6px;
    font-size: 1rem;
  }
  .ctrl-main {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
  #btnSpeed {
    display: none; /* Hide speed on very small screens to save space */
  }
}

/* =========================================
   ULTIMATE MOBILE RESPONSIVENESS FIX
   ========================================= */

.mobile-only {
  display: none; /* Hidden on desktop */
}

.playlist-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
}
.playlist-backdrop.open {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .mobile-only { display: flex; }
  
  /* Hide volume slider */
  .volume-group { display: none !important; }
  
  /* Main layout */
  .main { flex-direction: column; }
  .player-area { height: 60vh; flex: none; padding-bottom: 10px; }
  
  /* Scale down vinyl */
  .vinyl { width: 180px; height: 180px; }
  .visualizer { width: 220px; height: 220px; }
  .track-info { bottom: 5%; }
  
  /* THE SLIDE-UP DRAWER */
  .playlist-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65vh; /* Takes up 65% of the screen */
    z-index: 100;
    transform: translateY(100%); /* Hidden off-screen */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    padding-bottom: 20px; /* Safe area for home bar */
  }
  
  .playlist-panel.open {
    transform: translateY(0); /* Slides up */
  }

  /* Search bar clean up */
  #searchBar { width: 100%; padding: 10px 12px; font-size: 0.9rem; }
  #searchBar::placeholder { color: transparent; }
  #searchBar {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23999" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
    background-repeat: no-repeat;
    background-position: 12px center;
    padding-left: 36px;
  }

  /* Always show delete button */
  .delete-btn { opacity: 1; background: rgba(255, 85, 85, 0.1); }
  
  /* Fix control spacing */
  .transport { gap: 10px; }
  .controls { padding: 12px; }
}
