/* ====================================================================
   MULTICAM.CSS — Hoja de estilos autónoma para /multicam
   ====================================================================
   Contiene TODO lo que /multicam necesita. No depende de
   /css/transmision/transmision.css. Si agregás algo nuevo a multicam,
   va acá, no en transmision.css.

   Organización:
     1. Variables
     2. Reset y base
     3. Layout principal (options-bar, container, cards)
     4. Player (streams-grid, stream-item, playerFrame)
     5. Chat (chat-card, twitchChat)
     6. Selectores por tile (custom-select, dropdowns)
     7. Controles sobre cada tile (modo video/web, URL)
     8. Modal URL personalizada
     9. Fullscreen
    10. Flyer banner
    11. Responsive
   ==================================================================== */

/* ====================================================================
   1. VARIABLES
   ==================================================================== */
:root {
  /* Colores */
  --bg-dark: #0b0d1b;
  --bg-card: rgba(20, 20, 40, 0.7);
  --text-primary: #ffffff;
  --text-secondary: #72d6ff;
  --text-muted: #8ea0bd;
  --accent: #72d6ff;
  --accent-purple: #ff7fff;
  --border-color: rgba(255, 255, 255, 0.1);
  --line: #ffffff1a;

  /* Espaciado */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 15px;
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 18px;
  --mobile-padding: 0.5rem;
  --touch-target: 44px;

  /* Streams */
  --streams-items: 1px;

  /* Bordes y sombras */
  --border-width: 1px;
  --border-radius-sm: 6px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius: 10px;
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.28);

  /* Transiciones */
  --transition: 0.2s ease;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  /* Layout */
  --header-height: 70px;
  --sidebar-width-desktop: 340px;
  --sidebar-width-tablet: 280px;
}

/* ====================================================================
   2. RESET Y BASE
   ==================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ====================================================================
   3. LAYOUT PRINCIPAL
   ==================================================================== */

/* ---------- Options Bar ---------- */
.options-bar {
  position: relative;
  width: 100%;
  background: #0a1220;
  border-bottom: 1px solid #1a2a3e;
  z-index: 20;
}

.menu-btn {
  background-color: rgba(50, 50, 50, 0.8);
  color: white;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 5px;
  width: 100%;
  text-align: center;
  margin: 0;
  z-index: 1000;
  font-size: 16px;
}

.menu-btn:hover {
  background-color: rgba(70, 70, 70, 0.8);
}

.card-header {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.card-header label {
  color: white;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- Menú desplegable ---------- */
.options-menu {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 10px;
  padding: 5px 8px;
  background: #0d1120;
  background-color: rgba(0, 0, 0, 0.7);
  border-bottom: 1px solid #1a2a3e;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  transition: opacity 0.5s ease, transform 0.5s ease;
  position: absolute;
  width: 100%;
  z-index: 20;
}

.options-menu[hidden] {
  display: none;
}

/* ---------- Botones ---------- */
select,
.btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background-color: rgba(6, 13, 22, 0.836);
  color: #fdfdfd;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  font-size: 0.9rem;
  min-height: 38px;
  line-height: 1.2;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.btn:hover,
select:hover {
  border-color: rgba(58, 106, 138, 0);
  background-color: rgba(99, 99, 99, 0.699);
}

#reloadBtn {
  border-color: rgba(114, 214, 255, 0.3);
  border: 1px solid var(--line);
  background-color: rgba(114, 214, 255, 0.05);
}

#reloadBtn:hover {
  background-color: rgba(70, 70, 70, 0.8);
  color: white;
}

#reloadBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Toggle buttons ---------- */
.chat-toggle,
.toggle-fullscreen,
.options-toggle {
display: flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0);
    border: 1px solid transparent;
    color: white;
    font-size: 12.5px;
    font-weight: 500;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.chat-toggle:hover,
.toggle-fullscreen:hover,
.options-toggle:hover {
    color: #9b9b9b;
    border-color: rgba(50, 50, 50, 0) !important;
    background-color: rgba(202, 37, 37, 0);}

.chat-toggle svg,
.toggle-fullscreen svg {
  width: 18px;
  height: 18px;
}

.toggle-fullscreen.active {
  background: rgba(159, 211, 255, 0.15);
  border-color: #9fd3ff;
  color: #ffffff;
}

/* ---------- Actions / divider ---------- */
.actions {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
}

.divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  flex-shrink: 0;
}

/* ---------- Contenedor principal (2 columnas: player + chat) ---------- */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width-desktop);
  position: relative;
  z-index: 2;
  align-content: stretch;
  justify-content: stretch;
  justify-items: stretch;
  flex: 1;
  isolation: isolate;
  min-height: 0;
}

.container.chat-hidden {
  grid-template-columns: 1fr;
}

