/* ============================================================
   EVO TV Play - Futuristic Cinema & Mobile Web Player
   Dual Orientation: Vertical (Mobile) / Horizontal (iPad, PC, TV)
   ============================================================ */

:root {
  --bg-primary: #060913;
  --bg-secondary: #0d1424;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(26, 38, 66, 0.85);
  --bg-acrylic: rgba(10, 15, 30, 0.82);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-cyan: rgba(0, 229, 255, 0.25);
  --border-cyan-glow: rgba(0, 229, 255, 0.6);
  --neon-cyan: #00e5ff;
  --neon-blue: #0070f3;
  --neon-purple: #7928ca;
  --accent-gradient: linear-gradient(135deg, #00e5ff 0%, #7928ca 100%);
  --accent-glow: 0 0 25px rgba(0, 229, 255, 0.35);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 260px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  line-height: 1.5;
  user-select: none;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.25);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--neon-cyan);
}

/* ============================================================
   PANTALLA DE EL GUARDIÁN (AUTENTICACIÓN Y EMPAREJAMIENTO)
   ============================================================ */
/* ============================================================
   BLINDAJE DE PANTALLA SMART TV: OCULTAR APP HASTA AUTENTICAR
   ============================================================ */
body:not(.authenticated) .app-container {
  display: none !important;
}

.guardian-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  min-width: 100%;
  min-height: 100%;
  background: #060913;
  background: radial-gradient(circle at 50% 30%, #111a36 0%, #060913 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
  backdrop-filter: blur(20px);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.guardian-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.guardian-modal {
  width: 100%;
  max-width: 480px;
  margin: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-cyan);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 229, 255, 0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(25px);
  padding: 32px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

.guardian-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
}

.guardian-logo-img {
  max-height: 52px;
  max-width: 220px;
  object-fit: contain;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.4));
}

.guardian-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* Selector de pestañas de activación */
.guardian-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.guardian-tab-btn {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.25s ease;
}

.guardian-tab-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 229, 255, 0.3);
}

/* Caja de Código de Emparejamiento */
.pairing-code-box {
  background: rgba(0, 0, 0, 0.5);
  border: 2px dashed var(--neon-cyan);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  margin: 16px 0;
  box-shadow: inset 0 0 20px rgba(0, 229, 255, 0.08);
}

.pairing-code-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--neon-cyan);
  font-weight: 700;
  margin-bottom: 8px;
}

.pairing-code-display {
  font-family: "Courier New", Courier, monospace, monospace;
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 5px;
  color: #ffffff;
  text-shadow: 0 0 15px rgba(0, 229, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.pairing-qr-wrapper {
  display: flex;
  justify-content: center;
  margin: 18px 0;
}

.pairing-qr-box {
  background: #ffffff;
  padding: 12px;
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.pairing-countdown {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.pairing-polling-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 229, 255, 0.3);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Formulario de Login Directo */
.login-form-group {
  margin-bottom: 16px;
  text-align: left;
}

.login-form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.login-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #10b981;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-whatsapp:hover {
  background: #10b981;
  color: #ffffff;
}

/* ============================================================
   LAYOUT PRINCIPAL DEL REPRODUCTOR
   ============================================================ */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ============================================================
   MODO VERTICAL / MÓVIL (< 768px o portrait)
   ============================================================ */
@media (max-width: 768px), (orientation: portrait) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    display: none; /* En móvil usamos header superior y barra inferior */
  }

  .main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  /* Player Fijo Superior Sticky */
  .player-box {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  }

  /* Barra de herramientas móvil */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-logo-img {
    height: 28px;
    object-fit: contain;
  }

  .mobile-client-badge {
    font-size: 0.72rem;
    padding: 3px 8px;
    background: rgba(0, 229, 255, 0.15);
    color: var(--neon-cyan);
    border-radius: var(--radius-full);
    font-weight: 600;
  }

  .mobile-tabs {
    display: flex;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .mobile-tabs::-webkit-scrollbar { display: none; }

  .mobile-tab-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border: none;
    background: transparent;
    white-space: nowrap;
    cursor: pointer;
    border-bottom: 2px solid transparent;
  }

  .mobile-tab-btn.active {
    color: var(--neon-cyan);
    border-bottom-color: var(--neon-cyan);
  }

  /* Barra de búsqueda móvil */
  .search-wrapper {
    padding: 10px 14px;
    background: var(--bg-primary);
  }

  /* Selector de Categorías (Pills Horizontales) */
  .categories-pills {
    display: flex;
    gap: 8px;
    padding: 4px 14px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--bg-primary);
  }
  .categories-pills::-webkit-scrollbar { display: none; }

  .cat-pill {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .cat-pill.active {
    background: var(--neon-cyan);
    color: #060913;
    font-weight: 700;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
  }

  /* Lista Vertical de Canales (TikTok / Reels / YouTube Style) */
  .channels-container {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 60px;
  }

  .channel-card-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .channel-card-mobile.active {
    background: rgba(0, 229, 255, 0.12);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
  }

  .channel-logo-wrapper {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
  }

  .channel-logo-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
  }

  .channel-info {
    flex: 1;
    min-width: 0;
  }

  .channel-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .channel-category-tag {
    font-size: 0.72rem;
    color: var(--text-dim);
  }
}

