/* ==================== VARIABLES CSS MULTICAM ESPACIAL ==================== */
:root {
  --bg-dark: #0b0d1b;
  --bg-card: rgba(20, 20, 40, 0.85);
  --text-primary: #ffffff;
  --text-secondary: #72d6ff;
  --accent: #72d6ff;
  --accent-purple: #ff7fff;
  --border-color: rgba(255, 255, 255, 0.15);
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 15px;
  --streams-items: 1px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
  --panel-width: 350px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ==================== CONTAINER PRINCIPAL ==================== */
.multicam-container {
  display: flex;
  min-height: 100vh;
  background: #000014;
  position: relative;
  overflow: hidden;
}

.multicam-container::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse at top, #1a1f3b 0%, #0b0d1b 50%, #000014 100%),
    linear-gradient(135deg, rgba(114, 214, 255, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: -2;
}

/* ==================== STARFIELD ==================== */
#starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
}

.spiral-galaxy {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(60vw, 600px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center,
    rgba(114, 214, 255, 0.02) 0%,
    rgba(255, 127, 255, 0.02) 30%,
    transparent 70%);
  border-radius: 50%;
  z-index: -1;
}

.star {
  position: absolute;
  background: currentColor;
  border-radius: 50%;
  opacity: 0.8;
  z-index: -1;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.star.layer-1 { color: rgba(255, 255, 255, 0.9); }
.star.layer-2 { color: rgba(255, 255, 255, 0.7); }
.star.layer-3 { color: rgba(255, 255, 255, 0.5); }

/* ==================== PANEL DE CONTROL ==================== */
.control-panel {
  width: var(--panel-width);
  background: 
    radial-gradient(circle at 30% 50%, rgba(114, 214, 255, 0.08), transparent 30%),
    radial-gradient(circle at 70% 50%, rgba(255, 127, 255, 0.08), transparent 30%),
    rgba(15, 15, 30, 0.95);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 0;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

/* PC: colapsa hacia la izquierda */
.control-panel.collapsed {
  transform: translateX(-100%);
  width: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.control-panel::-webkit-scrollbar { width: 6px; }
.control-panel::-webkit-scrollbar-track { background: transparent; }
.control-panel::-webkit-scrollbar-thumb { background: var(--accent); border-radius: var(--radius-sm); }
.control-panel::-webkit-scrollbar-thumb:hover { background: var(--accent-purple); }

/* ==================== HEADER DEL PANEL ==================== */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) var(--space-xl);
  border-bottom: 1px solid var(--border-color);
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(114, 214, 255, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(255, 127, 255, 0.12), transparent 50%),
    rgba(20, 20, 40, 0.8);
  position: relative;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.panel-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-purple), transparent);
  opacity: 0.6;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.panel-title::before {
  content: '●';
  color: var(--accent);
  font-size: 10px;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  text-shadow: 0 0 10px var(--accent);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.panel-collapse-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  position: relative;
  overflow: hidden;
}

.panel-collapse-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.2), rgba(255, 127, 255, 0.2));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.panel-collapse-btn:hover {
  background: rgba(114, 214, 255, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(114, 214, 255, 0.3);
}

.panel-collapse-btn:hover::before { opacity: 1; }

.panel-collapse-btn svg {
  width: 18px;
  height: 18px;
  position: relative;
  z-index: 1;
}

/* ==================== SECCIONES DEL PANEL ==================== */
.control-section {
  padding: var(--space-xl);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.control-section:last-child { border-bottom: none; }

.control-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin: 0 0 var(--space-lg) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.control-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-color), transparent);
}

/* ==================== LAYOUT GRID ==================== */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.layout-option {
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  position: relative;
  overflow: hidden;
}

.layout-option::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(114, 214, 255, 0.2), transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.layout-option svg {
  width: 22px;
  height: 22px;
  opacity: 0.6;
  transition: all var(--transition-fast);
  position: relative;
  z-index: 1;
}

