/* Global Styles */
body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  color: #fff;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  /* Prevent scrolling */
}

/* Player Container (Background) */
#player-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#player {
  width: 100%;
  height: 100%;
}

/* Interaction Blocker */
#player-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  z-index: 2;
}

/* UI Layer (Foreground) */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  /* Let clicks pass through where there's no UI */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  /* Align content to bottom mostly */
  padding: 2rem;
  box-sizing: border-box;
}

/* Header */
header {
  position: absolute;
  top: 2rem;
  left: 2rem;
  pointer-events: auto;
  opacity: 0;
  /* Hidden by default, show on hover or channel switch? */
  transition: opacity 0.3s ease;
}

#ui-layer:hover header {
  opacity: 1;
}

h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.5rem 0 0;
  opacity: 0.7;
  font-size: 0.9rem;
}

/* Channel Info / Interstitials */
#app {
  pointer-events: auto;
  width: 100%;
  max-width: 800px;
}

.channel-info {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  border-radius: 1rem;
  margin-bottom: 2rem;
  transform: translateY(20px);
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
}

.interstitial {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
  /* Above player */
  pointer-events: auto;
}

.interstitial h2 {
  font-size: 3rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff 0%, #aaa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.interstitial p {
  font-size: 1.5rem;
  color: #888;
}

@keyframes slideUp {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Upcoming List */
.upcoming-list {
  margin-top: 1rem;
  list-style: none;
  padding: 0;
  font-size: 0.9rem;
  color: #aaa;
}

.upcoming-list li {
  margin-bottom: 0.5rem;
}

.upcoming-time {
  display: inline-block;
  width: 80px;
  font-weight: bold;
  color: #fff;
}

/* Notifications/Banners */
.banner {
  background: #333;
  color: #fff;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.banner-error {
  background: #dc2626;
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  font-size: 1.5rem;
  color: #666;
}

/* Channel Guide Sidebar */
#channel-guide {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 300px;
  background: #000;
  /* Solid black for visibility */
  border-right: 1px solid #333;
  padding: 2rem 1rem;
  box-sizing: border-box;
  transform: translateX(-100%);
  /* Hidden by default */
  transition: transform 0.3s ease;
  z-index: 100;
  /* Ensure above everything including attribution */
  pointer-events: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

/* Show sidebar on hover of left edge or sidebar itself */
#ui-layer:hover #channel-guide,
#channel-guide:hover {
  transform: translateX(0);
}

/* Or simpler: triggers when mouse is near left edge? 
   For MVP, let's keep it simple: hovering the UI layer reveals it (maybe too aggressive),
   or add a specific 'hover-zone' div on the left.
*/

/* Better: Hover zone */
.hover-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 100%;
  z-index: 100;
}

/* .hover-zone:hover~#ui-layer #channel-guide { ... } */

#channel-guide.visible,
#channel-guide:hover {
  transform: translateX(0);
}

/* Initial state override for peeking? No, let's use a explicit toggle or just a large hover area?
   Let's try: Sidebar is -290px, so 10px is visible.
*/
#channel-guide {
  transform: translateX(-280px);
}

#channel-guide h2 {
  margin-top: 0;
  font-size: 1.5rem;
  border-bottom: 1px solid #333;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

#channel-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.channel-item {
  padding: 1rem;
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.channel-item.active {
  background: rgba(255, 255, 255, 0.2);
  border-left: 4px solid #fff;
}

.channel-name {
  font-weight: bold;
  font-size: 1.1rem;
  display: block;
}

.channel-desc {
  font-size: 0.8rem;
  color: #aaa;
  display: block;
}

.channel-now {
  display: block;
  font-size: 0.8rem;
  color: #4ade80;
  /* Greenish */
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Splash Screen */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  text-align: center;
  color: #fff;
}

.splash-title {
  font-size: 6rem;
  font-weight: 700;
  margin: 0 0 1rem 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.splash-subtitle {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0 0 0.5rem 0;
  opacity: 0.9;
}

.splash-hint {
  font-size: 1rem;
  opacity: 0.6;
  margin: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 0.3;
  }
}

/* Full Screen Guide Overlay */
#guide-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 200;
  /* Highest priority */
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: auto;
  /* Enable clicks */
}

#guide-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.guide-container {
  width: 100%;
  max-width: 800px;
  height: 80vh;
  overflow-y: auto;
  padding: 2rem;
}

.guide-container h2 {
  font-size: 3rem;
  margin-bottom: 2rem;
  text-align: center;
  background: linear-gradient(to right, #fff, #888);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#guide-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.guide-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.guide-item:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
}

.guide-channel-name {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  display: block;
}

.guide-now-playing {
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 0.5rem;
  display: block;
  line-height: 1.6;
}

/* Options View Specific Styles */
.options-content {
  padding: 1rem 0;
}

.legal-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legal-section h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: #fff;
}

