/* ===========================================================================
   NovaIPTV · styles.css
   Tema oscuro profesional. Variables CSS para escalar/temizar fácilmente.
   =========================================================================== */
:root {
  --bg: #0c0a0b;
  --bg-soft: #141011;
  --bg-elev: #1a1416;
  --bg-elev-2: #241a1d;
  --line: #2e2125;
  --line-soft: #221a1c;
  --text: #f3ecee;
  --text-dim: #bda6ac;
  --text-mut: #897177;
  --brand: #ff2e3e;
  --brand-hover: #e51d2b;
  --brand-2: #ff6a3d;
  --accent: #19c37d;
  --danger: #ff5d6c;
  --warn: #ffb454;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .55);
  --brand-glow: rgba(255, 46, 62, .18);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --grad: linear-gradient(135deg, var(--brand), var(--brand-2));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }
.ico { width: 20px; height: 20px; flex: none; } /* tamaño base de los iconos SVG */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-elev-2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Boot / spinner ---------- */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 22px; justify-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #2a1014, var(--bg));
}
.boot__logo { font-weight: 800; font-size: 30px; letter-spacing: .5px; }
.boot__logo span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner--sm { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   LOGIN
   =========================================================================== */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: #000;
}
.login__card { width: 100%; max-width: 380px; }

/* Marca / logo */
.login__brand { text-align: center; margin-bottom: 26px; }
.login__logo-box {
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; background: none;
}
.login__logo-img {
  display: block; height: 81px; width: auto; max-width: 100%; object-fit: contain;
}
.login__logo {
  margin: 0; font-weight: 800; font-size: 26px; letter-spacing: -.5px; color: var(--text);
}
.login__logo span {
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 900;
}
.login__sub { margin: 6px 0 0; color: var(--text-mut); font-size: 13px; }

/* Panel del formulario */
.login__form {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}

/* Campos */
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld__label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.fld__wrap { position: relative; }
.fld__input {
  width: 100%; padding: 11px 13px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.fld__wrap .fld__input { padding-right: 40px; }
.fld__input::placeholder { color: var(--text-mut); }
.fld__input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.fld__eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; padding: 6px; border: none; background: transparent; color: var(--text-mut);
}
.fld__eye:hover { color: var(--text-dim); }
.fld__eye .ico { width: 18px; height: 18px; }

/* Recordar usuario */
.login__remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); cursor: pointer; user-select: none; }
.chk { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* Cuentas guardadas */
.login__saved { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.login__saved-label { font-size: 12px; color: var(--text-mut); font-weight: 600; margin-bottom: 2px; }
.login__saved-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-weight: 600; font-size: 14px; transition: border-color .15s, background .15s;
}
.login__saved-item:hover { border-color: var(--brand); background: var(--bg-elev-2); }
.login__saved-item .ico { width: 16px; height: 16px; color: var(--text-mut); }

/* Mantengo .input/.field para Ajustes y otras vistas */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.input {
  width: 100%; padding: 12px 14px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
select.input { appearance: none; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-elev-2); color: var(--text); font-weight: 600; font-size: 14px; transition: filter .15s, transform .05s, background .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--grad); border: none; color: white; box-shadow: 0 6px 18px var(--brand-glow); }
.btn--primary:hover { filter: none; background: var(--brand-hover); }
.btn--block { width: 100%; }
.btn--lg { padding: 13px 18px; font-size: 15px; }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--sm { padding: 7px 11px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ===========================================================================
   LAYOUT (shell)
   =========================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: #070506; border-right: 1px solid var(--line); padding: 18px 14px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar__logo { font-weight: 800; font-size: 21px; letter-spacing: -.4px; padding: 8px 12px 18px; }
.sidebar__logo span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); }
.nav-item.is-active { background: var(--bg-elev-2); color: var(--text); }
.nav-item .ico { width: 20px; height: 20px; flex: none; }
.sidebar__spacer { flex: 1; }
.sidebar__acct {
  margin-top: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--line); font-size: 13px;
}
.sidebar__acct b { display: block; margin-bottom: 2px; }
.sidebar__acct .muted { color: var(--text-mut); font-size: 12px; }

/* Topbar */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 24px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(11,14,20,.85); backdrop-filter: blur(10px); z-index: 20;
}
.topbar__title { font-size: 18px; font-weight: 700; }
.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input { width: 100%; padding: 10px 14px 10px 38px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-mut); width: 18px; height: 18px; }

