/* === ESTILOS GENERALES === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;  /* evita scroll horizontal */
  font-family: "Poppins", sans-serif;
  background-color: #0e0e0e;
  color: #fff;
}

/* ========================================= */
/* === HEADER Y MENUBAR (ESTILO NETFLIX) === */
/* ========================================= */

/* 1. CONFIGURACIÓN GENERAL DEL MENUBAR (ESCRITORIO) */
.menubar {
    position: fixed;        
    top: 0;
    left: 0;
    width: 100%;             
    display: flex;
    align-items: center; /* Centrado vertical */
    padding: 0.5rem 2rem;
    
    /* FONDO TRANSPARENTE (GRADIENTE) AL INICIO */
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    
    z-index: 1000;                         
    transition: background-color 0.3s ease, padding 0.3s ease;
    
    /* CRUCIAL: Permite crear nuevas filas si los elementos no caben */
    flex-wrap: wrap; 
}

/* CUANDO SE HACE SCROLL (JS AGREGA ESTA CLASE) */
.menubar.scrolled {
    background-color: #0e0e0e; /* Negro sólido */
    background-image: none;    /* Quitamos el gradiente */
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

/* 2. LOGO */
.logo {
    height: 35px;
    cursor: pointer;
    margin-right: 2rem; /* Separación en escritorio */
    flex-shrink: 0; /* Evita que el logo se aplaste */
}

/* 3. NAVEGACIÓN (Enlaces centrales) */
.nav-links {
    display: flex;
    gap: 1.5rem;
    margin-right: auto; /* Empuja el menú derecho al final */
}

.nav-links a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem; 
    transition: color 0.3s;
}

.nav-links a:hover, .nav-links a.active {
    color: #e50914; /* Rojo activo */
}

/* 4. ZONA DERECHA (Lupa + Usuario) */
.menu-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon {
    height: 20px;
    cursor: pointer;
    transition: transform 0.2s;
}

.icon:hover { transform: scale(1.15); }

/* --- ZONA DE USUARIO --- */
.user-zone {
    display: flex;
    align-items: center;
    gap: 10px;        
    margin-left: 10px; 
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #e5e5e5;
    white-space: nowrap; 
    max-width: 100px;    
    overflow: hidden;
    text-overflow: ellipsis; 
}

.btn-logout {
    background-color: #e50914;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.3s ease;
}
.btn-logout:hover { background-color: #f40612; }

/* ========================================= */
/* === AJUSTE RESPONSIVE (MÓVIL - 2 FILAS) === */
/* ========================================= */
@media (max-width: 850px) {

    /* A. CONTENEDOR PRINCIPAL */
    .menubar {
        /* Usamos padding pequeño para no comer espacio */
        padding: 10px 15px !important; 
        
        /* Aseguramos que el ancho no exceda la pantalla */
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important; /* CRUCIAL para evitar desbordamiento */
        
        /* Gradiente para transparencia inicial */
        background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
        
        /* Espacio vertical entre fila 1 y fila 2 */
        gap: 10px; 
        
        /* Aseguramos flex-wrap para permitir las filas */
        flex-wrap: wrap !important;
    }
    
    .menubar.scrolled {
        background-color: #0e0e0e !important;
        background-image: none;
    }

    /* B. FILA 1: IZQUIERDA (Logo) */
    .logo {
        order: 1; 
        height: 25px !important; 
        margin-right: 0 !important;
        flex-shrink: 0; /* Evita que se aplaste */
    }

    /* C. FILA 1: DERECHA (Usuario + Lupa) */
    .menu-right {
        order: 2; 
        margin-left: auto; /* Empuja a la derecha */
        gap: 10px !important;
        flex-shrink: 0;
    }

    /* Forzar visibilidad del usuario */
    .user-name {
        display: block !important;
        font-size: 0.8rem !important;
        max-width: 80px; 
    }
    
    .btn-logout {
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
    }

    /* D. FILA 2: ABAJO (Menú de navegación) */
    .nav-links {
        order: 3; 
        
        /* FORZAR NUEVA LÍNEA: Ocupar el 100% del espacio disponible */
        width: 100% !important;
        flex-basis: 100% !important;
        
        /* RESET TOTAL DE ESPACIOS */
        margin: 0 !important;
        padding: 8px 0 0 0 !important; /* Solo padding arriba */
        gap: 0 !important; 
        
        display: flex;
        justify-content: space-between; /* Distribución exacta */
        align-items: center;
        
        border-top: 1px solid rgba(255,255,255,0.1); 
    }

    .nav-links a {
        font-size: 0.9rem !important;
        color: #bbb;
        /* Evita que los textos largos empujen el ancho */
        padding: 5px 2px;
    }
    
    .nav-links a.active {
        color: #fff;
        border-bottom: 2px solid #e50914;
    }
}

/* === CONTADOR DE TÍTULOS === */
.contador-titulo {
  text-align: center;
  font-size: 1.1rem;            /* Un poco más grande para legibilidad */
  color: rgba(255, 255, 255, 0.6); /* 60% opacidad para que se vea bien en PC y móvil */
  margin-top: -0.5rem;
  margin-bottom: 2rem;
  font-weight: 400;             /* Un poco más de grosor */
  font-family: "Poppins", sans-serif;
  letter-spacing: 1px;          /* Espaciado elegante */
  display: block;               /* Asegura que ocupe su propia línea */
}

/* reducimos un poco el margen inferior del título principal para que no queden muy separados */
#titulo-genero {
  margin-bottom: 0.5rem !important; 
}

/* === HERO SECTION (Portada principal tipo Netflix) === */
.hero {
  position: relative;
  width: 100%;
  height: 90vh;
  top: 0;
  overflow: hidden;
  background-color: #0e0e0e;
}

.hero-carrusel {
  display: flex;
  width: 110%; /* 3 películas */
  height: 100%;
  transition: transform 0.5s ease-in-out; /* transición rápida entre películas */
}

.hero-slide {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  overflow: hidden;
  height: 90vh;
}

.hero-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover; /* mantiene proporción y cubre todo */
  filter: brightness(90%); /* oscurece un poco para resaltar texto */
  object-position: top;

  /* --- máscara principal: fade a transparente desde 60% hasta 100% --- */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 60%, rgba(0,0,0,0) 100%);

  /* Para mayor suavidad en algunos navegadores */
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;

  /* Animación de desplazamiento lento de derecha a izquierda */
  animation: slow-slide 30s linear infinite;
}

@keyframes slow-slide {
  0% { transform: translateX(0); }
  100% { transform: translateX(-10%); } /* pequeño desplazamiento lento */
}

.hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60%; /* ajustar según lo suave que quieras el fundido */
  pointer-events: none;

  background: linear-gradient(
    to bottom,
    rgba(14,14,14,0) 0%,
    rgba(14,14,14,0.15) 30%,
    rgba(14,14,14,0.45) 65%,
    #0e0e0e 100%
  );
}

/* Contenido encima de la portada */
.hero-content {
  position: absolute;
  bottom: 25%;
  left: 4rem;
  color: #fff;
  z-index: 10;
}

