/* ─── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  --bg          : #090912;
  --surface     : #0f0f1e;
  --card        : #141428;
  --card-hover  : #1a1a35;
  --border      : rgba(255,255,255,.08);
  --accent      : #f44336;
  --accent-glow : rgba(244,67,54,.35);
  --live        : #00e676;
  --offline     : #9e9e9e;
  --text-hi     : #ffffff;
  --text-md     : #c8c8e0;
  --text-lo     : #6a6a88;
  --chip-bg     : #1e1e38;
  --chip-active : var(--accent);
  --radius-sm   : 8px;
  --radius-md   : 12px;
  --radius-lg   : 18px;
  --header-h    : 64px;
  --transition  : .18s ease;
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { scroll-behavior:smooth; }
body {
  font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-md);
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor:pointer; border:none; background:none; font:inherit; }
input  { font:inherit; border:none; outline:none; }
a      { color:inherit; text-decoration:none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar             { width:6px; height:6px; }
::-webkit-scrollbar-track       { background:var(--surface); }
::-webkit-scrollbar-thumb       { background:var(--chip-bg); border-radius:4px; }
::-webkit-scrollbar-thumb:hover { background:var(--accent); }

/* ─── Header ────────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(9,9,18,.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text-hi);
  white-space: nowrap;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border);
}
.tab-btn {
  padding: 7px 18px;
  border-radius: 9px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-lo);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.tab-btn.active,
.tab-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Clock ───────────────────────────────────────────────────────────────── */
.header-right { margin-left: auto; }
.live-clock {
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-lo);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
}

/* ─── Main ──────────────────────────────────────────────────────────────────── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ─── Tab panels ────────────────────────────────────────────────────────────── */
.tab-panel         { display: none; }
.tab-panel.active  { display: block; }

/* ─── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.filter-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}

.search-wrap input {
  background: var(--chip-bg);
  color: var(--text-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  width: 220px;
  font-size: .875rem;
  transition: border-color var(--transition);
}
.search-wrap input:focus {
  border-color: var(--accent);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 5px 13px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--text-lo);
  border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover,
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.active-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  color: var(--text-lo);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.active-toggle input { width:15px; height:15px; accent-color: var(--accent); }

.channel-count {
  font-size: .8rem;
  color: var(--text-lo);
  white-space: nowrap;
}

/* ─── Channel grid ──────────────────────────────────────────────────────────── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.ch-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.ch-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
  border-color: rgba(255,255,255,.16);
}
.ch-card:hover .card-watch-btn {
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

/* ── Card band (colored header) ──────────────────────────────────────────── */
.card-band {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--chip-bg);
}
.card-band--logo {
  background: #0a0a18;
  padding: 8px;
}
.card-logo-img {
  max-height: 60px;
  max-width: 90%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.6));
}
.card-initials {
  font-size: 1.5rem;
  font-weight: 900;
  color: rgba(255,255,255,.85);
  letter-spacing: -1px;
  text-shadow: 0 2px 8px rgba(0,0,0,.5);
  text-transform: uppercase;
  pointer-events: none;
}
.card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: .5px;
}
.badge-live    { background: var(--live);    color: #000; }
.badge-offline { background: #2a2a3a;        color: var(--offline); }
.badge-unknown { background: #2a2a3a;        color: var(--offline); }

/* ── Card body ────────────────────────────────────────────────────────────── */
.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.card-name {
  font-size: .925rem;
  font-weight: 700;
  color: var(--text-hi);
  line-height: 1.3;
}
.card-meta {
  font-size: .78rem;
  color: var(--text-lo);
}
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.card-watch-btn {
  flex: 1;
  background: var(--chip-bg);
  color: var(--text-hi);
  border-radius: var(--radius-sm);
  padding: 9px;
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
  transition: background var(--transition), box-shadow var(--transition);
}
.ch-card.offline .card-watch-btn {
  opacity: .4;
  pointer-events: none;
}
.card-embed-btn {
  background: var(--chip-bg);
  color: var(--text-lo);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: -.5px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.card-embed-btn:hover { background: var(--accent); color: #fff; border-color: transparent; }

/* ─── Loader & empty states ─────────────────────────────────────────────────── */
.loader {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 0;
  color: var(--text-lo);
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-grid {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-lo);
}
.empty-grid p { margin-top: 8px; font-size: .9rem; }

.empty-state {
  text-align: center;
  padding: 100px 20px;
  color: var(--text-lo);
}
.empty-icon { font-size: 4rem; margin-bottom: 20px; }
.empty-state h2 { color: var(--text-hi); font-size: 1.5rem; margin-bottom: 10px; }
.empty-state p  { font-size: 1rem; }

/* ─── Toast notification ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(0,0,0,.88);
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: .85rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Modal styles removed (modal replaced by embed player in new tab) ───── */
/* (dead code kept below for reference; safe to delete) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: 95vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity:0; } to { transform:none; opacity:1; } }

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--text-hi);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--accent); }

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 52px 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-hi);
}

/* ── Video ────────────────────────────────────────────────────────────────── */
.video-wrap {
  background: #000;
  position: relative;
  aspect-ratio: 16/9;
}
.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
}
.video-error {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-lo);
}
.video-error[hidden] { display: none; }
.video-error button {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-weight: 600;
  transition: opacity var(--transition);
}
.video-error button:hover { opacity: .8; }

/* ── Modal logo ──────────────────────────────────────────────────────────── */
.modal-ch-logo {
  width: 40px;
  height: 40px;
  background: #0a0a18;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.modal-ch-logo[hidden] { display: none; }
.modal-ch-logo img {
  max-width: 36px;
  max-height: 36px;
  object-fit: contain;
}

/* ── Modal footer & embed ─────────────────────────────────────────────────── */
.modal-footer {
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border);
}
.embed-toggle-btn {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-lo);
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  transition: color var(--transition), border-color var(--transition);
}
.embed-toggle-btn:hover {
  color: var(--text-hi);
  border-color: rgba(255,255,255,.2);
}
.embed-panel {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.embed-panel[hidden] { display: none; }
.embed-panel label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-lo);
}
.embed-code-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.embed-code-row textarea {
  flex: 1;
  background: var(--chip-bg);
  color: var(--text-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .78rem;
  font-family: 'Courier New', monospace;
  resize: none;
  line-height: 1.5;
}
.embed-code-row button {
  background: var(--chip-bg);
  border: 1px solid var(--border);
  color: var(--text-hi);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .9rem;
  transition: background var(--transition);
  align-self: stretch;
}
.embed-code-row button:hover { background: var(--accent); }
.embed-note {
  font-size: .75rem;
  color: var(--text-lo);
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { gap: 12px; padding: 0 12px; }
  .logo         { font-size: 1.1rem; }
  .tab-btn      { padding: 6px 12px; font-size: .8rem; }
  .live-clock   { display: none; }
  .channel-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .main         { padding: 16px 12px 50px; }
  .search-wrap input { width: 100%; }
}