.layout-option span {
  font-size: 11px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.layout-option:hover { border-color: var(--accent); box-shadow: 0 0 20px rgba(114, 214, 255, 0.3); }
.layout-option:hover::before { opacity: 1; }
.layout-option:hover svg { opacity: 1; transform: scale(1.1); }

.layout-option.active {
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.25), rgba(255, 127, 255, 0.25));
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 20px rgba(114, 214, 255, 0.4);
}

.layout-option.active svg { opacity: 1; }

/* ==================== FILTER BUTTONS ==================== */
.filter-buttons {
  display: flex;
  gap: var(--space-sm);
}

.filter-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(114, 214, 255, 0.4);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  min-height: 40px;
}

.filter-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.1), rgba(255, 127, 255, 0.1));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.filter-btn svg { width: 16px; height: 16px; position: relative; z-index: 1; }
.filter-btn span { position: relative; z-index: 1; }

.filter-btn:hover { border-color: var(--accent); background: rgba(114, 214, 255, 0.12); }
.filter-btn:hover::before { opacity: 1; }

.filter-btn.active {
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.25), rgba(255, 127, 255, 0.25));
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 20px rgba(114, 214, 255, 0.4);
}

/* ==================== STREAM SELECTORS ==================== */
.streams-section { flex: 1; }

.stream-selector { margin-bottom: var(--space-lg); }
.stream-selector:last-child { margin-bottom: 0; }

.selector-label { display: block; margin-bottom: var(--space-sm); padding-left: 4px; }

.screen-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.screen-number::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
}

.custom-select { position: relative; }

.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: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: left;
  min-height: 44px;
}

.select-trigger:hover { background: rgba(30, 30, 60, 0.95); border-color: var(--accent); }

.select-trigger.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(114, 214, 255, 0.1);
  color: var(--text-primary);
}

.select-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.select-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  transition: transform 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;
  right: 0;
  background: rgba(20, 20, 40, 0.98);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow: hidden;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-normal);
  display: none;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.select-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  display: flex;
  animation: dropdownFadeIn 0.2s ease;
}

.dropdown-search {
  padding: var(--space-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 30, 0.9);
  position: relative;
  top: 0;
  z-index: 10;
}

.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: all var(--transition-fast);
}

.dropdown-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(114, 214, 255, 0.1); }
.dropdown-search input::placeholder { color: var(--text-secondary); opacity: 0.6; }

.dropdown-options { overflow-y: auto; max-height: 340px; }
.dropdown-options::-webkit-scrollbar { width: 6px; }
.dropdown-options::-webkit-scrollbar-track { background: rgba(20, 20, 40, 0.6); border-radius: var(--radius-sm); }
.dropdown-options::-webkit-scrollbar-thumb { background: var(--accent); border-radius: var(--radius-sm); }

.dropdown-option {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 44px;
}

.dropdown-option:last-child { border-bottom: none; }
.dropdown-option:hover { background: rgba(114, 214, 255, 0.12); padding-left: 20px; }
.dropdown-option.hidden { display: none; }

.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);
  top: 49px;
  z-index: 5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.option-title { font-size: 14px; font-weight: 500; color: var(--text-primary); margin: 0 0 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option-meta { font-size: 12px; color: var(--text-secondary); margin: 0; opacity: 0.9; }

/* ==================== ACTION BUTTONS ==================== */
.actions-section { margin-top: auto; padding-top: var(--space-xl); }

.action-btn {
  width: 100%;
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.25), rgba(255, 127, 255, 0.25));
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 16px var(--space-xl);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(114, 214, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-height: 52px;
}

.action-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.action-btn:hover { transform: translateY(-2px); box-shadow: 0 0 30px rgba(114, 214, 255, 0.5); }
.action-btn:hover::before { left: 100%; }
.action-btn svg { width: 20px; height: 20px; }

/* ==================== VIEWER AREA ==================== */
.viewer-area {
  flex: 1;
  overflow: hidden;
  transition: all var(--transition-normal);
  position: relative;
  z-index: 2;
  width: 100%;
}

.multicam-container:has(.control-panel.collapsed) .viewer-area {
  width: 100%;
  margin-left: 0;
}

.control-panel.collapsed ~ .viewer-area {
  width: 100%;
  margin-left: 0;
}