/* ============================================================
   MODO HORIZONTAL / CINEMA (iPad, PC, Smart TV >= 769px landscape)
   ============================================================ */
@media (min-width: 769px) and (orientation: landscape), (min-width: 1024px) {
  .app-container {
    display: flex;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
  }

  .mobile-header, .mobile-tabs {
    display: none !important;
  }

  /* Barra Lateral Cine Glassmorphism */
  .sidebar {
    width: var(--sidebar-w);
    background: var(--bg-acrylic);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    flex-shrink: 0;
    z-index: 50;
    backdrop-filter: blur(20px);
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
  }

  .sidebar-logo-img {
    height: 38px;
    object-fit: contain;
    filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.3));
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
  }

  .nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
  }

  .nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
  }

  .nav-btn.active {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
  }

  .nav-btn-icon {
    font-size: 1.15rem;
  }

  .sidebar-client-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: auto;
  }

  .sidebar-client-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
  }

  .sidebar-client-exp {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 2px;
  }

  .btn-logout-sidebar {
    margin-top: 10px;
    width: 100%;
    padding: 8px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .btn-logout-sidebar:hover {
    background: #ef4444;
    color: #fff;
  }

  /* Escenario Principal Cine */
  .main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at top right, #0d152c 0%, #060913 70%);
  }

  .cinema-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
  }

  /* Área del Reproductor (Izquierda/Superior) */
  .cinema-player-area {
    flex: 2;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
  }

  .player-box {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 72vh;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 229, 255, 0.15);
    border: 1px solid var(--border-cyan);
    position: relative;
  }

  /* Panel lateral de Canales en Cine (Derecha) */
  .cinema-channels-area {
    flex: 1;
    max-width: 420px;
    background: rgba(10, 16, 32, 0.6);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(15px);
  }

  .cinema-channels-header {
    padding: 18px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .categories-pills {
    display: flex;
    gap: 8px;
    padding: 10px 18px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-subtle);
  }

  .cat-pill {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
    cursor: pointer;
  }
  .cat-pill.active {
    background: var(--neon-cyan);
    color: #060913;
    font-weight: 700;
  }

  .channels-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px;
  }

  .channel-card-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .channel-card-mobile:hover {
    background: var(--bg-card-hover);
    transform: translateX(4px);
  }
  .channel-card-mobile.active {
    background: rgba(0, 229, 255, 0.12);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
  }

  .channel-logo-wrapper {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
  }
  .channel-logo-img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
  }
  .channel-info {
    flex: 1;
    min-width: 0;
  }
  .channel-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .channel-category-tag {
    font-size: 0.74rem;
    color: var(--text-dim);
  }
}

/* ============================================================
   VIDEO PLAYER INTERNALS & CUSTOM CONTROLS
   ============================================================ */
