/* ==========================================================================
   GRAVEL TV — MULTI-WINDOW VIEW WALL STYLES
   Edge-to-Edge, Borderless, Immersive 6-Window Grid
   ========================================================================== */

:root {
  --bg-wall: #000000;
  --bg-panel: rgba(18, 18, 22, 0.88);
  --bg-card: rgba(28, 28, 36, 0.7);
  --bg-card-hover: rgba(40, 40, 52, 0.85);
  --accent-color: #ff6200;
  --accent-hover: #ff7824;
  --accent-glow: rgba(255, 98, 0, 0.35);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 98, 0, 0.6);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-med: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-wall);
  color: var(--text-main);
  font-family: var(--font-family);
  user-select: none;
}

/* User idle state: hide cursor and floating controls */
body.user-idle {
  cursor: none;
}

body.user-idle .floating-controls,
body.user-idle .return-grid-pill,
body.user-idle .slot-badge {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.8s ease;
}

/* ==========================================================================
   VIDEO WALL GRID (BORDERLESS & EDGE-TO-EDGE)
   ========================================================================== */

.grid-wall {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  background: #000;
  display: grid;
  gap: 0; /* Strictly borderless */
  z-index: 1;
}

/* 6-Window Multiplay Layout: 3 Columns x 2 Rows */
.grid-wall.mode-multi {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

/* Responsive fallback on portrait / tall screens */
@media (max-aspect-ratio: 1/1) {
  .grid-wall.mode-multi {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
}

/* Single Screen Mode: Focused screen occupies entire 100vw x 100vh */
.grid-wall.mode-single .screen-slot {
  display: none !important;
}

.grid-wall.mode-single .screen-slot.active-solo {
  display: block !important;
  grid-column: 1 / -1 !important;
  grid-row: 1 / -1 !important;
  width: 100vw !important;
  height: 100vh !important;
}

/* ==========================================================================
   INDIVIDUAL SCREEN SLOT
   ========================================================================== */

.screen-slot {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
  cursor: pointer;
}

/* Video Container & Players */
.video-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
}

.video-container iframe,
.video-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  display: block;
}

/* Video Scaling Options */
.video-container video {
  object-fit: cover;
}

.fit-contain .video-container video,
.fit-contain .video-container iframe {
  object-fit: contain;
}

/* Make iframe fill edge to edge */
.video-container iframe {
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* Overlay Badge for Screen Number & Race Title */
.slot-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
  transition: opacity var(--transition-med);
}

.slot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  transition: opacity var(--transition-med);
}

.slot-badge .badge-num {
  background: var(--accent-color);
  color: #000;
  font-weight: 800;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
}

/* Audio Indicator (Equalizer wave animation when audio is unmuted on this screen) */
.slot-audio-indicator {
  display: none;
  align-items: flex-end;
  gap: 2.5px;
  height: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--accent-glow);
}

.slot-audio-indicator.is-active {
  display: inline-flex;
}

.slot-audio-indicator span {
  width: 3px;
  background-color: var(--accent-color);
  border-radius: 1px;
  animation: audioWave 1s ease-in-out infinite alternate;
}

.slot-audio-indicator span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.slot-audio-indicator span:nth-child(2) { height: 14px; animation-delay: 0.3s; }
.slot-audio-indicator span:nth-child(3) { height: 9px; animation-delay: 0.2s; }

@keyframes audioWave {
  0% { height: 4px; }
  100% { height: 15px; }
}

/* Subtle Active Screen Glow in Multiplay when hovered or selected */
.screen-slot.audio-active::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 98, 0, 0.5);
  pointer-events: none;
  z-index: 9;
  transition: border-color var(--transition-fast);
}

/* Drag & Drop Overlay */
.drop-zone-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 98, 0, 0.85);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.screen-slot.drag-over .drop-zone-overlay {
  display: flex;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}

/* ==========================================================================
   AUTO-HIDING FLOATING CONTROL BAR (TOP-RIGHT CORNER)
   ========================================================================== */

.floating-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 14, 18, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  padding: 6px 8px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 100;
  transition: opacity var(--transition-med), transform var(--transition-med);
}

