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

:root {
  --bg: #080c12;
  --surface: #0f1520;
  --card: #131c2e;
  --card2: #1a2540;
  --border: rgba(255,255,255,0.07);
  --accent: #00d4ff;
  --accent2: #0099cc;
  --cast: #1db954;
  --live: #ff3b3b;
  --text: #e8f0fe;
  --sub: #6080a0;
  --muted: #304060;
  --radius: 14px;
}

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: rgba(8,12,18,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.15rem; font-weight: 700; letter-spacing: 0.5px;
  text-decoration: none; color: var(--text);
}

.logo-mark {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 20px rgba(0,212,255,0.3);
}

.topbar-right {
  display: flex; align-items: center; gap: 10px;
}

/* ── Cast button ── */
.cast-btn {
  display: none;
  align-items: center; gap: 7px;
  padding: 8px 16px;
  background: rgba(29,185,84,0.15);
  border: 1px solid rgba(29,185,84,0.3);
  border-radius: 8px;
  color: var(--cast);
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.cast-btn:hover { background: rgba(29,185,84,0.25); }
.cast-btn.visible { display: flex; }

/* ── Player overlay ── */
.player-wrap {
  display: none;
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.92);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.player-wrap.active { display: flex; }

.player-inner {
  position: relative;
  width: min(100vw, calc(100vh * 16/9));
  height: min(100vh, calc(100vw * 9/16));
  max-width: 1100px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 60px rgba(0,0,0,0.8);
}

.player-inner video {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

/* yt-player y cualquier iframe dentro deben llenar todo el contenedor */
#yt-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#yt-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.player-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 10px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none;
}

.player-title { font-size: 0.9rem; font-weight: 600; }

.close-btn {
  background: rgba(255,255,255,0.2);
  border: none; border-radius: 6px;
  color: var(--text); cursor: pointer;
  padding: 8px 14px; font-size: 0.85rem;
  pointer-events: all;
  transition: background 0.2s;
}
.close-btn:hover { background: rgba(255,255,255,0.35); }

/* ── Filtros ── */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 16px 20px 8px;
}

.filter-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--sub);
  font-size: 0.8rem; font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #000; font-weight: 600;
}

/* ── Grilla ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 12px 20px 40px;
}

.canal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  outline: none;
}
.canal-card:hover,
.canal-card.focused {
  background: var(--card2);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,212,255,0.15);
}

.canal-logo {
  width: 48px; height: 48px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface);
}

.canal-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.canal-numero {
  font-size: 0.7rem;
  color: var(--sub);
  font-family: 'DM Mono', monospace;
}

.canal-nombre {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.3;
  /* truncar en 2 líneas */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.canal-localidad {
  font-size: 0.72rem;
  color: var(--sub);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-live {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--live);
  color: #fff; font-size: 0.65rem; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  margin-top: 6px;
}
.badge-live::before {
  content: '';
  width: 5px; height: 5px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

.badge-tipo {
  position: absolute; top: 10px; right: 10px;
  font-size: 0.6rem; font-weight: 700;
  padding: 2px 5px; border-radius: 4px;
  background: rgba(0,212,255,0.15);
  color: var(--accent);
}

/* ── Estado vacío ── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--sub);
}

.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text); }

/* ── Animations ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Nav tabs ── */
.nav-tabs {
  display: flex; gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.nav-tab {
  padding: 12px 16px;
  background: none; border: none;
  color: var(--sub); font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; padding: 8px 12px 40px; }
  .topbar { padding: 12px 14px; }
}
