/* ==========================================================================
   SERRA IPTV — Paleta 60-30-10 Senior Premium (Netflix Dark Mode)
   60% Dominante: #0f0f11 / #141417
   30% Secundario: #1b1b20 / #25252d / #f8fafc / #94a3b8
   10% Acento: #e50914 (Rojo Cine)
   ========================================================================== */

:root {
  --bg-base: #0f0f11;
  --bg-elevated: #18181d;
  --bg-card: #1e1e24;
  --bg-card-hover: #282831;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #e50914;
  --accent-hover: #ff1e29;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --transition: 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Focus visible para navegación con control remoto de Smart TV */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(15, 15, 17, 0.86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  letter-spacing: 0.04em;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.brand-name strong {
  color: var(--accent);
  font-weight: 800;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}

.nav-btn:hover, .nav-btn.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

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

.search-input {
  width: 240px;
  padding: 9px 14px 9px 36px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.88rem;
  transition: var(--transition);
}

.search-input:focus {
  border-color: rgba(229, 9, 20, 0.7);
  width: 280px;
}

/* BUTTONS */
.btn-accent, .btn-secondary, .btn-glass, .btn-play-hero {
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  padding: 9px 14px;
  font-size: 0.86rem;
}

.btn-accent:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 9px 14px;
  font-size: 0.86rem;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-play-hero {
  background: var(--accent);
  color: #fff;
  padding: 13px 24px;
  font-size: 0.98rem;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(229, 9, 20, 0.38);
}

.btn-play-hero:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 13px 20px;
  font-size: 0.94rem;
  border-radius: 10px;
  backdrop-filter: blur(10px);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-full {
  width: 100%;
  padding: 12px 16px;
}

/* MAIN */
.main-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px 48px;
}

/* HERO */
.hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 40px 36px;
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
  background:
    radial-gradient(circle at 82% 20%, rgba(229, 9, 20, 0.24), transparent 52%),
    linear-gradient(120deg, #16161b 0%, #101014 55%, #191316 100%);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 680px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(229, 9, 20, 0.16);
  color: #ff6b72;
  border: 1px solid rgba(229, 9, 20, 0.45);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.badge-pill {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 0.96rem;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* CONTROLS */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.source-tabs, .category-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.source-tab, .cat-pill {
  white-space: nowrap;
  border-radius: 999px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 15px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.source-tab:hover, .cat-pill:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.source-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cat-pill.active {
  background: var(--text-primary);
  color: var(--bg-base);
  border-color: var(--text-primary);
}

/* STATUS BANNER */
.status-banner {
  background: rgba(229, 9, 20, 0.12);
  border: 1px solid rgba(229, 9, 20, 0.35);
  color: #fecaca;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.88rem;
}

/* CATALOG GRID & ROWS */
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.section-heading span {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.channel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  padding: 0;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.channel-card:hover, .channel-card:focus-visible {
  transform: translateY(-4px) scale(1.015);
  border-color: rgba(229, 9, 20, 0.65);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
}

.card-thumb {
  position: relative;
  height: 124px;
  background: linear-gradient(135deg, #141418 0%, #23232c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.card-thumb img {
  max-width: 78%;
  max-height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

.card-initials {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(229, 9, 20, 0.18);
  border: 1px solid rgba(229, 9, 20, 0.4);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}

.channel-card:hover .card-play-overlay {
  opacity: 1;
}

.card-play-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  box-shadow: 0 6px 20px rgba(229, 9, 20, 0.55);
}

.card-fav-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 15, 17, 0.78);
  color: #fbbf24;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.75rem;
}

.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-group {
  font-size: 0.76rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}

/* LOADING & EMPTY */
.loading-state, .empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

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

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 5, 7, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.player-shell {
  width: min(1120px, 100%);
  background: #121216;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.player-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.player-group {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.player-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
}

.icon-btn.fav-active {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.5);
}

.icon-btn-close:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.video-stage {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  width: 100%;
}

.video-stage video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.player-feedback {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 14, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 16px;
}

.player-feedback p {
  margin: 0;
  max-width: 460px;
  color: #e2e8f0;
  line-height: 1.5;
}

.player-feedback-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* FORM MODALS */
.modal-card {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.06rem;
}

.modal-body {
  padding: 20px;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-row input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-base);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
}

.saved-lists-block {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.saved-lists-block h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.saved-lists {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.saved-list-item button {
  background: transparent;
  border: 1px solid rgba(229, 9, 20, 0.45);
  color: #fca5a5;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 0.76rem;
  cursor: pointer;
}

/* FOOTER CANÓNICO OFICIAL */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 22px 16px 28px;
  margin-top: 24px;
}

.footer-text {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
  line-height: 1.35;
}

.footer-brand, .footer-credit {
  display: block;
}

.footer-credit {
  font-size: calc(1em - 2px);
  font-weight: 400;
  margin-top: 3px;
}

.footer-credit strong {
  color: #e2e8f0;
  font-weight: 700;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .topbar {
    padding: 12px 16px;
  }
  .main-container {
    padding: 16px 16px 40px;
  }
  .hero {
    padding: 26px 20px;
  }
  .search-input, .search-input:focus {
    width: 100%;
  }
  .topbar-right {
    width: 100%;
  }
  .search-wrap {
    flex: 1;
  }
  .channels-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
  }
}
