/* =========================================================
   WebSeries – Estilo streaming (Header Mejorado & Clean UI)
   ========================================================= */

:root {
  --bg: #0b0f1a;
  --panel: #111827;
  --panel-2: #1e293b;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --fav: #facc15;
  --header-height: 70px;
}

* { 
  box-sizing: border-box; 
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  scroll-behavior: smooth;
}

img { display: block; max-width: 100%; }

/* ===== NUEVO HEADER (GLASSMORPHISM) ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(11, 15, 26, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Brand / Logo */
.header-left {
  display: flex;
  align-items: center;
  gap: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 800;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}

.logo-text { color: #fff; }
.accent-text { color: var(--accent); }
.logo-icon { font-size: 1.6rem; }

/* Navegación Principal */
.main-nav {
  display: flex;
  gap: 15px;
}

.nav-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  padding: 8px 5px;
}

.nav-link:hover {
  color: #fff;
  transform: translateY(-1px);
}

/* Buscador Restaurado y Estilizado */
.search {
  flex: 1;
  max-width: 450px;
  position: relative; /* Importante para que las sugerencias se alineen debajo */
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 0.85rem;
  opacity: 0.4;
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 10px 15px 10px 42px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.search input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1);
}

/* Sugerencias (aseguramos que no queden ocultas) */
.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 350px;
  overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  margin-top: 8px;
  z-index: 1001; /* Por encima del header */
}

/* Perfil de Usuario y Dropdown */
.header-right {
  display: flex;
  align-items: center;
}

.user-profile {
  position: relative;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 50px;
  transition: background 0.2s;
}

.user-info:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-name {
  font-size: 0.9rem;
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--panel-2);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 180px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  margin-top: 0;
}

.user-dropdown::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: transparent;
}

.user-profile:hover .user-dropdown {
  display: block;
}

.dropdown-header {
  padding: 8px 12px;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 1px;
  font-weight: 700;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.dropdown-item:hover { background: rgba(255, 255, 255, 0.05); }
.dropdown-item.danger { color: #f87171; }
.dropdown-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SUGERENCIAS DE BÚSQUEDA ===== */
.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-height: 350px;
  overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  margin-top: 8px;
}
.suggest.hidden { display: none; }
.s-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  cursor: pointer;
}
.s-item:hover { background: var(--panel); }
.s-thumb { width: 40px; height: 60px; object-fit: cover; border-radius: 4px; }
.s-title { font-weight: 600; font-size: 0.9rem; }
.s-muted { color: var(--muted); font-size: 0.75rem; }

/* ===== LAYOUT & CONTENT ===== */
.container { 
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 24px; 
}

.back { 
  margin-bottom: 24px; 
  color: var(--accent); 
  cursor: pointer; 
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0 15px;
}
.section-header h2 { margin: 0; font-size: 1.4rem; font-weight: 700; }

