/**
 * EPG Cards CSS - Estilos para el módulo de cards del EPG
 * Modal fullscreen con experiencia tipo Netflix/Pluto TV
 */

/* ============================================
   MODAL FULLSCREEN
   ============================================ */

.epg-cards-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
}

.epg-cards-modal.active {
  display: block;
}

.epg-cards-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1;
}

.epg-cards-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.epg-cards-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1em;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}

.epg-cards-close {
  width: 3em;
  height: 3em;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 0.2em solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 1.5em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* transition: all 0.2s ease; */ /* DESHABILITADO para mejor rendimiento en TVs */
}

.epg-cards-close:hover,
.epg-cards-close:focus {
  background: rgba(255, 255, 255, 0.3);
  /* transform: scale(1.1); */ /* DESHABILITADO para mejor rendimiento en TVs */
}

.epg-cards-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2em;
  padding-top: 1.2em; /* Ya no necesitamos reservar para el time-header sticky */
  /* scroll-behavior: smooth; */ /* DESHABILITADO para mejor rendimiento en TVs */
  -webkit-overflow-scrolling: touch;
}

/* Cabecera fija fuera del scroll (opción A) */
.epg-cards-time-header {
  flex: 0 0 auto;
  background: #1a1a1a;
  padding: 1em 2em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0.6em 1.2em rgba(0, 0, 0, 0.6);
  z-index: 6;
}

.epg-cards-content::-webkit-scrollbar {
  width: 0.8em;
}

.epg-cards-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.4em;
}

.epg-cards-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 0.4em;
}

.epg-cards-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* ============================================
   DISEÑO CUADRÍCULA EPG TRADICIONAL
   Estilo EPG tradicional mejorado con degradados
   Optimizado para rendimiento en TVs
   ============================================ */

/* Contenedor principal de cuadrícula */
.epg-grid-container {
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  width: 100%;
  min-height: 100%;
  padding-bottom: 2em; /* Espacio al final para scroll */
}

/* Encabezado de tiempo: misma cuadrícula que filas (200px + 3 columnas) */
.epg-time-header {
  display: grid;
  grid-template-columns: 200px 1fr 1fr 1fr;
  gap: 0;
  padding: 0;
  background: transparent;
}

/* Cabecera de tiempo con 4 columnas (cuando epgPast está habilitado) */
.epg-time-header.epg-time-header-four-cols {
  grid-template-columns: 200px 1fr 1fr 1fr 1fr;
}

.epg-time-header-spacer {
  /* Celda vacía alineada con la columna de canales */
}

.epg-time-label {
  font-size: 2em;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  padding: 0.5em;
  border-right: 2px solid rgb(255 255 255);
}

.epg-time-label:last-child {
  border-right: none;
}

/* Fila de canal */
.epg-channel-row {
  display: grid;
  grid-template-columns: 200px 1fr; /* Canal fijo + programas flexibles */
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
}

/* Sección del canal (izquierda) */
.epg-channel-info {
  background: #1a1a1a;
  padding: 1em 0.5em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5em;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

.epg-channel-info.active {
  background: var(--epg-cards-channel-active-bg, #3B699D);
}

.epg-channel-info:focus {
  outline: 0.3em solid #3498db;
  outline-offset: -0.3em;
  z-index: 10;
}

.epg-channel-number {
  font-size: 1.5em;
  font-weight: bold;
  color: #fff;
  line-height: 1.2;
}

/* Logo del canal: elemento principal en la columna (sin filtrar a blanco para ver colores) */
.epg-channel-logo {
  width: 9.5em;
  /* max-height: 56px; */
  object-fit: contain;
  display: block;
}

.epg-channel-name {
  font-size: 1em;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  line-height: 1.2;
  word-wrap: break-word;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Contenedor de programas (derecha) */
.epg-programs-container {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  width: 100%;
}

/* Tres columnas fijas: Ahora | A Continuación | Más Tarde (sin scroll horizontal) */
.epg-programs-container.epg-programs-three-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  overflow: visible;
  gap: 0;
}

/* Cuatro columnas fijas: Antes | Ahora | A Continuación | Más Tarde (cuando epgPast está habilitado) */
.epg-programs-container.epg-programs-four-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  overflow: visible;
  gap: 0;
}

.epg-program-slot-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  background: rgba(255, 255, 255, 0.03);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.epg-program-slot-empty:focus {
  outline: 0.3em solid #3498db;
  outline-offset: -0.3em;
  z-index: 10;
  background: rgba(255, 255, 255, 0.1);
}

.epg-slot-empty-label {
  color: rgba(255, 255, 255, 0.3);
  font-size: 1.2em;
}

.epg-channel-name-only {
  font-size: 0.9em;
  line-clamp: 3;
  -webkit-line-clamp: 3;
}

.epg-programs-container::-webkit-scrollbar {
  height: 0.4em;
}

.epg-programs-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.epg-programs-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 0.2em;
}