.streams-grid {
  display: grid;
  gap: var(--streams-items);
  height: 100%;
  width: 100%;
  transform: translate3d(0, 0, 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 ==================== */
.stream-item {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  position: relative;
  box-shadow: var(--shadow-md);
  min-height: 450px;
}

.stream-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  opacity: 0;
  transition: opacity var(--transition-normal);
  z-index: 3;
}

.stream-item.active { border-color: var(--accent); box-shadow: 0 0 30px rgba(114, 214, 255, 0.3); }

.stream-header {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-color);
  background: rgba(40, 40, 70, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  flex-shrink: 0;
}

.stream-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(30, 30, 50, 0.8);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stream-item.active .stream-badge {
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.25), rgba(255, 127, 255, 0.25));
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(114, 214, 255, 0.3);
}

.stream-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.stream-item.active .stream-title { color: var(--text-primary); }

.stream-content { flex: 1; 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: radial-gradient(circle at 50% 50%, rgba(114, 214, 255, 0.05), transparent 70%), #000;
}

.placeholder-icon { width: 64px; height: 64px; opacity: 0.3; color: var(--accent); animation: gentlePulse 3s ease-in-out infinite; }

@keyframes gentlePulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.05); }
}

.placeholder-text { font-size: 14px; color: var(--text-secondary); text-align: center; max-width: 240px; margin: 0; opacity: 0.9; }

/* ==================== FULLSCREEN MODE ==================== */
body.fullscreen-mode { overflow: hidden; }

body.fullscreen-mode .site-header,
body.fullscreen-mode .site-footer { display: none; }

body.fullscreen-mode .multicam-container { height: 100vh; }

body.fullscreen-mode .control-panel {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 10000;
}

body.fullscreen-mode .viewer-area { padding: 0; margin-left: var(--panel-width); }
body.fullscreen-mode .control-panel.collapsed ~ .viewer-area { margin-left: 0; }
body.fullscreen-mode .streams-grid { gap: 0; }

body.fullscreen-mode .stream-item {
  border-radius: 0;
  border: none;
  min-height: 0;
  height: 100%;
}

.exit-fullscreen-btn {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-xl);
  cursor: pointer;
  z-index: 10001;
  display: none;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
  transition: all var(--transition-normal);
  min-height: 48px;
}

.exit-fullscreen-btn:hover {
  background: rgba(20, 20, 40, 0.98);
  border-color: var(--accent-purple);
  transform: scale(1.05);
  box-shadow: 0 0 40px rgba(255, 127, 255, 0.6);
}

body.fullscreen-mode .exit-fullscreen-btn { display: flex; }

/* ==================== PANEL COLLAPSE BTN - flecha apunta a la izquierda en PC ==================== */
/* La flecha SVG del botón colapsar (‹) ya apunta izquierda por defecto — OK en PC */
/* En mobile se rota abajo via media query */

/* ==================== PANEL EXPAND BUTTON ==================== */
/* PC: aparece a la izquierda, centrado verticalmente */
.panel-expand-btn {
  position: fixed;
  left: var(--space-xl);
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  z-index: 99;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              left var(--transition-normal),
              opacity var(--transition-normal);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
}

/* La flecha del expand apunta a la DERECHA en PC (para abrir el panel que está a la izquierda) */
/* El SVG del JS tiene points="9 18 15 12 9 6" que apunta derecha — correcto */

