/* ────────────────────────────────────────────────────────────────
   IPTV Downloader — design system
   ──────────────────────────────────────────────────────────────── */

:root {
  --bg: #0a0c11;
  --surface: #11141c;
  --surface-2: #171b25;
  --surface-3: #1d2230;
  --border: rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #e9ebf2;
  --text-dim: #98a1b3;
  --accent: #7c5cff;
  --accent-2: #38bdf8;
  --accent-soft: rgba(124, 92, 255, .16);
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #38bdf8 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .45);
  --nav-h: 62px;
}

[data-bs-theme="dark"] {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-secondary-color: var(--text-dim);
  --bs-border-color: var(--border);
  --bs-primary: var(--accent);
  --bs-primary-rgb: 124, 92, 255;
  --bs-link-color: #a78bfa;
  --bs-link-hover-color: #c4b5fd;
  --bs-emphasis-color: #fff;
}

html, body { height: 100%; }

body {
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(124, 92, 255, .16), transparent 62%),
    radial-gradient(900px 480px at 92% -4%, rgba(56, 189, 248, .10), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

::selection { background: rgba(124, 92, 255, .35); }

.ico { width: 1.12em; height: 1.12em; flex: 0 0 auto; }

/* ── scrollbars ───────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .28); background-clip: content-box; }

/* ── navbar ───────────────────────────────────────────────────── */
.app-nav {
  position: sticky; top: 0; z-index: 1030;
  height: var(--nav-h);
  background: rgba(10, 12, 17, .72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.app-nav .nav-inner { height: 100%; display: flex; align-items: center; gap: .75rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); font-weight: 700; letter-spacing: -.02em; }
.brand:hover { color: #fff; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent-grad); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(124, 92, 255, .38);
}
.brand-mark .ico { width: 18px; height: 18px; }

.nav-pills-row { display: flex; align-items: center; gap: .25rem; margin-left: .5rem; overflow-x: auto; }
.nav-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .45rem .8rem; border-radius: 10px;
  color: var(--text-dim); text-decoration: none;
  font-size: .9rem; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-pill:hover { color: var(--text); background: rgba(255, 255, 255, .055); }
.nav-pill.active {
  color: #fff; background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .38);
}

.user-chip { display: flex; align-items: center; gap: .55rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; color: #cdd3e1;
  text-transform: uppercase;
}
.btn-ghost {
  border: 1px solid var(--border); background: transparent; color: var(--text-dim);
  border-radius: 10px; padding: .35rem .6rem; display: inline-flex; align-items: center; gap: .35rem;
  font-size: .85rem; transition: all .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, .05); }
.btn-ghost.active { color: #fff; border-color: rgba(124, 92, 255, .5); background: var(--accent-soft); }
.btn-ghost.disabled { opacity: .4; pointer-events: none; }
a.btn-soft { text-decoration: none; }

/* ── layout ───────────────────────────────────────────────────── */
.page { padding: 1.5rem 0 3rem; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--text-dim); font-size: .85rem; }

/* ── toolbar (search / filters) ───────────────────────────────── */
.toolbar {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: center;
  padding: .6rem; margin-bottom: 1.25rem;
  background: rgba(17, 20, 28, .68);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.search-wrap { position: relative; flex: 1 1 240px; max-width: 420px; }
.search-wrap .ico { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-dim); width: 16px; height: 16px; }
.search-input {
  width: 100%; padding: .5rem .8rem .5rem 2.2rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: .9rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { border-color: rgba(124, 92, 255, .55); box-shadow: 0 0 0 3px rgba(124, 92, 255, .16); }
.select-input {
  padding: .5rem .8rem; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; font-size: .88rem; outline: none;
  max-width: 260px;
}
.select-input:focus { border-color: rgba(124, 92, 255, .55); }
.toolbar .count { margin-left: auto; color: var(--text-dim); font-size: .82rem; }

/* ── media cards ──────────────────────────────────────────────── */
.media-card {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
  text-decoration: none; color: inherit;
}
.media-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); color: inherit; }
.media-card .thumb { position: relative; overflow: hidden; background: var(--surface-2); }
.poster { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; transition: transform .35s ease; }
.media-card:hover .poster { transform: scale(1.03); }
.channel-logo { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: contain; padding: 1rem; }
.thumb-fallback { aspect-ratio: 2 / 3; display: grid; place-items: center; color: var(--text-dim); background: var(--surface-2); }
.thumb-fallback .ico { width: 28px; height: 28px; }
.badge-live {
  position: absolute; top: .5rem; left: .5rem;
  background: rgba(220, 38, 38, .9); color: #fff;
  font-size: .64rem; font-weight: 700; letter-spacing: .06em;
  padding: .18rem .45rem; border-radius: 6px; backdrop-filter: blur(4px);
}
.media-body { display: flex; flex-direction: column; gap: .3rem; padding: .7rem .75rem .75rem; flex: 1; }
.media-title { font-size: .86rem; font-weight: 600; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-meta { display: flex; align-items: center; gap: .4rem; color: var(--text-dim); font-size: .76rem; }
.chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .1rem .45rem; border-radius: 999px; font-size: .7rem; font-weight: 600;
  background: rgba(255, 255, 255, .07); color: #c9cfdd;
}
.chip.gold { background: rgba(251, 191, 36, .14); color: #fcd34d; }
.chip.accent { background: var(--accent-soft); color: #b7a5ff; }
.media-actions { margin-top: auto; padding-top: .45rem; }

/* ── buttons ──────────────────────────────────────────────────── */
.btn-accent {
  background: var(--accent-grad); border: 0; color: #fff; font-weight: 600;
  border-radius: 10px; padding: .48rem .9rem; font-size: .86rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: filter .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .28);
}
.btn-accent:hover { filter: brightness(1.07); color: #fff; transform: translateY(-1px); }
.btn-accent:active { transform: translateY(0); }
.btn-accent:disabled { opacity: .5; box-shadow: none; }
.btn-soft {
  background: rgba(255, 255, 255, .07); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: .45rem .85rem; font-size: .85rem;
  display: inline-flex; align-items: center; gap: .4rem;
}
.btn-soft:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.btn-icon {
  width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center;
  border-radius: 9px; border: 1px solid var(--border); background: transparent;
  color: var(--text-dim); transition: all .15s;
}
.btn-icon:hover { color: #fff; border-color: var(--border-strong); background: rgba(255, 255, 255, .06); }

/* ── alerts / banners ─────────────────────────────────────────── */
.banner {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .7rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-size: .86rem; color: var(--text-dim); margin-bottom: 1rem;
}
.banner.warn { border-color: rgba(251, 191, 36, .3); background: rgba(251, 191, 36, .07); color: #fde68a; }
.banner.bad { border-color: rgba(248, 113, 113, .32); background: rgba(248, 113, 113, .08); color: #fecaca; }
.banner .ico { margin-top: .1rem; }

/* ── pagination ───────────────────────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: 1.6rem; }
.pager .btn-ghost { padding: .42rem .7rem; }

/* ── empty state ──────────────────────────────────────────────── */
.empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: 4rem 1rem; color: var(--text-dim); text-align: center;
}
.empty .ico { width: 34px; height: 34px; opacity: .6; }

/* ── series detail ────────────────────────────────────────────── */
.series-hero {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 1.5rem;
}
.series-hero .glow {
  position: absolute; inset: -40% -10% auto -10%; height: 320px;
  background-size: cover; background-position: center;
  filter: blur(60px) saturate(150%); opacity: .35; pointer-events: none;
}
.series-hero .hero-inner { position: relative; display: flex; gap: 1.5rem; padding: 1.5rem; flex-wrap: wrap; }
.series-hero .poster-lg { width: 168px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow); }
.series-hero .hero-text { flex: 1 1 320px; min-width: 260px; }
.series-hero h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .35rem; }
.plot { color: #c3c9d6; font-size: .9rem; line-height: 1.55; max-width: 78ch; }

.season { margin-bottom: 1.4rem; }
.season-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .55rem; }
.season-head h2 { font-size: 1rem; font-weight: 650; margin: 0; }
.ep-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.ep-row { display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-top: 1px solid var(--border); transition: background .12s; }
.ep-row:first-child { border-top: 0; }
.ep-row:hover { background: rgba(255, 255, 255, .035); }
.ep-num {
  flex: 0 0 auto; min-width: 62px; text-align: center;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  color: #b7a5ff; background: var(--accent-soft);
  border-radius: 7px; padding: .22rem .4rem;
}
.ep-text { flex: 1; min-width: 0; }
.ep-title { font-size: .88rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-desc { font-size: .76rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── queue ────────────────────────────────────────────────────── */
.queue-list { display: flex; flex-direction: column; gap: .7rem; }
.q-card {
  display: flex; gap: .9rem; align-items: center;
  padding: .85rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.q-main { flex: 1; min-width: 0; }
.q-title { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-sub { font-size: .76rem; color: var(--text-dim); margin-top: .15rem; }
.q-bar { height: 6px; background: rgba(255, 255, 255, .08); border-radius: 999px; overflow: hidden; margin-top: .45rem; }
.q-bar > div { height: 100%; background: var(--accent-grad); border-radius: 999px; transition: width .5s ease; }
.q-bar.indet > div { width: 35% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.status {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 999px; flex: 0 0 auto;
}
.status.queued { background: rgba(148, 163, 184, .16); color: #cbd5e1; }
.status.downloading { background: rgba(56, 189, 248, .16); color: #7dd3fc; }
.status.done { background: rgba(52, 211, 153, .15); color: #6ee7b7; }
.status.error { background: rgba(248, 113, 113, .16); color: #fca5a5; }
.status.canceled { background: rgba(251, 191, 36, .15); color: #fcd34d; }
.q-actions { display: flex; gap: .4rem; flex: 0 0 auto; }
.q-note { color: #fcd34d; font-size: .74rem; margin-top: .2rem; }

.url-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .76rem; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: .55rem .7rem; color: #c9d1e3;
}
code {
  background: rgba(255, 255, 255, .06); color: #c4b5fd;
  padding: .1rem .35rem; border-radius: 5px; font-size: .85em;
}

/* ── admin ────────────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; height: 100%; }
.panel-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .8rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .9rem; background: rgba(255, 255, 255, .02);
}
.panel-head .ico { color: #a78bfa; }
.panel-body { padding: 1rem; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .32rem 0; font-size: .83rem; border-bottom: 1px dashed rgba(255, 255, 255, .05); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-dim); }
.kv .v { text-align: right; }

/* ── player ───────────────────────────────────────────────────── */
.player-shell { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--border); }
.player-shell video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.player-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 1rem; background: rgba(3, 5, 10, .78); backdrop-filter: blur(3px); color: #fff;
}
.player-overlay .spinner-border { width: 2.2rem; height: 2.2rem; border-width: .2rem; }
.player-overlay .msg { font-size: .88rem; color: #d7dbe6; max-width: 34ch; }
.epg-bar { display: flex; flex-direction: column; gap: .3rem; margin-top: .65rem; font-size: .82rem; }
.epg-line { display: flex; align-items: baseline; gap: .5rem; color: #cbd2e0; }
.epg-line .label { color: var(--text-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; min-width: 46px; }
.channel-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); max-height: 68vh; overflow-y: auto; }
.channel-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .55rem .75rem; border-top: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: .84rem;
  transition: background .12s;
}
.channel-item:first-child { border-top: 0; }
.channel-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.channel-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.channel-item .ico { color: var(--text-dim); }

/* ── now watching ─────────────────────────────────────────────── */
.now-strip { display: flex; gap: .7rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.now-card {
  display: flex; align-items: center; gap: .7rem; min-width: 0;
  flex: 1 1 300px; max-width: 420px;
  padding: .6rem .7rem; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(124, 92, 255, .16), rgba(56, 189, 248, .08));
  border: 1px solid rgba(124, 92, 255, .32);
  text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s;
}
.now-card:hover { color: #fff; border-color: rgba(124, 92, 255, .6); transform: translateY(-1px); }
.now-thumb {
  width: 40px; height: 40px; border-radius: 9px; object-fit: contain;
  background: rgba(255, 255, 255, .06); padding: .25rem; flex: 0 0 auto;
}
.now-thumb.ph { display: grid; place-items: center; font-size: 1rem; }
.now-text { min-width: 0; flex: 1; }
.now-title { font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-sub { font-size: .74rem; color: #c4b5fd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-card .btn-accent { padding: .3rem .7rem; font-size: .78rem; flex: 0 0 auto; }
.badge-watch {
  position: absolute; top: .5rem; right: .5rem;
  background: rgba(52, 211, 153, .92); color: #052e1b;
  font-size: .62rem; font-weight: 700; letter-spacing: .03em;
  padding: .16rem .42rem; border-radius: 6px;
}
.watch-line { font-size: .8rem; color: #c4b5fd; }
.watch-line .ico { color: #a78bfa; }

/* ── login ────────────────────────────────────────────────────── */
.login-wrap { min-height: calc(100vh - 3rem); display: grid; place-items: center; padding: 2rem 1rem; }
.login-card {
  width: 100%; max-width: 400px;
  background: rgba(17, 20, 28, .82); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem 1.75rem;
  backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
.login-card .brand { justify-content: center; margin-bottom: .35rem; }
.login-card .brand span { font-size: 1.1rem; }
.login-sub { text-align: center; color: var(--text-dim); font-size: .82rem; margin-bottom: 1.5rem; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .76rem; color: var(--text-dim); margin-bottom: .35rem; font-weight: 500; }
.field input {
  width: 100%; padding: .6rem .8rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: .9rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: rgba(124, 92, 255, .6); box-shadow: 0 0 0 3px rgba(124, 92, 255, .16); }
.login-foot { text-align: center; color: var(--text-dim); font-size: .74rem; margin-top: 1.1rem; }

/* ── toasts ───────────────────────────────────────────────────── */
.alert { border-radius: var(--radius-sm); border-width: 1px; font-size: .86rem; }
.toast-host { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; }

/* ── admin: live channel group filters ────────────────────────── */
.group-tools {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-bottom: .75rem;
}
.group-tools .search-wrap { flex: 1 1 240px; }
.group-list {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); max-height: 420px; overflow-y: auto;
}
.group-row {
  display: flex; align-items: center; gap: .6rem; cursor: pointer;
  padding: .38rem .75rem; border-bottom: 1px solid var(--border);
  font-size: .84rem; transition: background .12s;
}
.group-row:last-child { border-bottom: 0; }
.group-row:hover { background: rgba(255, 255, 255, .04); }
.group-row .form-check-input { margin: 0; flex: 0 0 auto; cursor: pointer; }
.group-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count {
  flex: 0 0 auto; color: var(--text-dim); font-size: .74rem;
  font-variant-numeric: tabular-nums;
}

/* ── connect: stream keys ──────────────────────────────────────── */
.key-list {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
}
.key-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .75rem; border-bottom: 1px solid var(--border);
}
.key-row:last-child { border-bottom: 0; }
.key-main { flex: 1 1 auto; min-width: 0; }
.key-label {
  display: flex; align-items: center; gap: .45rem;
  font-size: .88rem; font-weight: 600;
}
.key-row .btn-ghost { padding: .32rem .6rem; font-size: .76rem; }

/* ── responsive ───────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .nav-pills-row { position: fixed; bottom: 0; left: 0; right: 0; margin: 0; z-index: 1040;
    background: rgba(10, 12, 17, .92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: .45rem .6rem calc(.45rem + env(safe-area-inset-bottom));
    justify-content: space-around; }
  .nav-pill { flex-direction: column; gap: .18rem; font-size: .68rem; padding: .3rem .6rem; }
  .nav-pill .ico { width: 18px; height: 18px; }
  .page { padding-bottom: 5.5rem; }
  .series-hero .poster-lg { width: 120px; }
  .toolbar { padding: .5rem; }
  .toolbar .count { margin-left: 0; width: 100%; }
  .q-card { flex-wrap: wrap; }
  .q-actions { width: 100%; justify-content: flex-end; }
}