.hero-logo {
  width: 60%;
  max-width: 1500px;
  height: auto;
  display: block;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.6));
  animation: fadeInUp 1s ease forwards;
}

.hero-subtitle {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  color: #ccc;
}

.hero-btn {
  background-color: #e50914;
  color: white;
  border: none;
  padding: 0.7rem 1.5rem;
  font-size: 1.1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.hero-btn:hover {
  background-color: #f40612;
}

.hero-dots {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.7rem;
  z-index: 25;  /* encima de hero-content y hero-carrusel */
}

.hero-dots .dot {
  width: 15px;
  height: 15px;
  cursor: pointer;
  transition: transform 0.3s;
}

.hero-dots .dot:hover {
  transform: scale(1.3);
}


.hero-botones-wrapper {
  display: flex;
  align-items: center;
  gap: 15px; /* Misma separación que en el modal */
  margin-top: 1.5rem; /* Separación del subtítulo */
  position: relative;
  z-index: 30;
}


.hero-content .hero-btn {
  margin-top: 0; 
  margin-bottom: 0;
}


header {
  display: contents;
  text-align: center;
  padding: 1rem 0;
  background: transparent;
  font-size: 1.5rem;
  letter-spacing: 1px;
}

.header-seccion {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* separación pequeña entre botón y título */
  margin-bottom: 0rem; /* pegado al carrusel */
}

/* Botones hero superpuestos */
.hero-btn-left,
.hero-btn-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background-color: transparent;
  width: 50px;
  height: 50px;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;           /* ocultos por defecto */
  pointer-events: none; /* no clickeables */
}

.hero:hover .hero-btn-left,
.hero:hover .hero-btn-right {
  opacity: 0.7;         /* visibles al hover */
  pointer-events: auto; /* ahora clickeables */
}

.hero-btn-left:hover,
.hero-btn-right:hover {
  background-color: transparent;
  transform: translateY(-50%) scale(1.5);
  opacity: 1;
}

.hero-btn-left {
  left: 1rem;
}

.hero-btn-right {
  right: 1rem;
}

.hero-btn-left img,
.hero-btn-right img {
  width: 25px;
  height: 25px;
}


.explorar-btn {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.8rem;
  color: #e50914; /* rojo estilo Netflix */
  overflow: hidden;
  transform: translateY(9px);

  
  padding: 0.3rem 0.6rem; /* añade área alrededor del símbolo/texto */
  border-radius: 4px;     /* opcional: suaviza los bordes de la zona activa */
}

.explorar-btn .simbolo {
  display: inline-block;
  transition: transform 0.3s ease;
}

.explorar-btn .texto {
  display: inline-block;
  transform: translateX(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  white-space: nowrap;
  margin-left: 0.2rem;
  color: #e50914; /* rojo también para el texto */
}

.explorar-btn:hover .simbolo {
  opacity: 0;              /* desaparece */
  transform: translateX(-10px); /* opcional, un pequeño movimiento al desaparecer */
}

.explorar-btn:hover .texto {
  transform: translateX(0);
  opacity: 1;
}

/* === CARRUSEL === */
.carrusel-container {
  position: relative;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 0;
  overflow: hidden;
}

.carrusel {
  display: flex;
  gap: 1rem;
  padding: 0 2rem;
  overflow-x: auto;
  scroll-behavior: smooth;

  /* ocultar scrollbar */
  -ms-overflow-style: none;  /* IE y Edge */
  scrollbar-width: none;     /* Firefox */
}

.carrusel::-webkit-scrollbar {
  display: none;  /* Chrome, Safari y Opera */
}

/* === BOTONES SCROLL === */
.scroll-btn {
  position: absolute;  /* relativo a .carrusel-container */
  top: 50%;
  transform: translateY(-50%);
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 50%;
  z-index: 10;
  transition: background 0.3s, opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}

.carrusel-container:hover .scroll-btn {
  opacity: 1;
  pointer-events: auto;
}

.scroll-btn:hover {
  background-color: rgba(255,255,255,0.2);
}

.scroll-btn.left {
  left: 0px;  /* un poquito fuera para no tapar tarjetas */
}

.scroll-btn.right {
  right: 0px;
}


/* Mantener tu carrusel existente */
.carrusel {
  padding: 1rem;
  display: flex;
  overflow-x: auto;
  gap: 1rem;
  padding: 1rem 2rem;
  scroll-behavior: smooth;

  /* ocultar scrollbar */
  -ms-overflow-style: none;  /* IE y Edge */
  scrollbar-width: none;     /* Firefox */
}

.carrusel::-webkit-scrollbar {
  display: none;  /* Chrome, Safari y Opera */
}

.carrusel::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 10px;
}

/* === TARJETAS === */
.tarjeta {
  position: relative;
  flex: 0 0 auto;
  width: 200px;
  height: auto; /* <--- Agrega esto para que la tarjeta crezca con la imagen */
  border-radius: 12px;
  overflow: hidden;
  background-color: #1a1a1a;
  transition: transform 0.3s, box-shadow 0.3s;
  cursor: pointer;
  display: flex;             /* Asegura alineación */
  flex-direction: column;    /* Pone imagen arriba, texto abajo */
}

.tarjeta:hover {
  transform: scale(1.04);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.tarjeta img:not(.icono-favorito) {
  width: 100%;
  height: auto;        /* Deja que la altura se calcule sola */
  aspect-ratio: 2 / 3; /* Fuerza la proporción vertical de cine */
  object-fit: cover;   /* Recorta los excesos sin deformar */
}

.contenido {
  padding: 0.8rem;
  text-align: left;
}

.contenido h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #fff;
}

.contenido p {
  font-size: 0.85rem;
  color: #bbb;
  margin: 0.2rem 0;
}

.descripcion {
  display: none;
}

/* === ESTILOS PARA MIS FAVORITOS (Ajustados) === */

.seccion-favoritos {
  /* Usamos el mismo padding que .genero-main para que la altura sea idéntica */
  padding: 7.4rem 2rem 3rem; 
  min-height: calc(100vh - 100px); 
  margin-top: 0; /* Eliminamos el margen extra que lo empujaba hacia abajo */
}

/* --- AGREGA ESTO JUSTO AQUÍ DEBAJO --- */
@media (max-width: 850px) {
  .seccion-favoritos {
    /* Aumentamos de 6rem a 9rem (aprox 144px) solo en celular */
    /* Esto bajará el título "Mis Favoritos" para que no choque con el menú */
    padding-top: 7.2rem !important; 
  }
}

.seccion-favoritos h2 {
  font-size: 2rem;
  color: #fff;
  margin-bottom: 1.65rem;
  text-align: center;
  /* Eliminamos border-bottom y padding-bottom para quitar la barra */
  border-bottom: none; 
  padding-bottom: 0;
}

/* Estilo para el link activo en la barra de navegación */
.nav-links a {
    transition: color 0.2s;
}

.nav-links a.active {
    color: #e50914; /* Color de resaltado */
    font-weight: 600;
}