.btn.ghost { 
  background: transparent; 
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn.ghost:hover { border-color: var(--muted); color: #fff; }

/* ===== CARDS & ROWS ===== */
.row {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 15px;
  scrollbar-width: thin;
}
.row::-webkit-scrollbar { height: 6px; }
.row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.card {
  width: 190px;
  flex: 0 0 auto;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.5);
}
.card img { aspect-ratio: 2/3; object-fit: cover; width: 100%; }
.card .meta { padding: 12px; position: relative;}
.card .title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== CONTINUAR VIENDO ===== */
.continue-card {
  display: flex;
  gap: 16px;
  background: var(--panel);
  padding: 12px;
  border-radius: 12px;
  width: 320px;
  flex: 0 0 auto;
  cursor: pointer;
  border: 1px solid transparent;
}
.continue-card:hover { background: var(--panel-2); border-color: var(--border); }
.continue-card img { width: 80px; height: 110px; object-fit: cover; border-radius: 8px; }
.continue-info { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 5px; }
.continue-time { font-size: 0.75rem; color: var(--muted); }
.progress-bar { height: 4px; background: var(--border); border-radius: 10px; overflow: hidden; margin-top: 5px; }
.progress { height: 100%; background: var(--accent); }

/* ===== EPISODIOS ===== */
.episodes { display: flex; flex-direction: column; gap: 10px; }
.episode {
  background: var(--panel);
  padding: 14px 20px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}
.episode:hover { border-color: var(--border); background: var(--panel-2); }
.episode-row { display: flex; align-items: center; gap: 15px; }
.episode-num { color: var(--accent); font-weight: 800; min-width: 30px; }
.fav-icon { margin-left: auto; color: var(--muted); transition: color 0.2s; }
.fav-icon.active { color: var(--fav); }
.watched { opacity: 0.5; }

/* ===== PLAYER ===== */
.player-container { margin: 20px 0; background: #000; border-radius: 16px; overflow: hidden; }
video { width: 100%; max-height: 80vh; display: block; }
.autoplay { padding: 15px; background: var(--panel); text-align: center; font-weight: 600; color: var(--accent); }

/* ===== AUTH OVERLAY ===== */
.auth-overlay {
  position: fixed; inset: 0;
  background: rgba(11, 15, 26, 0.98);
  backdrop-filter: blur(15px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.auth-box {
  background: var(--panel);
  width: 100%; max-width: 400px;
  padding: 40px; border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}
.auth-tabs { display: flex; margin-bottom: 25px; border-bottom: 1px solid var(--border); }
.tab-btn { flex: 1; padding: 12px; background: none; border: none; color: var(--muted); cursor: pointer; }
.tab-btn.active { color: var(--accent); border-bottom: 2px solid var(--accent); font-weight: 700; }
.form-group { margin-bottom: 20px; }
.form-group input {
  width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: #fff;
}
.auth-btn {
  width: 100%; padding: 14px; background: var(--accent); border: none;
  border-radius: 10px; color: #000; font-weight: 700; cursor: pointer;
}

/* ===== FAVORITOS VIEW ===== */
.fav-list { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px 0; }
.fav-item { width: 180px; background: var(--panel); border-radius: 12px; overflow: hidden; cursor: pointer; }
.fav-item:hover { transform: scale(1.05); }
.fav-item img { aspect-ratio: 2/3; object-fit: cover; }
.fav-item .title { padding: 10px; font-size: 0.85rem; text-align: center; }

/* Responsive */
@media (max-width: 768px) {
  .main-nav, .user-name { display: none; }
  .header-container { padding: 0 15px; }
  .search-container { max-width: 200px; }
  .logo-text { display: none; }
}

.s-more {
  padding: 10px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--accent);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  border-top: 1px solid var(--border);
}

.s-more:hover {
  background: rgba(255,255,255,0.08);
}

.search-results-empty {
    text-align: center;
    padding: 100px 20px;
}

.search-results-empty h2 {
    color: var(--muted);
    margin-bottom: 20px;
}

/* ===== SERIE DETAIL (Mejorado) ===== */
.serie-detail-header {
  display: flex;
  gap: 30px;
  margin-bottom: 40px; /* Más espacio con lo de abajo */
  align-items: center; /* Alineación centrada para que no se vea gigante */
  background: rgba(255, 255, 255, 0.03);
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.serie-poster {
  width: 140px; /* Tamaño reducido más elegante */
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  flex-shrink: 0;
}

.serie-info-text {
  flex: 1;
}

.serie-info-text h2 {
  margin: 0 0 10px 0;
  font-size: 1.8rem;
}

/* Selector de temporadas mejorado */
.serie-info-text select {
  margin-top: 15px;
  background: var(--panel-2);
  color: white;
  border: 1px solid var(--border);
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
}

/* ===== PAGINACIÓN (Con más espacio) ===== */
.pagination {
    display: flex;
    flex-wrap: wrap; /* Permite que se ajuste en móviles */
    align-items: center;
    justify-content: space-between; /* Separación entre controles y buscador */
    gap: 20px;
    margin: 40px 0;
    padding: 15px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.goto-episode {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-2);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.goto-episode input {
    width: 60px;
    background: transparent;
    border: none;
    color: white;
    font-weight: 600;
    outline: none;
    text-align: center;
}

/* Eliminar flechas del input number para diseño limpio */
.goto-episode input::-webkit-inner-spin-button,
.goto-episode input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-info {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.episodes {
  margin: 20px 0; /* Espacio extra para la lista de episodios */
}

.title-container {
    display: flex;
    align-items: center;
    width: 100%;
}

.title-container .title { 
    font-weight: 600; 
    font-size: 0.95rem; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    padding-right: 30px; /* CREA EL HUECO para la bandera para que el texto no la pise */
    flex: 1;
}

.lang-flag {
    position: absolute; /* Anclamos la bandera */
    right: 12px;        /* Misma distancia que el padding del meta */
    top: 50%;           /* La centramos verticalmente respecto al contenedor meta */
    transform: translateY(-50%); 
    display: flex;
    align-items: center;
    pointer-events: none; /* Para que no interfiera con el click de la tarjeta */
}v

.lang-flag svg {
  border-radius: 50%; /* Asegura que se vean circulares */
}

/* Contenedor en rejilla para que no se amontonen */
.grid-container {
    display: grid;
    /* Crea columnas de mínimo 180px que se expanden solas */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

/* Ajuste para que las carátulas mantengan el tamaño */
.grid-container .card {
    width: 100%; /* Que ocupen el ancho de su celda de la rejilla */
    margin: 0;
}

.grid-container .card img {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 8px;
}