/* Card de programa */
.epg-program-card {
  background: #2a2a2a;
  padding: 1em;
  border-right: 1px solid rgba(255, 255, 255);
  position: relative;
  min-width: 250px;
  min-height: 120px;
  max-height: 15em;
  overflow: hidden;       /* El contenido extra se recorta dentro de la card */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-sizing: border-box;
  cursor: pointer;
}

.epg-program-card:focus {
  outline: 0.3em solid #3498db;
  outline-offset: -0.3em;
  z-index: 10;
  background: rgba(255, 255, 255, 0.1);
}

.epg-program-card.live {
  background: var(--epg-cards-program-live-bg, #F58225);
}

.epg-program-card.live:focus {
  background: var(--epg-cards-program-live-bg, #F58225);
}

.epg-program-title {
  font-size: xx-large;
  /* font-weight: bold; */
  color: #fff;
  margin-bottom: 0.3em;
  line-height: 1.15;
  word-wrap: break-word;
  /* Limitar a un número fijo de líneas para que no crezca la altura de la card */
  display: -webkit-box;
  line-clamp: 2;
  /* -webkit-line-clamp: 2; */
  -webkit-box-orient: vertical;
}

.epg-program-meta {
  font-size: 1em;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.3em;
  /* Evitar que textos largos empujen hacia abajo la hora/barra de progreso */
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.epg-program-time {
  font-size: 1.5em;
  color: rgba(255, 255, 255, 0.6);
}

/* Barra de progreso (solo en programas en vivo) */
.epg-program-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: #fff;
  z-index: 2;
  height: 0.5em;
  border-radius: 0 7px 7px 0px;
}

/* Icono de menú (kebab menu) */
.epg-program-menu {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2em;
  cursor: pointer;
  padding: 0.3em;
  line-height: 1;
  width: 2em;
  height: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.epg-program-menu:focus {
  outline: 0.2em solid #3498db;
  outline-offset: -0.2em;
  color: #fff;
}

.epg-program-menu:hover {
  color: #fff;
}

/* Compatibilidad con diseño anterior (mantener para evitar errores) */
.epg-channel-card {
  display: none; /* Ocultar si se usa el nuevo diseño */
}

.epg-event-card {
  display: none; /* Ocultar si se usa el nuevo diseño */
}

.epg-events-carousel {
  display: none; /* Ocultar si se usa el nuevo diseño */
}

/* Estilos para canales sin EPG */
.epg-card-no-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5em;
  background: rgba(100, 100, 100, 0.15);
  border-radius: 0.5em;
  border: 0.2em dashed #666;
  min-height: 8em;
  text-align: center;
}

.epg-card-no-data-icon {
  font-size: 2.5em;
  margin-bottom: 0.5em;
  opacity: 0.5;
}

.epg-card-no-data-title {
  font-size: 1.1em;
  font-weight: bold;
  margin-bottom: 0.8em;
  color: #999;
  text-align: center;
}

.epg-card-no-data-message {
  font-size: 0.9em;
  color: #aaa;
  text-align: center;
  margin-bottom: 1em;
  line-height: 1.5;
}

/* Punto 33: variante para cuando la EPG del canal falló al cargar
   (timeout/red) en vez de simplemente no tener programación configurada
   -- mismo layout que .epg-card-no-data, con un borde/color distinto para
   comunicar "esto es un error, no un dato permanente". */
.epg-card-load-error {
  background: rgba(231, 76, 60, 0.12);
  border: 0.2em dashed #e74c3c;
}

.epg-card-load-error .epg-card-no-data-title {
  color: #e74c3c;
}

.epg-action-button-small {
  padding: 0.6em 1.2em;
  background: linear-gradient(135deg, #3498db, #2980b9);
  border: none;
  border-radius: 0.3em;
  color: white;
  font-weight: bold;
  cursor: pointer;
  /* transition: all 0.2s ease; */ /* DESHABILITADO para mejor rendimiento en TVs */
  font-size: 0.9em;
}

.epg-action-button-small:hover,
.epg-action-button-small:focus {
  /* transform: translateY(-0.2em); */ /* DESHABILITADO para mejor rendimiento en TVs */
  box-shadow: 0 0.5em 1em rgba(52, 152, 219, 0.3);
}

/* Estilo para eventos pasados */
.epg-program-card.past {
  background: #1a1a1a;
  opacity: 0.7;
}

.epg-program-card.past:focus {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}