.icono-favorito {
  position: absolute;
  top: 8px; /* Separación superior */
  right: 8px; /* Separación derecha */
  width: 30px !important;  /*  ¡CLAVE! Tamaño fijo y prioritario */
  height: 30px !important; /* ¡CLAVE! Tamaño fijo y prioritario */
  cursor: pointer;
  z-index: 10;
  
  transition: transform 0.2s ease-in-out, filter 0.2s ease-in-out; 
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.8));
}

.icono-favorito:hover {
  transform: scale(1.15); 
}

.icono-favorito.favorito {
  transform: scale(1.05);
}

/* === ESTADO VACÍO DE FAVORITOS (NETFLIX STYLE) === */
.mensaje-vacio-container {
  grid-column: 1 / -1; /* OBLIGATORIO: Hace que ocupe todo el ancho del grid */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 50vh;    /* Ocupa la mitad de la pantalla verticalmente */
  width: 100%;
  animation: fadeIn 0.5s ease;
}

.mensaje-vacio-icono {
  font-size: 3rem;       /* Tamaño gigante (aprox 128px) */
  line-height: 1;
  margin-bottom: 1rem;
  
  filter: grayscale(100%); 
  opacity: 0.5;        
  
  cursor: default;
  transition: transform 0.3s ease, filter 0.3s ease, opacity 0.3s ease;
}

.mensaje-vacio-titulo {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 10px 0;
}

.mensaje-vacio-texto {
  font-size: 1rem;
  color: #a3a3a3; /* Gris suave */
  line-height: 1.5;
  max-width: 400px; /* Mantiene el texto compacto */
  margin: 0;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Títulos de secciones (Mantenemos tu código anterior) */
.seccion-catalogo h2 {
  margin: 0 0 -1rem 30px;
  font-size: 1.5rem;
  color: #fff;
}

/* === BUSCADOR EMERGENTE === */
.buscador-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(10, 10, 10, 0.95);
  display: flex;
  justify-content: center;
  align-items: flex-start !important;
  padding-top: 10rem;
  padding-bottom: 4rem;
  overflow-y: auto;
  overflow-x: hidden; /* evita desplazamiento horizontal */
  z-index: 2000;
  transition: opacity 0.3s ease;
  box-sizing: border-box;
}

.buscador-overlay.hidden {
  display: none;
}

.buscador-contenido {
  width: 90%;
  max-width: 1000px;
  display: block;
  text-align: center;
  margin: 0;
}

#input-busqueda {
  width: 100%;
  max-width: 700px;
  padding: 0.8rem 1.2rem;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  outline: none;
  margin-bottom: 2rem;
  background-color: #222;
  color: #fff;
}

/* === GRID DE RESULTADOS === */
.resultados-busqueda {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(420px, auto);
  gap: 1.5rem;
  justify-items: center;
  justify-content: center; /* 💡 centra todo el grid */
  align-content: start;
  margin: 0 auto;           /* 💡 centra dentro del contenedor */
  padding: 2rem 0.5rem;
  max-width: 1000px;
  width: fit-content;       /* 💡 evita que se extienda innecesariamente */
  overflow: visible;
}


/* === AJUSTE DE TARJETAS EN BUSCADOR === */
.resultados-busqueda .tarjeta {
  width: 100%;
  max-width: 250px;
  height: 420px; /* más altura total */
  border-radius: 14px;
  overflow: hidden;
  background-color: #111;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.resultados-busqueda .tarjeta img:not(.icono-favorito) {
  width: 100%;
  height: 85%; /* más espacio para la imagen */
  object-fit: cover;
}

.resultados-busqueda .contenido {
  height: 15%;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  background: transparent;
}

.resultados-busqueda .contenido h3 {
  font-size: 1rem;
  color: #fff;
  margin: 0;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resultados-busqueda .contenido p {
  font-size: 0.8rem;
  color: #ccc;
  margin: 0.2rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === FOOTER === */
.footer {
  background-color: #0e0e0e;  /* mismo fondo que la página */
  color: #aaa;                /* gris suave, estilo Netflix */
  text-align: center;
  padding: 1rem 0;
  font-size: 0.9rem;
  border-top: 1px solid #222; /* línea sutil arriba */
}

.footer p {
  margin: 0;
  letter-spacing: 0.5px;
}

@media (max-width: 900px) {
  #input-busqueda {
    width: 90%;
    max-width: 650px; /* un poco más estrecho que desktop */
  }

  .resultados-busqueda {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 1rem;       /* separación horizontal */
    row-gap: 0.5rem;        /* filas más juntas */
    justify-content: center;
    justify-items: center;
    align-items: start;
    grid-auto-rows: auto;   /* altura según contenido */
  }

  .resultados-busqueda .tarjeta {
    max-width: 200px;
    min-height: 340px;       /* altura mínima uniforme */
    height: auto;            
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background-color: #111;
    overflow: hidden;
  }

  .resultados-busqueda .tarjeta img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    flex-shrink: 0;          /* evita compresión de la imagen */
  }

  .resultados-busqueda .contenido {
    padding: 0.45rem 0.55rem;  /* compacto pero suficiente para texto */
    flex-grow: 1;              
    display: flex;
    flex-direction: column;
    justify-content: flex-start; 
    text-align: center;
    overflow: hidden;          
  }

  .resultados-busqueda .contenido h3 {
    font-size: 0.9rem;
    margin: 0 0 0.2rem;
    line-height: 1.2;
    word-break: break-word;
    white-space: normal;      
    display: block;           
    overflow: visible;        
  }

  .resultados-busqueda .contenido p {
    font-size: 0.75rem;
    color: #ccc;
    margin: 0;
    line-height: 1.2;
    white-space: normal;      
    overflow: visible;
  }
}

@media (max-width: 600px) {

  #input-busqueda {
    width: 90%;
    max-width: 600px;
  }

  .resultados-busqueda {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 1rem;    /* separación horizontal */
    row-gap: 0.5rem;     /* filas más juntas */
    justify-content: center;
    justify-items: center;
    align-items: start;
    grid-auto-rows: auto; /* altura de fila según contenido */
  }

  .resultados-busqueda .tarjeta {
    max-width: 180px;
    height: auto;            
    min-height: 320px;       /* altura mínima uniforme */
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background-color: #111;
    overflow: hidden;        
  }

  .resultados-busqueda .tarjeta img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    flex-shrink: 0;          
  }

  .resultados-busqueda .contenido {
    padding: 0.4rem 0.5rem; /* un poco menos para compactar */
    flex-grow: 1;            
    display: flex;
    flex-direction: column;
    justify-content: flex-start; 
    text-align: center;
    overflow: hidden;        
  }

  .resultados-busqueda .contenido h3 {
    font-size: 0.85rem;
    margin: 0 0 0.15rem;
    line-height: 1.2;
    word-break: break-word;
    white-space: normal;      
    display: block;           
    overflow: visible;        
  }

  .resultados-busqueda .contenido p {
    font-size: 0.7rem;
    color: #ccc;
    margin: 0;
    line-height: 1.2;
    white-space: normal;      
    overflow: visible;
  }
}