.tos-notice {
  margin: 0.5rem 0 1rem 0;
  font-size: 0.9rem;
  color: #aaa;
  font-style: italic;
}

.legal-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

.legal-links a {
  color: #4a9eff;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.legal-links a:hover {
  color: #6bb3ff;
  text-decoration: underline;
}

.api-notice {
  margin: 1rem 0 0 0;
  font-size: 0.85rem;
  color: #888;
}

.guide-time {
  font-size: 0.8rem;
  color: #4ade80;
  display: block;
}


/* Attribution Overlay */
/* Attribution Overlay - Minimal Pill (Clickable) */
#video-attribution {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  left: auto;
  width: auto;

  padding: 0.5rem 1rem;
  box-sizing: border-box;

  background: rgba(0, 0, 0, 0.7);
  border-radius: 4px;

  text-align: right;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: none;

  z-index: 50;
  pointer-events: auto;
  /* Make clickable */
  opacity: 0;
  transition: opacity 0.3s ease, background 0.2s ease;
  cursor: pointer;
}

#video-attribution:hover {
  background: rgba(0, 0, 0, 0.85);
}

#video-attribution.visible,
#ui-layer:hover #video-attribution {
  opacity: 1;
}

/* Expandable Info Card */
#info-card {
  position: absolute;
  bottom: 5rem;
  right: 2rem;
  width: 350px;
  max-height: 400px;
  overflow-y: auto;

  background: rgba(17, 17, 17, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1.5rem;
  box-sizing: border-box;

  z-index: 60;
  pointer-events: auto;

  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#info-card.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

#info-card-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

#info-card-close:hover {
  color: #fff;
}

#info-card-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  padding-right: 2rem;
  /* Space for close button */
}

#info-card-channel {
  margin: 0 0 0.25rem 0;
  font-size: 0.9rem;
  color: #aaa;
}

#info-card-time {
  margin: 0 0 1rem 0;
  font-size: 0.85rem;
  color: #888;
}

#info-card-description {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #ccc;
}

/* --- New Layout (Sidebar + Views) --- */

/* Persistent Sidebar */
/* --- New Layout (Overlay Mode) --- */

/* Persistent Sidebar (Icons Only by default) */
#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 60px;
  /* Collapsed width */
  background: rgba(17, 17, 17, 0.9);
  /* Semi-transparent */
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  /* Above splash screen */
  padding-top: 6rem;
  box-sizing: border-box;
  transition: width 0.3s ease, background 0.3s ease;
  overflow: hidden;
  /* Hide text when collapsed */
  pointer-events: auto;
  /* Enable clicks inside UI layer */
}

/* Expand on hover - REMOVED per user request */
/* #sidebar:hover, #sidebar.visible { width: 250px; background: #111; } */

#sidebar.hidden-idle {
  transform: translateX(-100%);
  opacity: 0;
}

/* Shift content - REMOVED */
/* #sidebar:hover ~ #main-content... */

/* Sidebar Sections (Tabs) */
.sidebar-section {
  padding: 1rem;
  /* Reduced padding for icons */
  font-size: 1.1rem;
  font-weight: 500;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
  white-space: nowrap;
  /* Prevent text wrap */
}

.sidebar-section:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.sidebar-section.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-right: 3px solid #fff;
}

.sidebar-section .icon {
  font-size: 1.5rem;
  /* Larger icons */
  opacity: 0.8;
  min-width: 30px;
  /* Fixed width for alignment */
  text-align: center;
}

.sidebar-spacer {
  flex: 1;
  /* Push help to bottom */
}

/* Main Content Area/* View Container (Overlay Mode) */
#main-content {
  position: absolute;
  top: 0;
  left: 60px;
  /* Starts after collapsed sidebar */
  width: 300px;
  /* Fixed width panel for channels */
  height: 100%;
  padding-top: 6rem;
  padding-right: 0;
  box-sizing: border-box;
  z-index: 1002;
  /* Above sidebar and splash */
  pointer-events: none;
  /* Default: Hidden or Transparent? */
  /* We want views to appear "next to" sidebar. */
}

/* View Panels */
/* When active, they take pointer events. When hidden, they don't. */
/* View Panels */
/* Channels View - Sidebar list (Overlay) */
#view-channels {
  background: #111;
  border-right: 1px solid #333;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  pointer-events: auto;
  display: none;
  /* Force hidden initially */
}

#view-channels.active {
  display: block;
  transform: translateX(0);
}

