/* dhanytv web — dark-first IPTV interface */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #0e1013;
  --bg-2: #12151a;
  --surface: #171b21;
  --surface-2: #1f242c;
  --border: #262d38;
  --border-soft: #1d232c;
  --text: #eceef2;
  --text-muted: #8b93a1;
  --accent: #e63946;        /* merah bendera, dipakai hemat */
  --accent-hover: #ff4d5a;
  --accent-soft: rgba(230, 57, 70, .12);
  --ok: #3ecf8e;
  --danger: #ff5a5f;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 32px -8px rgba(0,0,0,.65);
  --radius: 10px;
  --header-h: 58px;
}

html.light {
  --bg: #f4f4f2;
  --bg-2: #ecece9;
  --surface: #ffffff;
  --surface-2: #eeeef0;
  --border: #dddddf;
  --border-soft: #e7e7ea;
  --text: #191b1f;
  --text-muted: #666c76;
  --accent: #d42a37;
  --accent-hover: #b71f2c;
  --accent-soft: rgba(212, 42, 55, .09);
  --ok: #14915c;
  --shadow: 0 1px 3px rgba(20,20,25,.08);
  --shadow-lg: 0 12px 28px -10px rgba(20,20,25,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 420px at 85% -180px, rgba(230,57,70,.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.011em;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent); color: #fff; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(12px, 3vw, 24px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.03em; font-size: 1.08rem; }
.brand .dot { width: 30px; height: 30px; border-radius: 8px; overflow: hidden; flex: none; }
.brand .dot img { width: 100%; height: 100%; object-fit: cover; }
.brand small { display: block; color: var(--text-muted); font-weight: 500; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; margin-top: -2px; }

.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 7px 13px; border-radius: 8px; font-size: .88rem; font-weight: 550;
  color: var(--text-muted); transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 8px 8px 0 0; }

.install-btn {
  flex: none; padding: 0 14px; height: 38px; border-radius: 8px; border: 0;
  background: var(--accent); color: #fff; font-weight: 650; font-size: .84rem;
}
.install-btn:hover { background: var(--accent-hover); }

.search-wrap { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input {
  width: 100%; height: 38px; padding: 0 13px 0 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .9rem; outline: none;
  transition: border-color .15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.icon-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 225px; flex: none; position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 18px 10px; border-right: 1px solid var(--border-soft);
  scrollbar-width: thin;
}
.sidebar h3 { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); margin: 14px 10px 6px; }
.cat-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 7px 11px; border: 0; background: transparent;
  border-radius: 7px; color: var(--text-muted); font-size: .87rem; text-align: left;
  transition: background .1s, color .1s;
}
.cat-btn:hover { background: var(--surface); color: var(--text); }
.cat-btn.active { background: var(--surface-2); color: var(--text); font-weight: 650; box-shadow: inset 2px 0 0 var(--accent); }
.cat-btn .count { font-size: .7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cat-btn.active .count { color: var(--accent); }

.main { flex: 1; min-width: 0; padding: 22px clamp(16px, 3vw, 28px) 60px; }
.page-title { font-size: 1.3rem; font-weight: 750; letter-spacing: -.02em; margin: 2px 0 2px; }
.page-sub { color: var(--text-muted); font-size: .84rem; margin-bottom: 20px; }

/* ---------- Grid & Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: transform .13s ease, border-color .13s, box-shadow .13s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); border-color: #3a4250; box-shadow: var(--shadow-lg); }
.card:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.card .thumb { aspect-ratio: 16/10; background: var(--bg-2); display: grid; place-items: center; padding: 14px; }
.card .thumb img { max-width: 82%; max-height: 60px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.card .thumb .ph { font-weight: 800; font-size: 1.35rem; color: #454e5c; letter-spacing: -.02em; }
.card .meta { padding: 9px 11px 11px; border-top: 1px solid var(--border-soft); }
.card .name { font-weight: 620; font-size: .88rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; mask-image: linear-gradient(90deg,#000 92%,transparent); }
.card .group { font-size: .71rem; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .now { font-size: .73rem; color: var(--text-muted); margin-top: 6px; display: flex; align-items: center; gap: 5px; min-height: 16px; }
.card .now b { color: var(--text); font-weight: 550; }
.progress { height: 2px; background: var(--surface-2); margin-top: 5px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .4s; }

.badges { position: absolute; top: 7px; left: 7px; display: flex; gap: 4px; }
.badge { font-size: .6rem; font-weight: 700; letter-spacing: .05em; padding: 2px 6px; border-radius: 5px; }
.badge.hls { background: rgba(62,207,142,.14); color: var(--ok); }
.badge.drm { background: rgba(255,255,255,.1); color: #cfd6e0; backdrop-filter: blur(4px); }
.badge.live {
  position: absolute; top: 7px; right: 7px; background: var(--accent); color: #fff;
  display: flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 5px;
  font-size: .6rem; font-weight: 800; letter-spacing: .06em;
}
.badge.live i { width: 5px; height: 5px; border-radius: 99px; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ---------- Player view ---------- */
.player-view { max-width: 1280px; margin: 0 auto; }
.player-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 1024px) { .player-grid { grid-template-columns: minmax(0,1fr) 300px; } }
.video-shell { background: #000; border-radius: var(--radius); overflow: hidden; position: relative; aspect-ratio: 16/9; border: 1px solid var(--border-soft); }
.video-shell video { width: 100%; height: 100%; background: #000; }
.video-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: #e7eaf0; background: radial-gradient(circle at center, rgba(15,17,21,.35), rgba(0,0,0,.88)); padding: 24px;
}
.video-overlay.hidden { display: none; }
.spinner { width: 40px; height: 40px; border: 3px solid rgba(255,255,255,.18); border-top-color: var(--accent); border-radius: 99px; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-info h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; margin: 4px 0; }
.player-info .epg-now { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .9rem; }
.player-info .epg-now b { color: var(--text); font-weight: 600; }
.related { display: flex; flex-direction: column; gap: 4px; }
.related h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.rel-item { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; transition: background .1s; border: 0; background: transparent; color: var(--text); width: 100%; text-align: left; }
.rel-item:hover { background: var(--surface); }
.rel-item.active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.rel-item img, .rel-item .ph { width: 46px; height: 31px; object-fit: contain; border-radius: 6px; flex: none; background: var(--bg-2); display: grid; place-items: center; font-weight: 750; font-size: .78rem; color: var(--text-muted); }
.rel-item .rn { font-size: .85rem; font-weight: 550; line-height: 1.2; }

.back-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .88rem; margin-bottom: 12px; background: transparent; border: 0; }
.back-btn:hover { color: var(--text); }
.fav-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: .86rem; margin-top: 14px; }
.fav-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Chips (mobile categories) ---------- */
.chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 6px; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { height: 0; }
.chip { white-space: nowrap; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .81rem; color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ---------- States ---------- */
.empty, .loading-screen { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.loading-screen .spinner { margin: 0 auto 16px; }
.skeleton .thumb { background: linear-gradient(90deg,var(--surface) 25%,var(--surface-2) 50%,var(--surface) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
.skeleton .meta { opacity: .4; }
@keyframes sk { to { background-position: -200% 0; } }

.alert { padding: 12px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); font-size: .85rem; margin-bottom: 16px; }
.alert.error-banner { border-left-color: var(--danger); }

/* ---------- Home rows ---------- */
.hrow { margin-bottom: 28px; }
.row-title { font-size: 1.04rem; font-weight: 750; letter-spacing: -.015em; margin: 0 0 13px; display: flex; align-items: center; gap: 9px; padding-left: clamp(16px,3vw,28px); margin-left: calc(-1 * clamp(16px,3vw,28px)); }
.row-title::before { content: ""; width: 3px; height: 16px; background: var(--accent); border-radius: 2px; }
.row-scroll { display: flex; gap: 11px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.row-scroll::-webkit-scrollbar { height: 5px; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.mini { flex: none; width: 130px; background: transparent; border: 0; padding: 0; text-align: left; scroll-snap-align: start; cursor: pointer; }
.mini-thumb { position: relative; aspect-ratio: 16/10; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 9px; display: grid; place-items: center; padding: 12px; transition: transform .13s, border-color .13s; }
.mini:hover .mini-thumb { transform: translateY(-2px); border-color: #3a4250; }
.mini:focus-visible .mini-thumb { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.mini-thumb img { max-width: 82%; max-height: 50px; object-fit: contain; }
.mini-thumb .ph { font-weight: 800; color: #454e5c; }
.live-dot { position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 99px; background: var(--accent); animation: pulse 1.6s infinite; }
.mini-name { display: block; font-size: .81rem; font-weight: 600; margin-top: 7px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-now { display: block; font-size: .71rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Guide ---------- */
.guide-view { max-width: 900px; margin: 0 auto; }
.guide-list { display: flex; flex-direction: column; gap: 6px; }
.guide-row { display: flex; align-items: center; gap: 14px; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; text-align: left; cursor: pointer; transition: border-color .12s; }
.guide-row:hover { border-color: var(--accent); }
.guide-row:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.guide-logo { width: 54px; height: 37px; flex: none; display: grid; place-items: center; background: var(--bg-2); border-radius: 7px; overflow: hidden; }
.guide-logo img { max-width: 88%; max-height: 30px; object-fit: contain; }
.guide-logo .ph { font-weight: 750; color: var(--text-muted); font-size: .83rem; }
.guide-info { flex: 1; min-width: 0; }
.guide-name { display: block; font-weight: 600; font-size: .93rem; }
.guide-prog { display: block; font-size: .81rem; color: var(--text-muted); margin-top: 2px; }
.guide-prog b { color: var(--text); font-weight: 600; }
.guide-prog .gt { font-variant-numeric: tabular-nums; }
.guide-prog .gnext { display: block; opacity: .8; margin-top: 1px; }
.guide-play { flex: none; color: var(--accent); font-size: 1rem; }

/* ---------- Player controls bar ---------- */
.pi-head { display: flex; align-items: center; gap: 10px; }
.player-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.8)); opacity: 0; transition: opacity .2s; }
.video-shell:hover .player-bar, .video-shell:focus-within .player-bar, .video-shell.show .player-bar { opacity: 1; }
.pb-btn { background: rgba(255,255,255,.13); border: 0; color: #fff; width: 35px; height: 35px; border-radius: 7px; font-size: .95rem; backdrop-filter: blur(4px); }
.pb-btn:hover { background: rgba(255,255,255,.26); }
.pb-vol { width: 88px; accent-color: var(--accent); }
.pb-spacer { flex: 1; }
.pb-quality select { background: rgba(255,255,255,.13); color: #fff; border: 0; border-radius: 7px; padding: 7px 8px; font-size: .81rem; }
.pb-quality select option { color: #111; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(5,7,10,.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; }
.modal-backdrop[hidden] { display: none; }
.modal { width: 100%; max-width: 450px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 22px; }
.modal h2 { margin: 0 0 14px; font-size: 1.1rem; font-weight: 700; }
.modal label { font-size: .84rem; font-weight: 600; }
.modal-help { font-size: .77rem; color: var(--text-muted); line-height: 1.55; margin: 0 0 16px; }
.modal-help code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.modal-actions { display: flex; align-items: center; gap: 8px; }

footer.app-footer { border-top: 1px solid var(--border-soft); padding: 22px 20px; color: var(--text-muted); font-size: .79rem; text-align: center; }
footer.app-footer a { color: var(--accent); }

/* ---------- Responsive ---------- */
.mobile-only { display: none; }
@media (max-width: 980px) { .nav { display: none; } }
@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-only { display: flex; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 9px; }
  .search-wrap { max-width: none; }
  .brand small { display: none; }
  .install-btn { display: none; }
}
@media (min-width: 1800px) { .grid { grid-template-columns: repeat(auto-fill, minmax(198px,1fr)); } }