/* Solo en escritorio: 8 tarjetas visibles, carrusel fijo sin scroll */
@media screen and (min-width: 1024px) {
  .carrusel {
    overflow-x: hidden; /* deshabilita scroll horizontal */
  }

  .tarjeta {
    flex: 0 0 calc((100% - 7rem) / 8); /* 7 gaps = 7rem entre 8 tarjetas */
    height: auto;
  }

  .tarjeta img {
    height: auto;
    aspect-ratio: 2/3;
  }

  /* Opcional: ocultar botones de scroll en escritorio */
  .scroll-btn {
    display: none;
  }
}

/* === Ajuste de posición del buscador en modo responsive === */
@media (max-width: 900px) {
  .buscador-overlay {
    padding-top: 3rem; /* antes era 10rem → sube un poco */
  }
}

@media (max-width: 600px) {
  .buscador-overlay {
    padding-top: 1rem; /* aún más arriba en pantallas pequeñas */
  }
}

/* === GRID DE GÉNERO === */
.genero-main {
  padding: 6rem 2rem 3rem; /* deja espacio para el menú fijo */
}

#titulo-genero {
  font-size: 2rem;
  margin-bottom: 2rem;
  text-align: center;
  color: #fff;
}

.grid-genero {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1rem;
  justify-items: center;
}

/* === AJUSTE FINAL DE TAMAÑO Y TÍTULOS EN GRID DE GÉNERO === */

/* Tarjetas más grandes y con espacio reservado para el texto */
.grid-genero .tarjeta {
  width: 100%;
  aspect-ratio: auto;       /* libera la restricción vertical */
  background-color: #1a1a1a;
  border-radius: 10px;
  display: flex;
  flex-direction: column;   /* imagen arriba, texto abajo */
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.grid-genero .tarjeta:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

/* Imagen completa, sin recorte */
.grid-genero .tarjeta img:not(.icono-favorito) {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 10px 10px 0 0;
  flex-shrink: 0;
}

/* Contenedor de texto debajo de la imagen */
.grid-genero .contenido {
  padding: 0.5rem 0.4rem 0.7rem;
  text-align: center;
}

.grid-genero .contenido h3 {
  margin: 0.4rem 0 0.2rem;
  font-size: 0.9rem;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  white-space: normal; /* permite 2 líneas si el título es largo */
  line-height: 1.2;
}

.grid-genero .contenido p {
  font-size: 0.75rem;
  color: #bbb;
  margin: 0;
}

/* Escalado limpio para pantallas pequeñas */
@media (max-width: 900px) {
  .grid-genero {
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
  }
  .grid-genero .tarjeta {
    max-width: 150px;
  }
}

@media (max-width: 700px) {
  .grid-genero {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
  }
  .grid-genero .tarjeta {
    max-width: 120px;
  }
}

@media (max-width: 480px) {
  .grid-genero {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.7rem;
  }
  .grid-genero .tarjeta {
    max-width: 140px;
  }
}

@media (max-width: 380px) {
  .grid-genero {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.7rem;
  }
  .grid-genero .tarjeta {
    max-width: 120px;
  }
}

/* === AJUSTE DE TIPOGRAFÍA EN MODO RESPONSIVE PARA GRID DE GÉNERO === */

/* Tablets medianas */
@media (max-width: 900px) {
  .grid-genero .contenido h3 {
    font-size: 0.85rem;
  }
  .grid-genero .contenido p {
    font-size: 0.7rem;
  }
}

/* Celulares grandes */
@media (max-width: 700px) {
  .grid-genero .contenido h3 {
    font-size: 0.8rem;
  }
  .grid-genero .contenido p {
    font-size: 0.68rem;
  }
}

/* Celulares pequeños */
@media (max-width: 480px) {
  .grid-genero .contenido h3 {
    font-size: 0.75rem;
  }
  .grid-genero .contenido p {
    font-size: 0.65rem;
  }
}

/* Muy pequeños (hasta 380px) */
@media (max-width: 380px) {
  .grid-genero .contenido h3 {
    font-size: 0.7rem;
  }
  .grid-genero .contenido p {
    font-size: 0.6rem;
  }
}

/* === AJUSTE PARA VISTA RESPONSIVE DE 4 COLUMNAS === */
@media (max-width: 1024px) {
  .grid-genero {
    grid-template-columns: repeat(4, 1fr); /* 4 columnas */
    gap: 1rem;
  }

  .grid-genero .tarjeta {
    width: 100%;
    max-width: none;
    border-radius: 12px;
    background-color: #1a1a1a;
  }

  .grid-genero .tarjeta img:not(.icono-favorito) {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
  }

  .grid-genero .contenido {
    padding: 0.5rem 0.6rem 1rem;
    text-align: center;
  }

  .grid-genero .contenido h3 {
    font-size: 0.9rem;
    margin: 0.5rem 0 0.3rem;
    line-height: 1.2;
    color: #fff;
  }

  .grid-genero .contenido p {
    font-size: 0.75rem;
    color: #bbb;
  }
}

/* === Optimización para pantallas más pequeñas === */
@media (max-width: 600px) {
  .grid-genero {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }

  .grid-genero .contenido h3 {
    font-size: 0.85rem;
  }

  .grid-genero .contenido p {
    font-size: 0.7rem;
  }
}


/* ========================================= */
/* === ESTILOS DEL MODAL === */
/* ========================================= */

/* Fondo oscuro que cubre toda la pantalla */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  justify-content: center;
  
  /* CLAVE 1: Usar flex-start permite el scroll desde el principio */
  align-items: flex-start; 
  
  overflow-y: auto;
  
  /* Damos un poco más de aire arriba y abajo */
  padding: 40px 20px; 
  
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
}

/* Contenedor principal */
.modal-container {
  background-color: #181818;
  width: 100%;
  max-width: 850px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.8);
  position: relative;
  overflow: hidden;
  
  /* CLAVE 2: EL TRUCO DE ORO */
  /* En un contenedor Flex, 'margin: auto' centra verticalmente si hay espacio,
     pero si el contenido es muy alto, respeta el padding superior y no lo corta. */
  margin: auto; 
  
  /* Margen extra para que al scrollear hasta el fondo no quede pegado */
  margin-bottom: 40px; 
  
  animation: modalFadeIn 0.4s ease-out;
}

@keyframes modalFadeIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Botón Cerrar */
.btn-cerrar {
  position: absolute;
  top: 15px;
  right: 15px;
  background-color: rgba(24, 24, 24, 0.6);
  color: white;
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20; /* Aseguramos que esté por encima de todo */
  transition: transform 0.2s;
}
.btn-cerrar:hover {
  background-color: white;
  color: black;
  transform: scale(1.1);
}

/* === ESTILO DEL BOTÓN FAVORITO EN MODAL === */
.btn-modal-favorito {
  position: absolute;
  top: 13px; /* Debajo del botón cerrar (aprox 15px + 36px + gap) */
  right: 65px; /* Mismo margen derecho que el cerrar */
  width: 36px;
  height: 36px;
  cursor: pointer;
  z-index: 20;
  transition: transform 0.2s;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8)); /* Sombra para resaltar sobre el fondo */
}

.btn-modal-favorito:hover {
  transform: scale(1.1);
}