.panel-expand-btn.show {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.panel-expand-btn:hover {
  background: rgba(114, 214, 255, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 25px rgba(114, 214, 255, 0.4);
}

.panel-expand-btn svg { width: 24px; height: 24px; }

/* ── FULLSCREEN: botón se oculta deslizándose al borde izquierdo ── */
body.fullscreen-mode .panel-expand-btn.show {
  left: -46px; /* se esconde fuera de pantalla */
  opacity: 0.15;
  transition: left var(--transition-normal),
              opacity var(--transition-normal);
}

/* Zona de hover invisible a la izquierda que lo hace reaparecer */
body.fullscreen-mode .panel-expand-btn.show:hover {
  left: var(--space-xl);
  opacity: 1;
}

/* También reaparece si el mouse está cerca del borde izquierdo
   usando un pseudo-elemento que actúa como zona de detección */
body.fullscreen-mode .panel-expand-btn.show::before {
  content: '';
  position: absolute;
  left: 0;
  top: -60px;
  width: 60px;  /* zona de detección más ancha que el botón */
  height: 160px; /* zona vertical generosa */
  cursor: pointer;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  :root { --panel-width: 320px; }
  
  .layout-2,
  .layout-3,
  .layout-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: minmax(400px, 1fr);
  }
  
  .stream-item { min-height: 350px; }
}

/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  /* Container en columna: panel arriba, viewer abajo */
  .multicam-container {
    flex-direction: column;
    min-height: 100vh;
    overflow: visible;
  }

  /* Panel: ancho completo, aparece arriba */
  .control-panel {
    order: 0;
    width: 100% !important;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    max-height: 70vh;
    height: auto;
    overflow-y: auto;
    flex-shrink: 0;
    /* Sin transform en mobile */
    transform: none !important;
    transition: max-height var(--transition-normal),
                opacity var(--transition-normal),
                padding var(--transition-normal),
                border var(--transition-normal);
  }

  /* Viewer: crece para ocupar el espacio restante */
  .viewer-area {
    order: 1;
    flex: 1;
    min-height: 0;
  }

  /* Panel COLAPSADO en mobile: se encoge a 0 sin dejar hueco */
  .control-panel.collapsed {
    max-height: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border: none !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    margin: 0 !important;
    flex: none !important;
    transform: none !important;
  }

  /* Viewer se expande al colapsar el panel */
  .control-panel.collapsed ~ .viewer-area {
    flex: 1;
  }

  /* Botón expand en mobile: centrado horizontal, pegado al borde superior */
  .panel-expand-btn {
    left: 50% !important;
    top: 8px !important;
    transform: translateX(-50%) !important;
  }

  .panel-expand-btn:hover {
    transform: translateX(-50%) scale(1.1) !important;
  }

  /* Rotar la flecha del botón colapsar (ahora apunta abajo) */
  .panel-collapse-btn svg {
    transform: rotate(90deg);
  }


  .layout-2,
  .layout-3,
  .layout-4 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(auto-fill, minmax(400px, auto));
  }

  .layout-3 .stream-item:last-child { grid-column: 1; }

  body.fullscreen-mode .control-panel { position: relative; }
  body.fullscreen-mode .viewer-area { margin-left: 0; }
}

@media (max-width: 640px) {
  .panel-header { padding: var(--space-lg); }
  .control-section { padding: var(--space-lg); }
  .layout-grid { gap: var(--space-sm); }
  .filter-btn { padding: 10px var(--space-md); font-size: 12px; }
  .stream-header { padding: var(--space-md) var(--space-lg); }
  .stream-item { min-height: 300px; }

  .layout-1,
  .layout-2,
  .layout-3,
  .layout-4 {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(auto-fill, minmax(300px, auto));
  }
}

@media (max-width: 480px) {
  .stream-item { min-height: 280px; }
  .spiral-galaxy { display: none; }
}

/* ==================== LOADING STATES ==================== */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(114, 214, 255, 0.1);
  border-top-color: var(--accent);
  border-right-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 30px rgba(114, 214, 255, 0.2);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.stream-item { animation: fadeIn var(--transition-slow) ease-out; }
.stream-item:nth-child(1) { animation-delay: 0ms; }
.stream-item:nth-child(2) { animation-delay: 100ms; }
.stream-item:nth-child(3) { animation-delay: 200ms; }
.stream-item:nth-child(4) { animation-delay: 300ms; }

/* ==================== ACCESSIBILITY ==================== */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==================== UTILITY CLASSES ==================== */
.text-glow { text-shadow: 0 0 10px var(--accent); }
.box-glow { box-shadow: 0 0 20px rgba(114, 214, 255, 0.3); }

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==================== CORRECCIONES ESPECÍFICAS ==================== */
#selector-1 { order: 1; }
#selector-2 { order: 2; }
#selector-3 { order: 3; }
#selector-4 { order: 4; }