/* Guide View - Full Screen Overlay? */
#view-guide {
  position: fixed;
  top: 0;
  left: 60px;
  width: calc(100% - 60px);
  height: 100%;
  background: #111;
  transform: translateY(100%);
  /* Slide up? */
  transition: transform 0.3s ease;
  z-index: 2000;
  /* Fixed: Must be higher than main-content (1002) */
  pointer-events: auto;
}

#view-guide.active {
  display: block;
  transform: translateY(0);
}

/* Options View */
#view-options {
  background: #111;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  pointer-events: auto;
}

#view-options.active {
  display: block;
  transform: translateX(0);
}

.view-panel {
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: auto;
  overflow-y: auto;
}

.view-panel.active {
  display: block;
  /* animation handled by specific IDs */
}

.view-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  position: absolute;
  top: 1rem;
  right: 1rem;
}

/* Position relative for Options container to hold absolute close btn */
#view-options>div {
  position: relative;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Guide Grid Container */
/* Guide Grid Container */
#guide-grid-container {
  display: flex;
  flex-direction: column;
  height: 80vh;
  /* Fixed height relative to viewport */
  width: 100%;
  box-sizing: border-box;
  position: relative;
  background: #111;
  overflow: hidden;
  /* Prevent container scroll, use scroll-area */
}

#guide-scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  position: relative;
  z-index: 10;
  /* Below Now Line */
}


.guide-row {
  display: flex;
  align-items: center;
  height: 80px;
  /* Increased from 60px for wrapping */
}

.guide-channel-name {
  width: 200px;
  /* Increased from 150px */
  min-width: 200px;
  font-weight: bold;
  padding-right: 1.5rem;
  text-align: right;
  white-space: normal;
  /* Allow wrapping */
  overflow: visible;
  text-overflow: clip;
  line-height: 1.2;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.guide-timeline-track {
  flex-grow: 1;
  height: 100%;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.guide-time-axis {
  display: flex;
  height: 40px;
  min-height: 40px;
  /* Force height */
  position: relative;
  margin-left: 200px;
  /* Offset for channel names */
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  background: #1a1a1a;
  z-index: 100;
  align-items: center;
  /* Vertically center labels */
}

.time-label {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #aaa;
  top: 5px;
}

/* Program Modal */

#program-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  /* Above everything */
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: auto;
  /* Enable interaction by default */
}

#program-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  pointer-events: auto;
  /* Explicitly auto */
  background: #222;
  padding: 2rem;
  border-radius: 8px;
  width: 500px;
  max-width: 90%;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
}

#modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-actions {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
}

.btn-primary,
.btn-secondary {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: #fff;
  color: #000;
}

.btn-secondary {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
}

.btn-primary:hover {
  background: #eee;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Keyboard Shortcuts Help Overlay */
#help-overlay {
  position: fixed;
  top: 0;
  left: 60px;
  /* Start after sidebar */
  width: calc(100% - 60px);
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  /* Above everything */
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.3s ease;
}

#help-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.help-content {
  background: rgba(17, 17, 17, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  position: relative;
}

.help-content h2 {
  margin: 0 0 1.5rem 0;
  font-size: 1.5rem;
  color: #fff;
  text-align: center;
}

#help-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #aaa;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

#help-close:hover {
  color: #fff;
}

.shortcuts-grid {
  display: grid;
  gap: 1rem;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.shortcut-item kbd {
  min-width: 50px;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-family: monospace;
  font-size: 1rem;
  color: #fff;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shortcut-item span {
  flex: 1;
  color: #ccc;
  font-size: 0.95rem;
}

/* Guide Block Video */
.guide-block-video {
  transition: background 0.2s;
}

.guide-block-video:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  z-index: 10;
}

#view-guide {
  z-index: 1500;
  /* Ensure on top */
}

/* New Guide Elements */
.guide-content-wrapper {
  position: relative;
  flex: 1;
  /* Take remaining space */
  display: flex;
  overflow: hidden;
  /* Contain scroll area */
  width: 100%;
}

.guide-now-line {
  position: absolute;
  left: 200px;
  /* Match channel name width */
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 0, 0, 0.7);
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

.guide-now-line::after {
  content: "NOW";
  position: absolute;
  top: -1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #d00;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 4px;
  border-radius: 2px;
  font-weight: bold;
}

.guide-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: #4ade80;
  /* Green accent */
  z-index: 20;
  box-shadow: 0 -1px 4px rgba(74, 222, 128, 0.5);
}

.guide-block-video.playing {
  border-bottom: 3px solid rgba(74, 222, 128, 0.2);
  /* Subtle indication */
}

.guide-block-video.playing:hover {
  border-bottom-color: rgba(74, 222, 128, 0.8);
}

.guide-channel-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  font-weight: bold;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.1);
}