/* ============================================================
   StreamVault — style.css
   Palette: void-black / electric-violet / live-red
   ============================================================ */

:root {
  --bg-base:       #0A0A0F;
  --bg-card:       #12121A;
  --bg-surface:    #1A1A28;
  --bg-elevated:   #22223A;
  --accent:        #6C63FF;
  --accent-dim:    rgba(108,99,255,.15);
  --accent-glow:   rgba(108,99,255,.35);
  --live:          #FF4757;
  --live-dim:      rgba(255,71,87,.15);
  --text-primary:  #F0F0F8;
  --text-secondary:#8888AA;
  --text-muted:    #44445A;
  --border:        rgba(255,255,255,.06);
  --border-hover:  rgba(108,99,255,.4);
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --transition:    .2s cubic-bezier(.4,0,.2,1);
  --shadow-card:   0 4px 24px rgba(0,0,0,.45);
  --shadow-glow:   0 0 32px var(--accent-glow);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Toast ─────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: .85rem;
  box-shadow: var(--shadow-card);
  animation: toastIn .3s ease forwards;
  max-width: 320px;
}
.toast.success { border-left: 3px solid #2ED573; }
.toast.error   { border-left: 3px solid var(--live); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid #FFA502; }
.toast i { font-size: 1rem; }
.toast.success i { color: #2ED573; }
.toast.error i   { color: var(--live); }
.toast.info i    { color: var(--accent); }
.toast.warning i { color: #FFA502; }
.toast.fade-out { animation: toastOut .3s ease forwards; }

@keyframes toastIn  { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; transform:none; } to { opacity:0; transform:translateX(40px); } }

/* ── Header ────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,10,15,.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: .85rem; color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}
.logo-text { font-size: 1.2rem; color: var(--text-primary); letter-spacing: -.02em; }
.logo-text strong { color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .9rem;
  display: grid; place-items: center;
  transition: var(--transition);
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

.channel-count-badge {
  padding: 6px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  color: var(--accent);
  letter-spacing: .04em;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Hero Section ──────────────────────────────────────── */
.hero-section {
  background: linear-gradient(180deg, #0E0E1A 0%, var(--bg-base) 100%);
  padding: 24px;
}
.hero-inner {
  max-width: 1400px; margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

/* ── Player Wrapper ─────────────────────────────────────── */
.player-wrapper {
  position: relative;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transition: box-shadow .3s;
}
.player-wrapper.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

#video-player {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
  position: relative; z-index: 1;
}

.player-idle {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: radial-gradient(ellipse at center, #1A1A28 0%, #0A0A0F 100%);
}
.idle-icon { font-size: 3.5rem; color: var(--accent); opacity: .5; }
.idle-title { font-size: 1.1rem; font-weight: 600; color: var(--text-primary); }
.idle-sub { font-size: .85rem; color: var(--text-secondary); }
.player-idle.hidden { display: none; }

.player-overlay {
  position: absolute; inset: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 16px;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 50%);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.player-wrapper:hover .player-overlay { opacity: 1; pointer-events: all; }

.now-playing { display: flex; align-items: center; gap: 8px; }
.live-badge-sm {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  background: var(--live);
  border-radius: 999px;
  font-size: .7rem; font-weight: 700;
  color: #fff; letter-spacing: .06em;
}
.live-badge-sm i { font-size: .5rem; animation: pulse 1.5s infinite; }
.np-name { font-size: .9rem; font-weight: 600; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.8); }

.player-controls { display: flex; gap: 8px; }
.ctrl-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .9rem;
  display: grid; place-items: center;
  transition: var(--transition);
  border: 1px solid rgba(255,255,255,.2);
}
.ctrl-btn:hover { background: var(--accent); border-color: var(--accent); }

.player-loader {
  position: absolute; inset: 0; z-index: 4;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
}
.player-loader.visible { display: flex; }
.loader-ring {
  width: 48px; height: 48px;
  border: 3px solid rgba(108,99,255,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.drm-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(0,0,0,.85);
  color: var(--text-primary);
}
.drm-overlay.visible { display: flex; }
.drm-overlay i { font-size: 2.5rem; color: #FFA502; }
.drm-overlay p { font-size: 1rem; font-weight: 600; }
.drm-overlay span { font-size: .8rem; color: var(--text-secondary); }

@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }

/* ── Now Playing Panel ──────────────────────────────────── */
.now-playing-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 200px;
}
.panel-header { }
.panel-label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: .12em; color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}
.panel-logo-wrap {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.panel-logo { width: 100%; height: 100%; object-fit: contain; padding: 10px; display: none; }
.panel-logo.loaded { display: block; }
.np-placeholder { font-size: 2.5rem; color: var(--text-muted); }
.np-placeholder.hidden { display: none; }

.np-meta { display: flex; flex-direction: column; gap: 4px; }
.np-channel-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.np-group { font-size: .78rem; color: var(--accent); font-weight: 500; }
.np-type {
  font-size: .7rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.np-actions { display: flex; gap: 8px; }
.action-btn {
  flex: 1;
  padding: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: var(--transition);
}
.action-btn:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.action-btn.active { background: var(--live-dim); border-color: var(--live); color: var(--live); }
.action-btn.active i { font-weight: 900; }

/* ── Controls Bar ───────────────────────────────────────── */
.controls-bar {
  background: var(--bg-base);
  position: sticky; top: 64px; z-index: 90;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}
.controls-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}

/* Search */
.search-wrap {
  position: relative;
  display: flex; align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  min-width: 260px;
  transition: border-color var(--transition);
}
.search-wrap:focus-within { border-color: var(--accent); background: var(--bg-elevated); }
.search-icon { color: var(--text-muted); font-size: .85rem; }
.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  padding: 10px 10px;
  color: var(--text-primary);
  font-size: .875rem;
  font-family: inherit;
}
.search-input::placeholder { color: var(--text-muted); }
.clear-search {
  color: var(--text-muted);
  font-size: .8rem;
  padding: 4px;
  border-radius: 4px;
  display: none;
  transition: color var(--transition);
}
.clear-search:hover { color: var(--live); }
.clear-search.visible { display: flex; }

/* Filters */
.filter-wrap {
  display: flex; gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  overflow: hidden;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: .78rem; font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Channel Grid ───────────────────────────────────────── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

/* Channel Card */
.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
  user-select: none;
}
.channel-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--accent-dim) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.channel-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(108,99,255,.2);
}
.channel-card:hover::before { opacity: 1; }
.channel-card.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
.channel-card.active::before { opacity: 1; }