/* ---------- Card base ---------- */
.card {
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: auto;
  min-height: 0;
}

/* ====================================================================
   4. PLAYER (streams-grid, stream-item)
   ==================================================================== */
.player-card {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #000;
  height: 100%;
  isolation: isolate;
  position: relative;
  padding: 0;
}

.streams-grid {
  display: grid;
  gap: var(--streams-items);
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
}

.streams-grid.layout-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.streams-grid.layout-2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; }
.streams-grid.layout-3 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.streams-grid.layout-3 .stream-item:last-child { grid-column: 1 / -1; }
.streams-grid.layout-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }

.stream-item {
  background: var(--bg-card);
  border: 2px solid transparent;
  overflow: visible;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

.stream-item:has(.select-dropdown.show) {
  z-index: 500;
}

.stream-content {
  flex: 1;
  aspect-ratio: 16 / 9;
  position: relative;
  background: #000;
  overflow: hidden;
  min-height: 0;
}

.stream-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
}

.stream-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  color: var(--text-secondary);
  background: #000;
}

.placeholder-icon { width: 56px; height: 56px; opacity: 0.3; color: var(--accent); }
.placeholder-text { font-size: 13px; color: var(--text-secondary); text-align: center; max-width: 220px; margin: 0; opacity: 0.9; }

/* ---------- iframe del player ---------- */
#playerFrame {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: none;
  background: transparent;
  flex: 1;
  overflow: hidden !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  position: relative;
  z-index: auto;
}

/* ====================================================================
   5. CHAT
   ==================================================================== */
.chat-card {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  overflow: hidden;
  min-height: 0;
  height: 100%;
  position: relative;
  isolation: isolate;
  z-index: auto;
  contain: layout style;
}

.chat-card.hidden {
  display: none;
}

#twitchChat {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  overflow: hidden;
  min-height: 0;
  position: relative;
  z-index: auto;
  display: block;
}

/* ---------- Scrollbar oculta en iframes ---------- */
#twitchChat::-webkit-scrollbar,
#playerFrame::-webkit-scrollbar,
#f1Telemetry::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

#twitchChat,
#playerFrame,
#f1Telemetry {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

/* ---------- Fix iframes (transform rompe rendering) ---------- */
body,
html,
.container,
.card,
.chat-card,
#twitchChat,
#playerFrame {
  transform: none !important;
  -webkit-transform: none !important;
  will-change: auto !important;
  backface-visibility: visible !important;
  perspective: none !important;
}

/* ====================================================================
   6. SELECTORES POR TILE (custom-select + dropdowns)
   ==================================================================== */
.tile-selectors {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  right: var(--space-sm);
  z-index: 40;
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  flex-wrap: wrap;
}

.stream-item:not(.active) .tile-selectors {
  opacity: 1;
}

.stream-item:not(.active) .select-trigger {
  width: auto;
  max-width: 100%;
}

.stream-item.active .tile-selectors {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.stream-item.active:hover .tile-selectors,
.stream-item.active .tile-selectors.force-visible {
  opacity: 1;
}

.custom-select { position: relative; z-index: 30; }
.custom-select.option-select { z-index: 1; }

.event-select { min-width: 200px; }
.option-select { min-width: 150px; }

.select-trigger {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  min-height: 40px;
}

.select-trigger:hover {
  background-color: rgba(30, 30, 60, 0.95);
  border-color: var(--accent);
}

.select-trigger.active,
.select-trigger.has-value {
  border-color: var(--accent);
  color: var(--text-primary);
}

.select-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  transition: transform var(--transition-fast), color var(--transition-fast);
  color: var(--text-secondary);
}

.select-trigger.active .select-icon {
  transform: rotate(180deg);
  color: var(--accent);
}

.select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(320px, 90vw);
  background: rgba(20, 20, 40, 0.98);
  border: 1px solid rgba(114, 214, 255, 0.25);
  border-radius: var(--radius-md);
  max-height: 360px;
  overflow: hidden;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  display: none;
  flex-direction: column;
}

.select-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  display: flex;
}

.dropdown-search {
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 30, 0.9);
}

.dropdown-search input {
  width: 100%;
  background: rgba(30, 30, 50, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px var(--space-md);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition-fast);
}

.dropdown-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.dropdown-search input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.dropdown-options {
  overflow-y: auto;
  max-height: 300px;
}

.dropdown-options::-webkit-scrollbar,
.option-select .select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.dropdown-options::-webkit-scrollbar-track,
.option-select .select-dropdown::-webkit-scrollbar-track {
  background: rgba(20, 20, 40, 0.6);
  border-radius: var(--radius-sm);
}

.dropdown-options::-webkit-scrollbar-thumb,
.option-select .select-dropdown::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: var(--radius-sm);
}