/* === CABECERA (HERO) === */
.modal-hero {
  position: relative;
  width: 100%;
  height: 400px;
}

#modal-img-fondo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.modal-gradient {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(to top, #181818, transparent);
  z-index: 1;
}

/* Contenido sobre la imagen */
.modal-hero-overlay {
  position: absolute;
  bottom: 30px;
  left: 40px;
  width: 80%;
  z-index: 10; /* Importante para que se vea sobre el gradiente */
}

#modal-titulo {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
  line-height: 1.1;
}

.btn-hero-play {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: white;
  color: black;
  padding: 0.8rem 2rem;
  border-radius: 4px;
  font-size: 1.2rem;
  font-weight: bold;
  text-decoration: none;
  transition: background-color 0.2s;
  z-index: 25;
  position: relative;
  cursor: pointer;
}
.btn-hero-play:hover {
  background-color: #e6e6e6;
}

/* === CUERPO DE INFO === */
.modal-info-body {
  padding: 20px 40px 40px 40px;
  color: #fff;
  position: relative;
  z-index: 5;
}

.modal-metadata {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap; /* Para que no se rompa en móvil */
}

.match { color: #46d369; font-weight: bold; }
.meta-tag.border { border: 1px solid rgba(255,255,255,0.4); padding: 0 5px; font-size: 0.8rem; }

.modal-descripcion-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  margin-bottom: 40px;
}

.sinopsis-texto {
  font-size: 1.1rem;
  line-height: 1.5;
  color: #ddd;
}

.label-gris { color: #777; }

/* === GRILLA SIMILARES === */
.seccion-similares h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  border-top: 1px solid #404040;
  padding-top: 20px;
}

.grid-similares {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 15px;
}

.card-similar {
  background-color: #2f2f2f;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}
.card-similar:hover { transform: scale(1.05); }

.card-similar img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}
.card-similar-info { padding: 8px; }
.card-similar-title { font-size: 0.8rem; color: #ccc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


/* === RESPONSIVE (MÓVIL) === */
@media (max-width: 768px) {
  
  /* 1. Aseguramos que el Overlay contenga todo sin salirse */
  .modal-overlay {
    padding: 15px; /* Margen seguro alrededor de todo el modal */
    align-items: flex-start; /* Alineado arriba para permitir scroll */
    box-sizing: border-box; /* IMPORTANTE: Para que el padding no sume ancho extra */
    display: flex; /* Asegura comportamiento flexible */
  }

  /* 2. El contenedor se obliga a respetar el ancho disponible */
  .modal-container {
    width: 100%; /* Ocupa el 100% del espacio disponible (dentro del padding del overlay) */
    max-width: 100%; /* Nunca exceder el ancho */
    margin: 0;
    height: auto; /* Permite crecer hacia abajo */
    display: block;
    box-sizing: border-box; /* CRUCIAL: Evita que bordes o rellenos lo ensanchen */
    overflow: hidden; /* Corta cualquier hijo rebelde que intente salirse */
  }

  /* 3. Cabecera fija para que no empuje */
  .modal-hero {
    height: 250px;
    width: 100%;
  }

  /* 4. Ajuste del texto sobre la imagen */
  .modal-hero-overlay {
    left: 15px; /* Margen izquierdo interno */
    right: 15px; /* Margen derecho interno (fuerza a no salirse) */
    bottom: 15px;
    width: auto; /* Ancho automático basado en left/right */
    box-sizing: border-box;
    z-index: 20 !important;
  }

  #modal-titulo {
    font-size: 1.6rem; /* Un poco más pequeño para evitar saltos bruscos */
    word-wrap: break-word; /* Rompe palabras muy largas si es necesario */
    hyphens: auto;
    margin-bottom: 1rem;
  }

  /* 5. Cuerpo del texto */
  .modal-info-body {
    padding: 15px;
    box-sizing: border-box;
  }

  /* Grid de una sola columna */
  .modal-descripcion-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  
  /* Botón de cerrar ajustado */
  .btn-cerrar {
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
  }

  .btn-modal-favorito {
    top: 8px; /* Un poco más arriba en celular */
    right: 50px; /* Alineado con el nuevo margen de la X */
    width: 32px;
    height: 32px;
  }

  .grid-similares {
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px;
  }

  .card-similar img {
    width: 100%;       /* Ocupa todo el ancho de su columna */
    height: auto;      /* La altura se calcula sola según el ancho */
    aspect-ratio: 2/3; /* Mantiene siempre formato póster vertical */
    object-fit: cover; /* Asegura que se vea bien sin deformarse */
    border-radius: 4px;
  }
}


/* === UTILIDAD PARA OCULTAR ELEMENTOS === */
.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* === PERSONALIZACIÓN DEL REPRODUCTOR (PLYR) === */

/* Definimos el color rojo Netflix para todo el reproductor */
:root {
  --plyr-color-main: #e50914; /* Rojo intenso */
}

/* Ajustes para que se vea más premium */
.plyr--video {
    height: 100%; /* Asegurar que llene el contenedor */
    border-radius: 8px; /* Bordes redondeados suaves */
    overflow: hidden;
}

/* El botón grande de play central */
.plyr__control--overlaid {
    background: rgba(229, 9, 20, 0.8) !important; /* Rojo semi-transparente */
}
.plyr__control--overlaid:hover {
    background: #e50914 !important; /* Rojo sólido al pasar el mouse */
}

/* Asegurar que los controles queden encima de todo */
.plyr--full-ui.plyr--video .plyr__controls {
    z-index: 105;
}

/* Forzamos que el contenedor de Plyr se ponga ENCIMA de todo (gradiente y títulos) */
.modal-hero .plyr {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50; /* Mayor que overlay (10) y gradiente (1) */
  background: #000; /* Fondo negro para evitar parpadeos */
}

.modal-hero.video-activo .modal-hero-overlay,
.modal-hero.video-activo .modal-gradient,
.modal-hero.video-activo #modal-img-fondo {
  display: none;
}


.custom-control-btn {
  background: rgba(0, 0, 0, 0.5); /* Fondo semitransparente */
  border: 2px solid rgba(255, 255, 255, 0.8);
  color: white;
  border-radius: 50%;
  width: 50px; /* Tamaño fijo */
  height: 50px; /* Tamaño fijo */
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 1.5rem; /* Tamaño de icono */
  backdrop-filter: blur(2px);
  user-select: none; /* Evita selección de texto */
  transition: transform 0.2s, background 0.2s;
}

.custom-control-btn:hover {
  background: #e50914; /* Rojo */
  border-color: #e50914;
  transform: scale(1.1);
}

#custom-play-btn {
  width: 70px; /* Botón Play más grande */
  height: 70px;
  font-size: 2rem;
}

/* === FEEDBACK VISUAL (+10s / -10s) === */
.seek-feedback {
  /* Configuración Base (Modo Normal) */
  position: absolute;
  top: 50%;
  left: 50%; /* Centrado inicial, las clases .left/.right lo moverán */
  transform: translate(-50%, -50%); /* Centrado exacto */
  
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  background: rgba(0,0,0,0.7);
  padding: 10px 20px;
  border-radius: 30px;
  
  opacity: 0;           /* Invisible por defecto */
  pointer-events: none; /* No bloquea clicks */
  z-index: 2000;        /* Muy alto para verse sobre el video */
  display: block;       /* Asegura que exista en el layout */
}

