/* TV-Safe CSS - No modern features */
@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;700;800&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Onest', 'Segoe UI', Roboto, Arial, sans-serif !important;
}

:root {
  --bg-color: #0d0d12;
  --panel-bg: #1a1a24;
  --accent-primary: #3399ff;
  --accent-secondary: #0066cc;
  --text-main: #ffffff;
  --text-muted: #a0a0b0;
}

html, body {
  height: 100vh; /* TV-safe: no dvh */
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  flex-shrink: 0;
  height: 60px; /* TV-safe: no clamp() */
  padding: 0 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--panel-bg);
  border-bottom: 2px solid var(--accent-primary);
  z-index: 100;
}

@media (min-width: 901px) {
  header {
    height: 70px;
    padding: 0 20px;
  }
}

.logo-text span {
  color: white;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
}

@media (min-width: 601px) {
  .logo-text span {
    font-size: 24px;
  }
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-badge {
  background: #2a2a38;
  color: var(--text-muted);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 15px;
  font-weight: bold;
}

.setup-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 15px;
  background: #2a2a38;
  transition: background 0.2s;
}

.setup-link:hover, .setup-link:focus {
  color: white;
  background: var(--accent-primary);
}

/* Main Layout */
main {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 10px;
  gap: 10px;
}

@media (min-width: 901px) {
  main {
    display: grid;
    grid-template-columns: 1fr 400px;
    padding: 15px 20px;
    gap: 15px;
  }
}

/* Player Section */
.player-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: var(--panel-bg);
  border-radius: 12px;
  padding: 10px;
}

.video-container {
  position: relative;
  width: 100%;
  /* TV-safe aspect ratio fallback */
  padding-top: 56.25%; /* 16:9 */
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
}

@media (min-width: 901px) {
  .video-container {
    padding-top: 0;
    height: 400px;
    flex-grow: 1;
  }
}

#player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 25px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 5;
  pointer-events: none;
}

.video-container:hover .video-overlay,
.video-overlay.active-touch {
  opacity: 1;
  pointer-events: auto;
}

.overlay-btn {
  background: rgba(51, 153, 255, 0.8);
  border: 2px solid white;
  border-radius: 50%;
  width: 55px;
  height: 55px;
  font-size: 18px;
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s;
}

.overlay-btn:hover {
  transform: scale(1.1);
  background: var(--accent-primary);
}

.mic-indicator-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #aaa;
  background: rgba(0, 0, 0, 0.6);
  padding: 5px 8px;
  border-radius: 10px;
}

.mic-indicator-overlay.active {
  color: #00ff00;
  background: rgba(0, 20, 0, 0.7);
}

.voice-animator {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  height: 20px;
}

.voice-animator .bar {
  width: 3px;
  height: 3px;
  background-color: #00ff00;
  border-radius: 2px;
  transition: height 0.05s;
}

.song-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 45px;
  z-index: 9999;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 75%, rgba(0,0,0,0) 100%);
  color: white;
  display: none;
  align-items: center;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-100%);
  transition: all 0.5s ease;
}

.song-tooltip.show {
  opacity: 1;
  transform: translateY(0);
  display: flex;
}

.score-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 50;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.score-screen.active {
  display: flex;
}

.score-title {
  font-size: 24px;
  color: white;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.score-number {
  font-size: 100px;
  font-weight: 900;
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.7);
  line-height: 1;
}

.current-song-info {
  padding: 12px 0 8px;
  flex-shrink: 0;
}

.current-song-info h2 {
  margin-bottom: 4px;
  color: var(--accent-primary);
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-song-info p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.controls-bar {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  margin-top: 8px;
}

.controls-bar button {
  color: white;
  border: none;
  padding: 8px 16px;
  font-weight: bold;
  font-size: 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.2s;
}

#mainPlayBtn {
  background: linear-gradient(45deg, #00b09b, #96c93d);
}

#mainNextBtn {
  background: linear-gradient(45deg, #ff512f, #dd2476);
}

#mainFsBtn {
  background: rgba(255, 255, 255, 0.1);
}

.controls-bar button:hover {
  transform: scale(1.03);
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  overflow: hidden;
}

.panel {
  background-color: var(--panel-bg);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--accent-primary);
  background: rgba(51, 153, 255, 0.1);
  border-color: rgba(51, 153, 255, 0.3);
}

.tab-btn:focus {
  outline: 2px solid var(--accent-primary);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.queue-badge {
  background-color: #444;
  color: white;
  padding: 2px 5px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: bold;
  margin-left: 4px;
}

.tab-btn.active .queue-badge {
  background-color: var(--accent-primary);
}

/* Song Lists */
.popular-wrapper,
.search-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.popular-wrapper::-webkit-scrollbar,
.search-wrapper::-webkit-scrollbar,
#queueList::-webkit-scrollbar {
  width: 5px;
}