.floating-controls:hover {
  opacity: 1 !important;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-1px);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-btn.btn-gear {
  color: var(--accent-color);
}

.ctrl-btn.btn-gear:hover {
  background: var(--accent-glow);
  color: #fff;
}

.ctrl-btn.is-muted {
  color: #ef4444;
}

/* Return to Grid Floating Pill (In Single Mode) */
.return-grid-pill {
  position: fixed;
  top: 16px;
  left: 16px;
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(14, 14, 18, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 100;
  transition: all var(--transition-fast);
}

.grid-wall.mode-single ~ .return-grid-pill {
  display: inline-flex;
}

.return-grid-pill:hover {
  background: var(--accent-color);
  color: #000;
  border-color: var(--accent-color);
  transform: translateY(-1px);
}

/* ==========================================================================
   FIRST CLICK / AUTOPLAY OVERLAY PROMPT
   ========================================================================== */

.first-click-prompt {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  cursor: pointer;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.first-click-prompt.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.prompt-card {
  background: rgba(22, 22, 28, 0.95);
  border: 1px solid rgba(255, 98, 0, 0.4);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px var(--accent-glow);
  padding: 40px 48px;
  border-radius: 20px;
  text-align: center;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.prompt-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 4px;
}

.prompt-card h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #fff;
}

.prompt-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.btn-start-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-color);
  color: #000;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: all var(--transition-fast);
}

.btn-start-action:hover {
  background: var(--accent-hover);
  transform: scale(1.03);
}

.prompt-hint {
  font-size: 11px;
  color: #6b7280;
  margin-top: 6px;
}

/* ==========================================================================
   SETTINGS & CONTROLS DIALOG (BEHIND GEAR ICON)
   ========================================================================== */

dialog.settings-modal {
  margin: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: var(--bg-panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: var(--text-main);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.85), 0 0 1px 1px rgba(255, 255, 255, 0.1);
  width: min(900px, 94vw);
  max-height: 88vh;
  padding: 0;
  overflow: hidden;
  z-index: 300;
}

dialog.settings-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: var(--accent-color);
  color: #000;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
}

.brand-title h2 {
  font-size: 18px;
  font-weight: 700;
}

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

.btn-icon-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  max-height: calc(88vh - 150px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Custom Scrollbar for modal body */
.modal-body::-webkit-scrollbar {
  width: 8px;
}
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-section h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.section-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-link-btn {
  background: transparent;
  border: none;
  color: var(--accent-color);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition-fast);
}

.text-link-btn:hover {
  background: var(--accent-glow);
}

/* View Mode Selector Group */
.mode-selector-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.mode-btn.active {
  background: var(--accent-color);
  color: #000;
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.single-screens-dropdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.screen-pills {
  display: flex;
  gap: 6px;
}

.screen-pill {
  flex: 1;
  padding: 6px 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.screen-pill:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.3);
}

.screen-pill.active {
  background: var(--accent-color);
  color: #000;
  border-color: var(--accent-color);
}

/* Audio & Settings Row */
.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.toggle-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-card);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.toggle-card label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.action-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn-sm:hover {
  background: rgba(255, 255, 255, 0.16);
}

.select-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.select-input:focus {
  border-color: var(--accent-color);
}

.select-input option {
  background: #18181f;
  color: #fff;
}

/* Channels List (Slots 1 to 6) */
.channels-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 10px 14px;
  border-radius: 12px;
  transition: border-color var(--transition-fast);
}

.channel-card:focus-within {
  border-color: var(--border-focus);
}

.channel-badge-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--accent-color);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.channel-inputs-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
}

.channel-title-input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  outline: none;
}

.channel-url-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  color: #e5e7eb;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  font-family: monospace;
}

.channel-url-input:focus {
  border-color: var(--accent-color);
}

.channel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-upload-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-upload-file:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Modal Footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.footer-shortcuts {
  font-size: 11px;
  color: var(--text-muted);
}

.footer-shortcuts b {
  color: #e5e7eb;
}

.btn-primary-done {
  background: var(--accent-color);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary-done:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