.player-box video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-overlay-buffering {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

.player-overlay-buffering.active {
  opacity: 1;
  visibility: visible;
}

.buffer-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(0, 229, 255, 0.2);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spin 0.9s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

.buffer-text {
  margin-top: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.player-info-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 9, 19, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  z-index: 10;
  max-width: calc(100% - 90px);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.player-info-badge.faded {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translateY(-8px) !important;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #ef4444;
  text-transform: uppercase;
  flex-shrink: 0;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.4; }
}

.player-channel-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.player-badge-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0 2px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
  flex-shrink: 0;
}

.player-badge-close:hover {
  color: #fff;
}

/* Ecualizador Animado para Canal en Reproducción */
.playing-equalizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  width: 16px;
  margin-left: auto;
}

.eq-bar {
  width: 3px;
  background: var(--neon-cyan);
  border-radius: 1px;
  animation: bounce-eq 0.8s ease infinite alternate;
}

.eq-bar:nth-child(1) { height: 40%; animation-delay: 0.1s; }
.eq-bar:nth-child(2) { height: 100%; animation-delay: 0.3s; }
.eq-bar:nth-child(3) { height: 60%; animation-delay: 0.2s; }

@keyframes bounce-eq {
  from { height: 20%; }
  to { height: 100%; }
}

/* Botón flotante para rotar a pantalla completa en móvil */
.btn-fullscreen-rotate {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-cyan);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 15;
  backdrop-filter: blur(8px);
}

/* Buscador */
.search-input-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.2);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ============================================================
   MODAL DE EPISODIOS Y TEMPORADAS DE SERIES
   ============================================================ */
.modal-episodes-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-episodes-content {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 229, 255, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-episodes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.4);
}

.series-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.series-cover-thumb {
  width: 48px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
}

.btn-close-episodes {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-close-episodes:hover {
  background: #ef4444;
}

.seasons-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  scrollbar-width: none;
}
.seasons-bar::-webkit-scrollbar { display: none; }

.season-tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.season-tab-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
}

.episodes-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.episode-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}
.episode-card:hover {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--neon-cyan);
  transform: translateX(4px);
}

.episode-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.episode-num-badge {
  background: rgba(0, 229, 255, 0.15);
  color: var(--neon-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 800;
}

.episode-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
}

.btn-play-episode {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

/* ============================================================
   SISTEMA DE ANCLAJE A PANTALLA (PWA ANDROID + IOS IPHONE)
   ============================================================ */
.btn-pwa-badge {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: var(--neon-cyan);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-pwa-badge:hover {
  background: rgba(0, 229, 255, 0.25);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

.btn-pwa-badge-sidebar {
  width: 100%;
  margin-top: 8px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--neon-cyan);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-pwa-badge-sidebar:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--neon-cyan);
}

/* Banner Flotante Inferior */
.pwa-floating-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  background: rgba(12, 18, 30, 0.95);
  border: 1px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 229, 255, 0.25);
  border-radius: 16px;
  padding: 12px 16px;
  z-index: 9999;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  animation: slideUpBanner 0.4s ease;
}

@keyframes slideUpBanner {
  from { transform: translate(-50%, 40px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.pwa-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
}

.pwa-banner-text strong {
  display: block;
  font-size: 0.85rem;
  color: #fff;
  font-weight: 800;
  margin-bottom: 2px;
}

.pwa-banner-text span {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.3;
}

.btn-pwa-action {
  background: var(--neon-cyan);
  color: #060913;
  border: none;
  border-radius: var(--radius-full);
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 229, 255, 0.4);
  transition: transform 0.15s;
}
.btn-pwa-action:hover {
  transform: scale(1.05);
}

.btn-pwa-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.btn-pwa-close:hover {
  color: #fff;
}

/* Modal Instructivo para iPhone / iPad */
.ios-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.ios-modal-content {
  background: rgba(14, 20, 32, 0.98);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 229, 255, 0.2);
}

.ios-steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}

.ios-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.82rem;
  color: #f1f5f9;
  line-height: 1.4;
}

.ios-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--neon-cyan);
  color: #060913;
  font-weight: 800;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   SELECTOR DE PLATAFORMA / SERVICIO HÍBRIDO (EVOLUTION TV & VIVA PLAYER)
   ============================================================ */