.popular-wrapper::-webkit-scrollbar-thumb,
.search-wrapper::-webkit-scrollbar-thumb,
#queueList::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 10px;
}

.song-list {
  list-style: none;
}

.song-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 10px;
  border-left: 3px solid transparent;
  transition: background 0.2s;
  cursor: pointer;
}

.song-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.song-item:focus {
  background-color: rgba(51, 153, 255, 0.15);
  border-left-color: var(--accent-primary);
  outline: none;
}

.song-item.dragging {
  opacity: 0.6;
  background-color: rgba(51, 153, 255, 0.1);
  border: 1px dashed var(--accent-primary);
}

.song-details {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
  margin: 0 8px;
  min-width: 0;
}

.song-title {
  font-weight: bold;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-artist {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-btn {
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 10px;
  flex-shrink: 0;
  border-radius: 6px;
  cursor: pointer;
}

.action-btn.add {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.action-btn.add:hover {
  background: var(--accent-primary);
  color: white;
}

.action-btn.delete {
  border-color: #ff4444;
  color: #ff4444;
  margin-left: 5px;
}

.action-btn.delete:hover {
  background: #ff4444;
  color: white;
}

.drag-handle {
  cursor: grab;
  font-size: 14px;
  color: var(--text-muted);
  padding: 0 4px;
}

.info-msg {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

.error-msg {
  color: #ff6666;
  font-size: 13px;
  text-align: center;
  padding: 10px;
  background: rgba(255, 102, 102, 0.1);
  border-radius: 8px;
  border: 1px solid #ff4444;
}

/* Search Container */
.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 0;
}

.search-container input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid #333;
  background-color: #000;
  color: white;
  font-size: 13px;
  outline: none;
}

.search-container input:focus {
  border-color: var(--accent-primary);
}

.search-container button {
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: var(--accent-primary);
  color: white;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
}

.input-wrapper {
  position: relative;
  flex: 1;
}

.clear-search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: #aaa;
  font-size: 13px;
}

.clear-search-icon:hover {
  color: white;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: var(--panel-bg);
  padding: 25px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--accent-primary);
  max-width: 95%;
  width: 320px;
}

.modal-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent-primary);
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-weight: bold;
  font-size: 14px;
  border: none;
  cursor: pointer;
  margin-top: 15px;
}

.remote-link-box {
  color: var(--text-main);
  font-size: 12px;
  margin: 15px 0;
  word-break: break-all;
  background: #000;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #333;
  font-family: monospace;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: 0.3s;
  border-radius: 22px;
  border: 1px solid #555;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #00cc66;
  border-color: #00cc66;
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Mobile Search Guide */
#searchGuide {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10002;
  justify-content: flex-end;
}

#searchGuide.visible {
  display: flex;
}

#searchContent {
  width: 90%;
  max-width: 320px;
  height: 95%;
  margin: 10px;
  background: #141419;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  padding: 20px;
  box-sizing: border-box;
}

@media (min-width: 901px) {
  #searchGuide {
    display: none !important;
  }
}

.search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.search-header .title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.close-guide-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}

.mobile-input-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

#mobileSearchInput {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}

#mobileSearchSubmit {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 0 18px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

#searchResultsContainer {
  flex: 1;
  overflow-y: auto;
  margin-top: 15px;
}

.suggestion-item {
  padding: 12px 15px;
  margin: 4px 0;
  color: white;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  font-size: 14px;
}

.suggestion-item:hover {
  background: rgba(51, 153, 255, 0.2);
}

/* Welcome Overlay */
#welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
}

/* Focus Styles for TV Remote Navigation */
:focus {
  outline: 2px solid var(--accent-primary) !important;
  outline-offset: 2px;
}

button:focus,
[tabindex]:focus,
input:focus {
  outline: 2px solid var(--accent-primary) !important;
  box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.3);
}

/* Hide outline on non-keyboard interaction */
body:not(.keyboard-nav) :focus {
  outline: none !important;
  box-shadow: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  .video-container {
    padding-top: 56.25%;
    height: auto;
  }
  
  .player-section {
    height: auto;
  }
  
  main {
    padding: 8px;
  }
  
  .controls-bar button {
    padding: 7px 14px;
    font-size: 12px;
  }
  
  .score-number {
    font-size: 80px;
  }
}

@media (max-width: 500px) {
  .search-container {
    flex-direction: column;
  }
  
  .tabs {
    flex-wrap: wrap;
  }
  
  .logo-text {
    display: none;
  }
  
  .setup-link span {
    display: none;
  }
}