/* Content area */
.content { padding: 22px 24px 64px; min-height: 0; }

/* ---------- Browse: panel de carpetas + grid ---------- */
.browse { display: grid; grid-template-columns: 256px 1fr; gap: 20px; align-items: start; }
.browse-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.browse-grid { min-width: 0; }

/* Barra con botón colapsable de carpetas */
.browse-bar { display: flex; align-items: center; gap: 12px; }
.folders-toggle { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.folders-toggle .ico { width: 18px; height: 18px; }
.browse-bar__current { color: var(--text-dim); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Estado colapsado: oculta el panel y la rejilla ocupa todo el ancho */
.browse.is-collapsed { grid-template-columns: 1fr; }
.browse.is-collapsed .cat-panel { display: none; }
.cat-panel {
  position: sticky; top: calc(var(--topbar-h) + 22px);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
  max-height: calc(100vh - var(--topbar-h) - 60px);
}
.cat-search { flex: none; }
.cat-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 2px; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 9px 11px; border-radius: 9px; border: none; background: transparent; text-align: left;
  color: var(--text-dim); font-size: 13px; font-weight: 600; transition: background .15s, color .15s;
}
.cat-item:hover { background: var(--bg-elev); color: var(--text); }
.cat-item.is-active { background: var(--grad); color: #fff; }
.cat-item__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .count { flex: none; font-size: 11px; background: rgba(255,255,255,.08); padding: 2px 8px; border-radius: 999px; }
.cat-item.is-active .count { background: rgba(255,255,255,.28); }
/* Fondo del cajón de carpetas (solo móvil) */
.cat-backdrop { display: none; }

/* En móvil: la rejilla ocupa TODO el ancho y las carpetas se abren como un
   cajón ancho superpuesto (legible y con buscador). Al elegir carpeta se cierra. */
@media (max-width: 900px) {
  .browse, .browse.is-collapsed { grid-template-columns: 1fr; }

  .cat-panel {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(330px, 86vw); max-height: none; border-radius: 0;
    border: none; border-right: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .browse:not(.is-collapsed) .cat-panel { transform: translateX(0); }

  .cat-search { display: block; }              /* buscador visible en el cajón */
  .cat-item { font-size: 14px; padding: 12px 12px; }
  .cat-item .count { display: inline; }

  .browse:not(.is-collapsed) .cat-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0, 0, 0, .55); backdrop-filter: blur(1px);
  }
}

/* Category chips bar (legacy) */
.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; margin-bottom: 6px; scrollbar-width: thin; }
.cats::-webkit-scrollbar { height: 6px; }
.chip {
  white-space: nowrap; padding: 8px 14px; border-radius: 999px; background: var(--bg-elev);
  border: 1px solid var(--line); color: var(--text-dim); font-size: 13px; font-weight: 600; transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--grad); border-color: transparent; color: white; }

/* Grid + cards */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.grid--live { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: transform .12s, border-color .15s, box-shadow .15s; position: relative;
}
.card:hover { transform: translateY(-4px); border-color: var(--brand); box-shadow: var(--shadow); }
.card__poster { aspect-ratio: 2/3; background: var(--bg-elev-2) center/cover no-repeat; position: relative; }
.card__poster img { width: 100%; height: 100%; object-fit: cover; }
/* Canales: tarjeta cuadrada y logo COMPLETO (contain), sin recortes. */
.card__poster--live { aspect-ratio: 1/1; display: grid; place-items: center; background: #0a0809; }
.card__poster--live img { width: auto; height: auto; max-width: 84%; max-height: 84%; object-fit: contain; }
.card__fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-mut); font-size: 12px; text-align: center; padding: 10px; }
.card__body { padding: 10px 12px; }
.card__title { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { font-size: 11px; color: var(--text-mut); margin-top: 4px; }
.card__fav {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px;
  background: rgba(0,0,0,.55); border: none; display: grid; place-items: center; color: white; opacity: 0; transition: opacity .15s;
}
.card:hover .card__fav, .card__fav.is-on { opacity: 1; }
.card__fav.is-on { color: var(--warn); }
.card__badge { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.6); font-size: 10px; font-weight: 700; }