/* Posiciones relativas */
.seek-feedback.left { left: 20%; }
.seek-feedback.right { left: 80%; }

/* Animación */
.animate-feedback {
  animation: fadeZoom 0.6s ease-out forwards;
}

@keyframes fadeZoom {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* === MODO PANTALLA COMPLETA  === */
/* Cuando Plyr activa fullscreen, cambiamos a fixed para salirnos del contenedor */
.plyr--fullscreen-active .seek-feedback {
  position: fixed !important; 
  z-index: 2147483647 !important; /* Capa máxima del navegador */
  font-size: 3rem !important;     /* Más grandes */
  background: rgba(0, 0, 0, 0.6);
  padding: 1.5rem 3rem;
  
  /* Ajustamos posiciones usando % de la pantalla */
  top: 50%;
  transform: translateY(-50%); /* Solo centrado vertical, horizontal es manual */
}

.plyr--fullscreen-active .seek-feedback.left {
  left: 15% !important;
  right: auto !important;
}

.plyr--fullscreen-active .seek-feedback.right {
  right: 15% !important;
  left: auto !important;
}

/* ========================================= */
/* === TÍTULO SUPERPUESTO EN EL VIDEO === */
/* ========================================= */

.video-overlay-title {
  position: absolute;
  top: 30px;  /* Separación del borde superior */
  left: 30px; /* Separación del borde izquierdo */
  color: #fff;
  font-size: 1.8rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.9); /* Sombra fuerte para legibilidad */
  z-index: 205; /* Encima de todo */
  opacity: 0;   /* Oculto por defecto */
  pointer-events: none; /* Que no estorbe al click */
  transition: opacity 0.3s ease;
  font-family: "Poppins", sans-serif;
  letter-spacing: 1px;
}


/* Ajuste para celulares */
@media (max-width: 768px) {
  .video-overlay-title {
    font-size: 1.2rem;
    top: 15px;
    left: 15px;
  }
}


/* ======================================================= */
/* === SINCRONIZACIÓN DE VISIBILIDAD (Normal y Fullscreen) === */
/* ======================================================= */

/* COMPORTAMIENTO POR DEFECTO: VISIBLE */
/* Esto asegura que si mueves el mouse, se vean. */
.custom-video-overlay,
.video-overlay-title {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

/* === BOTÓN CERRAR VIDEO (DENTRO DEL REPRODUCTOR) === */
.btn-close-video {
  position: absolute;
  top: 35px;
  right: 20px;
  background-color: rgba(24, 24, 24, 0.6); /* Fondo semitransparente oscuro */
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 210; /* Por encima de título y overlays */
  transition: transform 0.2s, background-color 0.2s, opacity 0.3s ease;
  line-height: 1; /* Centrado vertical exacto para la X */
  opacity: 1;
}

.btn-close-video:hover {
  background-color: white;
  color: black;
  transform: scale(1.1);
}

.plyr--hide-controls .btn-close-video {
  opacity: 0;
  pointer-events: none;
}

/* Ajuste para Pantalla Completa  */
.plyr--fullscreen-active .btn-close-video {
  top: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  font-size: 32px;
}

/* Ajuste para Móviles  */
@media (max-width: 768px) {
  .btn-close-video {
    width: 35px;
    height: 35px;
    font-size: 24px;
    top: 15px;
    right: 15px;
  }
}

/* AJUSTE ESPECIAL PARA PANTALLA COMPLETA */
/* Cuando está en fullscreen, hacemos el título más grande y elegante */
.plyr--fullscreen-active .video-overlay-title {
  font-size: 2.5rem; /* Más grande en TV/Monitor */
  top: 50px;
  left: 50px;
}

/* Ajuste de los botones centrales en pantalla completa */
.plyr--fullscreen-active .custom-control-btn {
  width: 80px;
  height: 80px;
  font-size: 2rem;
}
.plyr--fullscreen-active #custom-play-btn {
  width: 100px;
  height: 100px;
  font-size: 3rem;
}