.platform-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 999998;
  display: none;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.platform-modal-overlay.is-active {
  display: flex !important;
}

.platform-modal-card {
  background: linear-gradient(155deg, rgba(15, 23, 42, 0.96) 0%, rgba(10, 15, 30, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  max-width: 840px;
  width: 100%;
  padding: 36px 32px 30px 32px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 45px rgba(0, 229, 255, 0.12);
  text-align: center;
  box-sizing: border-box;
  margin: auto;
  flex-shrink: 0;
  animation: platformPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes platformPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.platform-modal-tag {
  display: inline-block;
  padding: 4px 14px;
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--neon-cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.platform-modal-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.platform-modal-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 580px;
  margin: 0 auto;
  line-height: 1.5;
}

.platform-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 28px;
  text-align: left;
}

.platform-card {
  position: relative;
  background: rgba(18, 26, 47, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 26px 22px 22px 22px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  outline: none;
}

.platform-card:hover,
.platform-card:focus-visible,
.platform-card.is-focused {
  transform: translateY(-5px);
  border-color: var(--neon-cyan);
  box-shadow: 0 16px 36px rgba(0, 229, 255, 0.22), 0 0 20px rgba(0, 229, 255, 0.3);
  background: rgba(22, 34, 60, 0.85);
}

.platform-card-viva:hover,
.platform-card-viva:focus-visible,
.platform-card-viva.is-focused {
  border-color: #8b5cf6;
  box-shadow: 0 16px 36px rgba(139, 92, 246, 0.25), 0 0 20px rgba(139, 92, 246, 0.35);
}

.platform-card-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.platform-card-badge.vip {
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
}

.platform-card-badge.extended {
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid #8b5cf6;
  color: #c4b5fd;
}

.platform-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.platform-card-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
}

.platform-viva-emblem {
  font-size: 1.8rem;
}

.platform-card-title {
  font-size: 1.28rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}

.platform-card-desc {
  font-size: 0.82rem;
  color: var(--neon-cyan);
  font-weight: 600;
  margin-bottom: 16px;
}

.platform-card-viva .platform-card-desc {
  color: #a78bfa;
}

.platform-features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.platform-features-list li {
  font-size: 0.8rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
}

.feat-check {
  color: var(--success);
  font-weight: 800;
  font-size: 0.85rem;
}

.btn-select-platform {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-select-platform.btn-evo {
  background: linear-gradient(135deg, #00e5ff 0%, #0070f3 100%);
  color: #060913;
}

.btn-select-platform.btn-evo:hover {
  filter: brightness(1.15);
}

.btn-select-platform.btn-viva {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  color: #ffffff;
}

.btn-select-platform.btn-viva:hover {
  filter: brightness(1.15);
}

.platform-modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.btn-platform-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-platform-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Selector en Sidebar */
.sidebar-platform-box {
  margin: 12px 14px 16px 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-platform-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.platform-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
}

.sidebar-platform-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
}

.btn-sidebar-switch {
  width: 100%;
  padding: 7px 10px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 8px;
  color: var(--neon-cyan);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-sidebar-switch:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--neon-cyan);
}

/* Selector en Móvil */
.btn-mobile-platform-switch {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--neon-cyan);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-mobile-platform-switch:hover {
  background: rgba(0, 229, 255, 0.22);
}

@media (max-width: 640px) {
  .platform-modal-overlay {
    padding: 16px 12px 60px 12px;
  }
  .platform-modal-overlay.is-active {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
  }
  .platform-options-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 18px;
  }
  .platform-modal-card {
    padding: 20px 16px 24px 16px;
    border-radius: 18px;
    margin: 12px auto 40px auto;
    max-width: 100%;
  }
  .platform-modal-title {
    font-size: 1.45rem;
  }
  .platform-modal-subtitle {
    font-size: 0.84rem;
  }
  .platform-card {
    padding: 18px 16px;
    border-radius: 16px;
  }
  .platform-icon-wrap {
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
  }
  .platform-features-list {
    margin: 0 0 16px 0;
    gap: 6px;
  }
  .platform-features-list li {
    font-size: 0.78rem;
  }
}