/* Section helpers */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 16px; }
.section-head h2 { font-size: 16px; margin: 0; }
.muted { color: var(--text-dim); }
.center-state { display: grid; place-items: center; gap: 14px; padding: 80px 20px; text-align: center; color: var(--text-dim); }
.sentinel { height: 1px; }
.loadmore-row { display: grid; place-items: center; padding: 24px; }

/* ===========================================================================
   PLAYER (modal)
   =========================================================================== */
.player-overlay {
  position: fixed; inset: 0; background: #000;
  z-index: 100; display: flex; flex-direction: column; padding: 12px; gap: 10px;
}
.player-overlay.hidden { display: none; }
.player-bar { display: flex; align-items: center; gap: 14px; }
.player-bar h3 { font-size: 16px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-stage { flex: 1; min-height: 0; display: flex; gap: 16px; }
.player-video-wrap { flex: 1; min-width: 0; background: black; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; position: relative; }
.player-video-wrap video { width: 100%; height: 100%; outline: none; opacity: 0; transition: opacity .25s ease; }
.player-video-wrap.cursor-hidden { cursor: none; }
.player-loading { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }

/* ---------- Controles propios del reproductor ---------- */
.pc {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 28px 16px 14px; display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  opacity: 1; transition: opacity .25s ease;
}
.pc.is-hidden { opacity: 0; pointer-events: none; }
.pc__seekwrap { width: 100%; }
.pc__row { display: flex; align-items: center; gap: 10px; }
.pc__btn {
  background: transparent; border: none; color: #fff; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 9px; transition: background .15s;
}
.pc__btn:hover { background: rgba(255,255,255,.16); }
.pc__btn .ico { width: 22px; height: 22px; }
.pc__time { color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc__spacer { flex: 1; }
.pc__live { color: #fff; font-weight: 700; font-size: 12px; letter-spacing: .5px; display: flex; align-items: center; gap: 7px; }
.pc__live::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 0 rgba(255,93,108,.6); animation: livepulse 1.6s infinite; }
@keyframes livepulse { 70% { box-shadow: 0 0 0 7px rgba(255,93,108,0); } 100% { box-shadow: 0 0 0 0 rgba(255,93,108,0); } }

/* Range inputs (barra de progreso y volumen) */
.rng { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 999px; background: rgba(255,255,255,.22); cursor: pointer; outline: none; }
.rng::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.rng::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #fff; }
.pc__seek { width: 100%; }
.pc__vol { width: 96px; flex: none; }
.player-video-wrap:fullscreen { border-radius: 0; }
@media (max-width: 600px) { .pc__vol { display: none; } }
.player-side {
  width: 320px; flex: none; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  overflow-y: auto; padding: 16px;
}
.player-side h4 { margin: 0 0 12px; font-size: 14px; }
.ep-group { margin-bottom: 16px; }
.ep-group > summary { cursor: pointer; font-weight: 600; padding: 8px 4px; font-size: 14px; }
.ep-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13px;
  color: var(--text-dim); transition: background .15s;
}
.ep-item:hover { background: var(--bg-elev-2); color: var(--text); }
.ep-item.is-active { background: var(--brand); color: white; }
.ep-num { width: 26px; height: 26px; flex: none; border-radius: 6px; background: var(--bg-elev-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.player-meta { color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.player-meta .row { display: flex; gap: 8px; margin-bottom: 6px; }
.player-meta .k { color: var(--text-mut); min-width: 70px; }

/* ===========================================================================
   Misc
   =========================================================================== */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg-elev-2); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 14px; max-width: 340px; animation: toastin .2s ease;
}
.toast--error { border-color: var(--danger); }
.toast--ok { border-color: var(--accent); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

.settings-grid { display: grid; gap: 18px; max-width: 640px; }
.panel { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; }
.acct-row.is-active { border-color: var(--brand); }
.acct-row .grow { flex: 1; }
.acct-row .name { font-weight: 600; }
.acct-row .sub { font-size: 12px; color: var(--text-mut); }

/* Responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row;
    border-right: none; border-top: 1px solid var(--line); padding: 8px; z-index: 50; overflow-x: auto; justify-content: space-around;
  }
  .sidebar__logo, .sidebar__spacer, .sidebar__acct { display: none; }
  .nav-item span { display: none; }
  .nav-item { flex-direction: column; gap: 4px; padding: 6px 12px; }
  .player-side { display: none; }
  .content { padding-bottom: 90px; }
}