#stream-1 { order: 1; }
#stream-2 { order: 2; }
#stream-3 { order: 3; }
#stream-4 { order: 4; }

@media (max-width: 768px) {
  .control-panel {
    height: auto !important;
    max-height: 70vh !important;
    overflow-y: auto !important;
  }

  .control-panel.collapsed {
    max-height: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    border: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    margin: 0 !important;
    flex: none !important;
    transform: none !important;
  }

  .streams-section { max-height: none !important; overflow-y: visible !important; }

  .streams-grid.layout-1,
  .streams-grid.layout-2,
  .streams-grid.layout-3,
  .streams-grid.layout-4 {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
  }

  .streams-grid.layout-3 .stream-item:last-child { grid-column: 1 !important; }
}
/* FIN DE CORRECCIONES */

/* ==================== FIX MOBILE ALTURA VIEWER ==================== */
html, body {
  height: 100%;
}

@media (max-width: 768px) {
  html, body {
    height: 100%;
  }

  /* El main container debe ocupar todo el alto disponible */
  .multicam-container {
    height: 100%;
    min-height: 100%;
    flex-direction: column;
    overflow: visible;
  }

  /* El viewer necesita altura explícita, no solo flex:1 */
  .viewer-area {
    flex: 1 1 auto;
    height: 0; /* truco: fuerza al flex a calcular correctamente */
    min-height: 300px;
    overflow-y: auto;
  }

  /* El grid no puede depender de height:100% si el padre no tiene altura fija */
  .streams-grid {
    height: auto !important;
    min-height: 100%;
  }

  /* stream-item ocupa todo el espacio disponible en layout-1 */
  .streams-grid.layout-1 .stream-item {
    min-height: calc(100vh - 60px); /* 60px = header del sitio aprox */
  }

  /* Cuando el panel está colapsado, el stream ocupa aún más */
  .control-panel.collapsed ~ .viewer-area {
    flex: 1 1 auto;
    height: 0;
    min-height: 400px;
  }

  .control-panel.collapsed ~ .viewer-area .streams-grid.layout-1 .stream-item {
    min-height: calc(100vh - 60px);
  }
}
/* ==================== FIN FIX ==================== */

/* ==================== FIX FOOTER / SCROLL MOBILE ==================== */
@media (max-width: 768px) {
  /* Ocultar footer en mobile — no tiene sentido en una app de video */
  .site-footer {
    display: none !important;
  }

 

 



  /* El stream-item en layout-1 ocupa exactamente el espacio del viewer */
  .streams-grid.layout-1 .stream-item {
    min-height: 0 !important;
    height: 100% !important;
  }

  /* Para layouts multi-pantalla, cada stream tiene una altura mínima razonable */
  .streams-grid.layout-2 .stream-item,
  .streams-grid.layout-3 .stream-item,
  .streams-grid.layout-4 .stream-item {
    min-height: 260px;
  }
}


/* ==================== MODAL URL PERSONALIZADA ==================== */
.url-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
  padding: var(--space-lg);
}

.url-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.url-modal {
  background:
    radial-gradient(ellipse at top left, rgba(114, 214, 255, 0.1), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(255, 127, 255, 0.1), transparent 60%),
    rgba(15, 15, 35, 0.98);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(114, 214, 255, 0.1);
  transform: translateY(16px) scale(0.97);
  transition: transform var(--transition-normal);
  position: relative;
}

.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: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.url-modal-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.url-modal-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: 18px;
  line-height: 1;
}

.url-modal-close:hover {
  background: rgba(255, 127, 255, 0.15);
  border-color: var(--accent-purple);
  color: white;
}

.url-modal-hint {
  font-size: 12px;
  color: var(--text-secondary);
  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 var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 44px 14px 16px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition-fast);
  font-family: 'Inter', monospace;
}

.url-modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(114, 214, 255, 0.12);
  background: rgba(20, 20, 60, 0.9);
}

.url-modal-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.url-modal-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0.5;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: opacity var(--transition-fast);
}