.option-select .select-dropdown {
  overflow-y: auto;
}

.dropdown-option {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 40px;
}

.dropdown-option:last-child { border-bottom: none; }
.dropdown-option:hover { background-color: rgba(114, 214, 255, 0.12); }
.dropdown-option.hidden { display: none; }
.dropdown-option.keyboard-focus { background-color: rgba(114, 214, 255, 0.16); }

.dropdown-option-custom {
  border-top: 1px dashed rgba(255, 107, 107, 0.25);
  opacity: 0.85;
}

.dropdown-option-custom:hover {
  opacity: 1;
  background-color: rgba(255, 107, 107, 0.08);
}

.picker-option-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 40px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px;
}

.option-group-header {
  padding: var(--space-sm) var(--space-lg);
  background: rgba(15, 15, 30, 0.9);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.option-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin: 0;
  opacity: 0.9;
}

.option-empty,
.option-no-results {
  padding: var(--space-lg);
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* ====================================================================
   7. CONTROLES SOBRE CADA TILE
   ==================================================================== */
.stream-controls-wrap {
  position: absolute;
  right: var(--space-sm);
  bottom: var(--space-sm);
  z-index: 25;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.stream-controls-wrap.hidden { display: none; }

.stream-item:hover .stream-controls-wrap:not(.hidden) { opacity: 1; }

.stream-mode-btn,
.stream-custom-url-btn {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(114, 214, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
}

.stream-mode-btn svg,
.stream-custom-url-btn svg { width: 12px; height: 12px; }

.stream-mode-btn.mode-video:hover,
.stream-custom-url-btn:hover {
  background-color: rgba(114, 214, 255, 0.15);
  border-color: var(--accent);
  color: var(--text-primary);
}

.stream-mode-btn.mode-web {
  background-color: rgba(255, 127, 255, 0.15);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.stream-mode-btn.mode-web:hover {
  background-color: rgba(255, 127, 255, 0.25);
  color: white;
}

/* ====================================================================
   8. MODAL URL PERSONALIZADA
   ==================================================================== */
.url-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.url-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.url-modal {
  background: rgba(15, 15, 35, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s ease;
}

.url-modal-overlay.show .url-modal {
  transform: translateY(0) scale(1);
}

.url-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.url-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #e8eaf0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.url-modal-close {
  background: transparent;
  border: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #5a5f7a;
  transition: color 0.2s;
  border-radius: 6px;
}

.url-modal-close:hover { color: #ff6b6b; }

.url-modal-hint {
  font-size: 12px;
  color: #5a5f7a;
  opacity: 0.7;
  margin-bottom: 14px;
  line-height: 1.5;
}

.url-modal-input-wrap {
  position: relative;
  margin-bottom: 16px;
}

.url-modal-input {
  width: 100%;
  background: rgba(20, 20, 50, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 44px 14px 16px;
  color: #e8eaf0;
  font-size: 14px;
  transition: border-color 0.2s, background-color 0.2s;
  font-family: 'Inter', monospace;
}

.url-modal-input:focus {
  outline: none;
  border-color: var(--accent);
  background-color: rgba(20, 20, 60, 0.9);
}

.url-modal-input::placeholder {
  color: #5a5f7a;
  opacity: 0.5;
}

.url-modal-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #5a5f7a;
  cursor: pointer;
  opacity: 0.5;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s;
}

.url-modal-clear:hover { opacity: 1; }

.url-modal-actions {
  display: flex;
  gap: 10px;
}

.url-modal-btn {
  flex: 1;
  border-radius: 10px;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.url-modal-btn.cancel {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.06);
  color: #5a5f7a;
}

.url-modal-btn.cancel:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e8eaf0;
}

.url-modal-btn.confirm {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.06);
  color: #5a5f7a;
}

.url-modal-btn.confirm:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #e8eaf0;
}

/* ====================================================================
   9. FULLSCREEN
   ==================================================================== */
body.fullscreen-mode .site-header,
body.fullscreen-mode .site-footer,
body.fullscreen-mode .options-bar {
  display: none;
}

body.fullscreen-mode .container { height: 100vh; }
body.fullscreen-mode .streams-grid { gap: 0; }
body.fullscreen-mode .stream-item { border-radius: 0; border: none; }
body.fullscreen-mode .stream-controls-wrap,
body.fullscreen-mode .tile-selectors {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ====================================================================
   10. FLYER BANNER
   ==================================================================== */
.flyer-banner {
  position: relative;
  width: 100%;
  background: linear-gradient(90deg, #0b0d1b 0%, #1a1f3a 50%, #0b0d1b 100%);
  border-bottom: 1px solid rgba(0, 230, 160, 0.3);
  color: #ffd54f;
  font-family: 'Inter', Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  z-index: 9999;
  height: 38px;
  display: flex;
  align-items: center;
}

.flyer-viewport {
  flex: 1;
  overflow: hidden;
  height: 100%;
  position: relative;
}

.flyer-track {
  display: flex;
  gap: 60px;
  white-space: nowrap;
  align-items: center;
  height: 100%;
}

.flyer-item {
  flex-shrink: 0;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.flyer-item a {
  color: #00e6a0;
  text-decoration: underline;
  font-weight: 700;
  transition: color 0.2s;
}

.flyer-item a:hover { color: #fff; }

.flyer-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffd54f;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
  z-index: 2;
  padding: 0;
}

.flyer-close:hover {
  background-color: rgba(255, 193, 7, 0.2);
  color: #fff;
  border-color: #ffd54f;
}

/* ====================================================================
   11. RESPONSIVE
   ==================================================================== */

/* ---------- Tablet ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width-desktop: var(--sidebar-width-tablet);
  }
}

@media (max-width: 1024px) {
  .stream-item { min-height: 280px; }
}

/* ---------- Móvil ---------- */
@media (max-width: 768px) {
  :root {
    --mobile-padding: 0.5rem;
    --gap-xs: 0.25rem;
    --gap-sm: 0.3rem;
  }

  .container,
  .container.chat-hidden {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto;
    grid-auto-flow: row;
    height: auto !important;
  }

  .options-bar {
    padding: 0;
    gap: 0.3rem;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    min-height: auto;
  }

  .options-menu {
    padding: 0.4rem 0.5rem;
    gap: 0.25rem;
  }

  select,
  .btn {
    width: auto;
    min-height: var(--touch-target);
    padding: 0 14px;
    font-size: 0.875rem;
    flex-shrink: 0;
  }

  .player-card,
  .chat-card {
    grid-column: 1 !important;
    grid-row: auto !important;
    width: 100%;
    height: auto;
    min-height: unset;
  }

  .player-card {
    order: 2;
    aspect-ratio: 16 / 9;
    align-self: start;
    position: relative;
  }

  #playerFrame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: unset;
  }

  .chat-card {
    order: 3;
    height: 60vh;
    min-height: 300px;
    max-height: 600px;
  }

  .card-header { min-height: 40px; }

  .streams-grid.layout-2,
  .streams-grid.layout-3,
  .streams-grid.layout-4 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(auto-fill, minmax(260px, auto));
  }

  .streams-grid.layout-3 .stream-item:last-child { grid-column: 1; }

  .stream-item { min-height: 240px; }

  .tile-selectors { flex-direction: column; }
  .event-select,
  .option-select { min-width: 0; width: 100%; }

  .url-modal { max-width: 95%; padding: 20px; }
  .url-modal-input { font-size: 16px; }
}

/* ---------- Móvil pequeño ---------- */
@media (max-width: 480px) {
  :root {
    --mobile-padding: 0.25rem;
  }

  .options-bar {
    gap: 0.25rem;
  }

  .options-menu .btn span,
  .options-menu .chat-toggle span,
  .options-menu .toggle-fullscreen span {
    display: none;
  }

  .options-menu .btn,
  .options-menu .chat-toggle,
  .options-menu .toggle-fullscreen {
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
  }

  .chat-card {
    height: 55vh;
    min-height: 260px;
  }

  .stream-item { min-height: 220px; }
  .select-dropdown { width: min(280px, 92vw); }

  .flyer-banner { font-size: 11px; height: 34px; }
  .flyer-track { gap: 40px; }
  .flyer-close {
    width: 20px;
    height: 20px;
    font-size: 10px;
    right: 6px;
  }
}

/* ---------- Landscape móvil ---------- */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    grid-template-columns: 1.5fr 1fr;
    grid-auto-flow: column;
    height: 100vh;
  }

  .player-card {
    grid-column: 1;
    grid-row: 1;
    order: 1;
    height: 100%;
    aspect-ratio: unset;
    align-self: stretch;
  }

  #playerFrame {
    position: static;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
  }

  .chat-card {
    grid-column: 2;
    grid-row: 1;
    order: 2;
    height: 100%;
    max-height: none;
  }
}

/* ---------- Touch targets ---------- */
@media (pointer: coarse) {
  .btn,
  select,
  .chat-toggle,
  .toggle-fullscreen,
  .options-toggle {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
  }
}

/* ---------- High DPI ---------- */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card { border-width: 0.5px; }
  .options-bar { border-bottom-width: 0.5px; }
  select,
  .btn { border-width: 0.5px; }
}

/* ---------- Modo oscuro del sistema ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-card: rgba(20, 20, 40, 0.8);
  }
}

/* ==================== FIN ==================== */