.card-logo-wrap {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}
.card-logo {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 8px;
  opacity: 0;
  transition: opacity .3s;
}
.card-logo.loaded { opacity: 1; }
.card-logo-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: var(--text-muted);
}
.card-logo-fallback.hidden { display: none; }

.card-badges {
  position: absolute; top: 8px; left: 8px;
  display: flex; gap: 4px;
}
.badge {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .62rem; font-weight: 700;
  letter-spacing: .05em;
  font-family: 'JetBrains Mono', monospace;
}
.badge-live {
  background: var(--live);
  color: #fff;
  display: flex; align-items: center; gap: 4px;
}
.badge-live i { font-size: .45rem; animation: pulse 1.5s infinite; }
.badge-hls  { background: rgba(46,213,115,.2);  color: #2ED573; border: 1px solid #2ED573; }
.badge-dash { background: rgba(255,165,2,.2);   color: #FFA502; border: 1px solid #FFA502; }
.badge-drm  { background: rgba(255,71,87,.15);  color: var(--live); border: 1px solid var(--live); }
.badge-fav  { background: var(--live-dim); color: var(--live); border: 1px solid var(--live); }

.card-info { display: flex; flex-direction: column; gap: 3px; }
.card-name  {
  font-size: .875rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.card-group {
  font-size: .72rem;
  color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-fav-btn {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  background: rgba(10,10,15,.7);
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-muted);
  font-size: .75rem;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}
.channel-card:hover .card-fav-btn { opacity: 1; }
.card-fav-btn.active { opacity: 1; color: var(--live); }
.card-fav-btn:hover { color: var(--live); }

/* ── Skeleton ───────────────────────────────────────────── */
.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.sk-img {
  width: 100%; aspect-ratio: 16/9;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  animation: shimmer 1.6s infinite;
}
.sk-line {
  background: var(--bg-surface);
  border-radius: 4px;
  animation: shimmer 1.6s infinite;
}
.sk-l1 { height: 14px; width: 80%; }
.sk-l2 { height: 11px; width: 55%; animation-delay: .1s; }

@keyframes shimmer {
  0%   { opacity: .6; }
  50%  { opacity: 1; }
  100% { opacity: .6; }
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state i { font-size: 3rem; color: var(--text-muted); }
.empty-state p { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-state span { font-size: .85rem; color: var(--text-muted); }

/* ── Footer ─────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Spin for refresh ───────────────────────────────────── */
.spinning { animation: spin .6s linear infinite; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }
  .now-playing-panel {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .panel-logo-wrap {
    width: 120px;
    aspect-ratio: 16/9;
    flex-shrink: 0;
  }
  .np-meta { flex: 1; }
  .np-actions { width: 100%; }
}

@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .logo-text { font-size: 1rem; }
  .channel-count-badge { display: none; }
  .hero-section { padding: 16px; }
  .controls-bar { padding: 12px 16px; }
  .controls-inner { flex-direction: column; align-items: stretch; }
  .search-wrap { min-width: unset; }
  .main-content { padding: 20px 16px 40px; }
  .channel-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .channel-card { padding: 12px; }
}

@media (max-width: 420px) {
  .channel-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Source & Group Filter Rows ─────────────────────────── */
#filter-wrap {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.source-row,
.group-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.source-row::before {
  content: 'SUMBER';
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  margin-right: 2px;
}

.group-row::before {
  content: 'GRUP';
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  margin-right: 2px;
}

/* Source-specific filter button with dynamic accent color */
.filter-btn.source-btn {
  --src-accent: var(--accent);
}
.filter-btn.source-btn:hover {
  border-color: var(--src-accent);
  color: var(--src-accent);
  background: color-mix(in srgb, var(--src-accent) 12%, transparent);
}
.filter-btn.source-btn.active {
  background: var(--src-accent);
  border-color: var(--src-accent);
  color: #fff;
  box-shadow: 0 0 12px color-mix(in srgb, var(--src-accent) 50%, transparent);
}

/* ── Source Badge on Cards ──────────────────────────────── */
.badge-source {
  background: color-mix(in srgb, var(--src-color) 18%, transparent);
  color: var(--src-color);
  border: 1px solid color-mix(in srgb, var(--src-color) 60%, transparent);
  font-size: .58rem;
  padding: 2px 6px;
}