.url-modal-clear:hover { opacity: 1; }

.url-modal-actions {
  display: flex;
  gap: var(--space-sm);
}

.url-modal-btn {
  flex: 1;
  border-radius: var(--radius-md);
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.url-modal-btn.cancel {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.url-modal-btn.cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.url-modal-btn.confirm {
  background: linear-gradient(135deg, rgba(114, 214, 255, 0.25), rgba(255, 127, 255, 0.25));
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 16px rgba(114, 214, 255, 0.2);
}

.url-modal-btn.confirm:hover {
  box-shadow: 0 0 28px rgba(114, 214, 255, 0.45);
  transform: translateY(-1px);
}

/* Botón flotante en cada stream para abrir el modal */
.stream-custom-url-btn {
  position: absolute;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(114, 214, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  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: all var(--transition-fast);
  opacity: 0;
  backdrop-filter: blur(4px);
}

.stream-item:hover .stream-custom-url-btn {
  opacity: 1;
}

.stream-custom-url-btn:hover {
  background: rgba(114, 214, 255, 0.15);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 16px rgba(114, 214, 255, 0.3);
}

.stream-custom-url-btn svg {
  width: 12px;
  height: 12px;
}

/* ==================== STREAM CONTROLS (modo + URL) ==================== */
.stream-controls-wrap {
  position: absolute;
  right: 1px;
  z-index: 10;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.stream-item:hover .stream-controls-wrap {
  opacity: 1;
}

/* Botón modo video/web */
.stream-mode-btn {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(114, 214, 255, 0.3);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  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: all var(--transition-fast);
  backdrop-filter: blur(4px);
}

.stream-mode-btn svg {
  width: 12px;
  height: 12px;
}

.stream-mode-btn.mode-video:hover {
  background: rgba(114, 214, 255, 0.15);
  border-color: var(--accent);
  color: var(--text-primary);
  box-shadow: 0 0 16px rgba(114, 214, 255, 0.3);
}

/* Cuando está en modo web se resalta para que el usuario sepa que está activo */
.stream-mode-btn.mode-web {
  background: rgba(255, 127, 255, 0.15);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(255, 127, 255, 0.25);
}

.stream-mode-btn.mode-web:hover {
  background: rgba(255, 127, 255, 0.25);
  box-shadow: 0 0 20px rgba(255, 127, 255, 0.4);
  color: white;
}

/* Reubicar el botón URL propia — ya no necesita position absolute propio */
.stream-controls-wrap .stream-custom-url-btn {
  position: static;
  opacity: 1;
}
/* ==================== FIN FIX FOOTER ==================== */

/* ==================== SUBMENU PARA OPCIONES MÚLTIPLES ==================== */
.dropdown-option-parent {
  position: relative;
  cursor: pointer;
}

.dropdown-option-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  transition: all var(--transition-fast);
}

.dropdown-option-parent:hover .dropdown-option-main {
  background: rgba(114, 214, 255, 0.08);
}

.option-arrow {
  color: var(--text-secondary);
  font-size: 10px;
  transition: transform var(--transition-fast);
}

.dropdown-option-parent.submenu-open .option-arrow {
  transform: rotate(90deg);
  color: var(--accent);
}

.dropdown-submenu {
  display: none;
  background: rgba(25, 25, 45, 0.98);
  border-left: 2px solid var(--accent);
  margin-left: var(--space-lg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow: hidden;
}

.dropdown-option-parent.submenu-open .dropdown-submenu {
  display: block;
  animation: submenuFadeIn 0.2s ease;
}

@keyframes submenuFadeIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.dropdown-submenu-header {
  padding: 8px var(--space-lg);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: rgba(114, 214, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dropdown-submenu-option {
  padding: 10px var(--space-lg);
  padding-left: calc(var(--space-lg) + 16px);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.dropdown-submenu-option:hover {
  background: rgba(114, 214, 255, 0.12);
  color: var(--text-primary);
  padding-left: calc(var(--space-lg) + 20px);
}

.dropdown-submenu-option:last-child {
  border-bottom: none;
}