/* SEGURIDAD PARA MÓVILES */
.plyr--paused .custom-video-overlay,
.plyr--paused .video-overlay-title {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ======================================================= */
/* === INDICADORES (+10s/-10s) === */
/* ======================================================= */

/* Estilo base (animación maneja la posición y escala) */
.seek-feedback {
  position: absolute;
  top: 50%;
  left: 50%; /* Centrado por defecto */
  font-size: 1.5rem;
  font-weight: bold;
  color: #fff;
  background: rgba(0,0,0,0.7);
  padding: 10px 20px;
  border-radius: 30px;
  opacity: 0; /* Invisible hasta que se anime */
  pointer-events: none;
  z-index: 2000; /* Muy alto */
  display: block;
}

/* Ajustes de posición base */
.seek-feedback.left { left: 20%; }
.seek-feedback.right { left: 80%; }

/* ANIMACIÓN: Controla opacidad, posición y zoom */
.animate-feedback {
  animation: fadeZoom 0.6s ease-out forwards;
}

@keyframes fadeZoom {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* === MODO PANTALLA COMPLETA === */
.plyr--fullscreen-active .seek-feedback {
  position: fixed !important; /* Salimos del contenedor */
  z-index: 2147483647 !important; /* Capa máxima posible */
  font-size: 3rem !important; /* Texto gigante */
  background: rgba(0, 0, 0, 0.6);
  padding: 1.5rem 3rem;
  border-radius: 50px;
}

/* Posiciones en pantalla completa (usamos porcentajes de la pantalla) */
.plyr--fullscreen-active .seek-feedback.left {
  left: 15% !important;
  right: auto !important;
}

.plyr--fullscreen-active .seek-feedback.right {
  left: auto !important;
  right: 15% !important;
}

/* Estos estilos tienen !important para sobrescribir los inyectados por JS */
@media (max-width: 768px) {
    
    /* Contenedor del menú: Más compacto y permite scroll si la lista es larga */
    .netflix-menu-container {
        flex-direction: column !important; /* Una columna encima de otra (Audio arriba, Subs abajo) */
        gap: 1.5rem !important;            /* Menos separación */
        width: 85% !important;             /* Un poco más estrecho para no tocar bordes */
        max-height: 80vh !important;       /* Nunca exceder el 80% de la altura de pantalla */
        overflow-y: auto !important;       /* Habilitar scroll interno si hay muchos idiomas */
        padding: 10px !important;
    }

    /* Títulos de columnas (Audio / Subtítulos) más pequeños */
    .netflix-col h3 {
        font-size: 1rem !important;
        margin-bottom: 0.5rem !important;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    /* Opciones individuales (Botones de idioma) */
    .netflix-option {
        font-size: 0.9rem !important;      /* Texto más pequeño */
        padding: 10px 12px !important;     /* Áreas de toque cómodas pero no gigantes */
        background-color: rgba(255,255,255,0.05); /* Fondo sutil para distinguir cada opción */
        margin-bottom: 5px;                /* Separación entre opciones */
        border-radius: 4px;
    }

    /* Estado seleccionado en móvil */
    .netflix-option.selected {
        background-color: rgba(229, 9, 20, 0.2); /* Fondo rojo suave */
        border: 1px solid rgba(229, 9, 20, 0.5);
    }
}


/* === NUEVOS ESTILOS PARA BOTONES DEL MODAL === */

.modal-botones-wrapper {
  display: flex;
  align-items: center;
  gap: 15px; /* Separación entre Reproducir y Telegram */
}

/* Botón de Telegram (Circular y transparente/glassmorphism) */
.btn-hero-telegram {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px; /* Tamaño del círculo */
  height: 50px;
  border-radius: 50%;
  background-color: rgba(40, 168, 234, 0.2); 
  border: 2px solid rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s;
  z-index: 25;
  pointer-events: auto;
}

.btn-hero-telegram img {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* Efecto hover de expansión (Igual al botón cerrar) */
.btn-hero-telegram:hover {
  transform: scale(1.1);
  background-color: rgba(40, 168, 234, 0.5); /* Más visible al pasar el mouse */
  border-color: #fff;
}

/* === MENSAJE TOAST (MODIFICADO) === */
.toast-msg {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #e50914; /* Rojo Vanacue */
  color: #fff;
  
  /* CAMBIO 1: Espaciado y dimensiones */
  padding: 16px 24px;      /* Un poco más de aire vertical */
  border-radius: 8px;      /* Bordes más suaves */
  width: auto;             /* Se ajusta al contenido */
  max-width: 90%;          /* Nunca se sale de la pantalla */
  
  /* CAMBIO 2: Manejo de texto */
  font-size: 1rem;
  font-weight: 600;
  text-align: center;      /* Centrar texto multilínea */
  white-space: pre-line;   /* ¡CRUCIAL! Esto permite los saltos de línea (\n) */
  line-height: 1.5;        /* Mejor lectura para dos líneas */
  
  /* Decoración */
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  z-index: 20000;
  
  /* Animación */
  opacity: 0;
  animation: toastFade 4s ease forwards; /* Subí a 4s para dar tiempo a leer */
  pointer-events: none;
}

/* Animación (La dejamos igual, funciona bien) */
@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, -20px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -20px); }
}

/* --- AJUSTE RESPONSIVE --- */
@media (max-width: 600px) {
  .toast-msg {
    top: 80px;
    font-size: 0.9rem; /* Texto legible pero ajustado */
    padding: 12px 20px;
    width: 90%;        /* En celular ocupamos casi todo el ancho para que quepa el texto */
    max-width: 350px;  /* Pero no exageramos */
  }
}

/* ========================================= */
/* === ESTILOS LISTA DE EPISODIOS (NETFLIX) === */
/* ========================================= */

.seccion-episodios {
  margin-top: 30px;
  margin-bottom: 40px;
  border-top: 1px solid #404040; /* Línea separadora sutil */
  padding-top: 20px;
  animation: fadeIn 0.5s ease;
}

.episodios-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.titulo-seccion-ep {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

/* Dropdown de Temporadas */
.dropdown-temporadas {
  background-color: #242424;
  color: #fff;
  border: 1px solid #4d4d4d;
  padding: 8px 30px 8px 15px; /* espacio extra a la derecha para la flecha */
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none; /* Quita estilo nativo del navegador */
  -webkit-appearance: none;
  
  /* Flecha personalizada */
  background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* === FILA DE CADA EPISODIO === */
.episodio-item {
  display: flex;
  align-items: center; /* Centrado vertical */
  padding: 20px 15px;
  border-bottom: 1px solid #333;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-radius: 4px;
}

.episodio-item:hover {
  background-color: #262626; /* Gris más claro al pasar el mouse */
}

/* Número grande a la izquierda */
.episodio-numero {
  font-size: 1.5rem;
  color: #d2d2d2;
  font-weight: 500;
  min-width: 40px;
  text-align: center;
  margin-right: 15px;
}

/* Miniatura del episodio */
.episodio-img-wrapper {
  position: relative;
  width: 140px; 
  height: 78px; /* Aspecto 16:9 aprox */
  margin-right: 20px;
  flex-shrink: 0; /* Evita que se aplaste */
  overflow: hidden;
  border-radius: 6px;
}

.episodio-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

/* Efecto hover en la imagen */
.episodio-item:hover .episodio-img {
  transform: scale(1.05);
  filter: brightness(0.7);
}

/* Icono Play superpuesto (oculto por defecto) */
.episodio-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  background: rgba(0,0,0,0.6);
  border: 1px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0; /* Invisible */
  transition: opacity 0.2s ease;
}

.episodio-play-icon::after {
  content: "▶";
  font-size: 12px;
  color: white;
  margin-left: 2px;
}

.episodio-item:hover .episodio-play-icon {
  opacity: 1; /* Visible al hover */
}

/* Información Texto (Título y Sinopsis) */
.episodio-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden; /* Para textos largos */
}

.episodio-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.episodio-titulo {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.episodio-duracion {
  font-size: 0.9rem;
  color: #fff;
  font-weight: 600;
}

.episodio-sinopsis {
  font-size: 0.85rem;
  color: #a3a3a3;
  line-height: 1.4;
  margin: 0;
  
  /* Truco CSS para cortar texto a 2 líneas */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === RESPONSIVE PARA MÓVILES === */
@media (max-width: 700px) {
  .episodio-img-wrapper {
    width: 110px;
    height: 62px;
    margin-right: 15px;
  }
  
  .episodio-numero {
    font-size: 1.1rem;
    min-width: 25px;
    margin-right: 10px;
  }
  
  .episodio-sinopsis {
    display: none; /* Ocultamos sinopsis en celular para ahorrar espacio */
  }

  .episodio-titulo {
    font-size: 0.9rem;
  }
}

/* === ESTILOS DEL MODAL DE EDICIÓN === */

/* Fondo oscuro que cubre toda la pantalla */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Fondo muy oscuro */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Por encima de todo */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Cuando le quitamos la clase hidden (vía JS) */
.modal-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

/* La cajita del formulario */
.modal-content {
    background: #1f1f1f;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    border: 1px solid #333;
}

.modal-content h3 {
    margin-top: 0;
    color: white;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    background: #333;
    border: 1px solid #444;
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    outline: none;
}

.modal-content input:focus {
    border-color: #e50914; /* Rojo Vanacue */
}

/* Botones */
.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.btn-primary {
    background-color: #e50914;
    color: white;
}
.btn-primary:hover { background-color: #f40612; }

.btn-secondary {
    background-color: #444;
    color: white;
}
.btn-secondary:hover { background-color: #555; }

/* Utilidad */
.hidden { display: none !important; } /* Aseguramos que hidden funcione */

/* 2. Reglas específicas para móvil */
@media (max-width: 768px) {
    .modal-overlay {
        /* En vez de centrar, alineamos al inicio para que no se corte arriba */
        align-items: flex-start; 
        padding-top: 20px; /* Un poco de aire arriba */
        padding-bottom: 20px; /* Un poco de aire abajo */
    }

    .modal-container, .modal-content {
        /* Aseguramos que quepa a lo ancho y no se desborde */
        width: 95%; 
        margin: 0 auto; /* Centrado horizontal */
        
        /* Importante: Si tenías una altura fija, quítala */
        height: auto; 
        max-height: none; 
    }
}

/* =======================================================
   TARJETAS PEQUEÑAS + ESTRELLA PEQUEÑA
   ======================================================= */

@media (max-width: 768px) {
    
    /* 1. ARREGLO DE LA ESTRELLA GIGANTE */
    .icono-favorito {
        width: 28px !important;
        height: 28px !important;
        top: 6px !important;     
        right: 6px !important;   
        z-index: 50 !important;
    }

    /* 2. ARREGLO DE LA TARJETA (2.5 Tarjetas visibles) */
    .carrusel .tarjeta {
        width: 38vw !important;       
        min-width: 38vw !important;  
        height: auto !important;      
        border-radius: 8px !important;
        margin-right: 0 !important;   
    }

    /* 3. ARREGLO DE LA IMAGEN (FORMATO PÓSTER AUTOMÁTICO) */
    .carrusel .tarjeta img:not(.icono-favorito) {
        width: 100% !important;
        height: auto !important;      /* Dejamos que la altura se calcule sola */
        aspect-ratio: 2/3 !important; /* Forzamos la proporción de póster de cine */
        object-fit: cover !important; 
    }

    /* 4. TEXTOS (Ajustados al nuevo ancho) */
    .carrusel .contenido {
        padding: 8px 6px !important; /* Un poco menos de padding lateral */
        text-align: left !important;
    }

    .carrusel .contenido h3 {
        font-size: 0.85rem !important; /* Reducimos ligeramente para que quepa bien */
        line-height: 1.2 !important;
        margin-bottom: 2px !important;
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    .carrusel .contenido p {
        display: block !important;     
        font-size: 0.6rem !important; 
        color: #bbb !important;
        margin: 0 !important;
    }

    /* Ajuste de espaciado del carrusel */
    .carrusel {
        gap: 12px !important; 
        padding: 1rem 12px !important;
    }
}

/* === INDICADORES DE ESTADO DE STREAMING (Punto con ondas) === */

/* Base del indicador (el punto central) */
.indicator-stream {
  position: absolute;
  top: 12px;   /* Ajustado para alinear mejor el centro con el icono de favoritos */
  left: 12px;
  width: 14px;  /* Tamaño del punto central */
  height: 14px;
  border-radius: 50%;
  z-index: 10;
  pointer-events: none; /* El click traspasa a la tarjeta */
  box-shadow: 0 0 6px rgba(0,0,0,0.6); /* Sombra base para profundidad */
}

/* Pseudo-elemento para la onda (el aro exterior que se expande) */
.indicator-stream::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0.7;
    z-index: -1; /* Detrás del punto central */
}

/* --- ESTADO: ONLINE (Disponible) --- */
/* Punto central verde vibrante */
.indicator-stream.online {
    background-color: #00ff2a; /* Verde neón */
    box-shadow: 0 0 10px #00ff2a, inset 0 0 3px rgba(255,255,255,0.6); /* Brillo externo + brillo interno */
}

/* Onda verde */
.indicator-stream.online::before {
    background-color: #00ff2a;
    animation: pulse-green 2s infinite ease-out; /* Animación continua */
}

/* --- ESTADO: OFFLINE (No disponible) --- */
/* Punto central rojo vibrante */
.indicator-stream.offline {
    background-color: #ff1100; /* Rojo neón */
    box-shadow: 0 0 10px #ff1100, inset 0 0 3px rgba(255,255,255,0.4);
}
/* Onda roja (opcional: puedes quitar la animación si quieres que el offline sea estático) */
.indicator-stream.offline::before {
    background-color: #ff1100;
    animation: pulse-red 2.5s infinite ease-out; /* Un poco más lento que el verde */
}


/* --- ANIMACIONES DE ONDAS (Keyframes) --- */
@keyframes pulse-green {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    70% {
         /* Expansión máxima */
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0; /* Se desvanece al final */
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

@keyframes pulse-red {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    70% {
        transform: translate(-50%, -50%) scale(2.0); /* Onda roja un poco más pequeña */
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.0);
        opacity: 0;
    }
}

/* --- AJUSTES MÓVILES --- */
@media (max-width: 768px) {
    .indicator-stream {
        width: 12px;
        height: 12px;
        top: 10px;
        left: 10px;
    }
    /* Reducimos un poco la expansión de la onda en móvil para que no tape mucho */
    @keyframes pulse-green {
        0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
        70% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
        100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
    }
}


/* ========================================= */
/* === BOTÓN VOLVER ARRIBA (SCROLL TOP) === */
/* ========================================= */

.btn-scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background-color: #e50914; /* Rojo Vanacue */
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 900; /* Debajo del menú (1000) pero sobre el contenido */
  
  /* Centrado del icono */
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* Sombra para que flote bonito */
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  
  /* Animación de entrada/salida */
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none; /* No clickeable si no se ve */
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s;
}

.btn-scroll-top:hover {
  background-color: #f40612; /* Rojo más claro al pasar mouse */
  transform: translateY(0) scale(1.1); /* Efecto pop */
}

/* Clase para mostrarlo (se activa con JS) */
.btn-scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.btn-scroll-top img {
  width: 24px;
  height: 24px;
  /* Filtro para asegurar que el icono se vea blanco si tu svg es negro */
  filter: brightness(0) invert(1); 
}

/* Ajuste para móvil: un poco más pequeño y pegado */
@media (max-width: 600px) {
  .btn-scroll-top {
    width: 45px;
    height: 45px;
    bottom: 1.5rem;
    right: 1.5rem;
  }
}

/* ========================================= */
/* === AJUSTE HERO RESPONSIVE (MÓVIL) === */
/* ========================================= */
@media (max-width: 768px) {
  .hero-content {
    left: 1.5rem;      /* Reducimos de 4rem a 1.5rem para pegarlo a la izquierda */
    bottom: 15%;       /* Bajamos un poco el contenido para que no tape la cara de los personajes */
    width: 90%;        /* Permitimos que ocupe más ancho de pantalla */
    text-align: left;  /* Aseguramos que el texto se alinee a la izquierda */
  }

  .hero-logo {
    width: 70%;        /* Reducimos el logo un poco para que no se vea gigante */
    max-width: 250px;  /* Límite máximo de ancho */
    margin-left: 0;    /* Aseguramos que no tenga margen extra */
  }

  .hero-subtitle {
    font-size: 1rem;   /* Ajustamos el tamaño del subtítulo para móviles */
    max-width: 100%;   /* Que ocupe el ancho disponible */
  }

  .hero-botones-wrapper {
    justify-content: flex-start; /* Alineamos los botones (Play y Telegram) a la izquierda */
    gap: 10px;         /* Reducimos un poco el espacio entre botones */
  }
  
  /* Ajuste opcional para el botón de reproducir en móvil */
  .hero-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }
}