:root {
  --bg: #0a0d12;
  --bg-2: #0d1119;
  --glass: rgba(255,255,255,0.045);
  --glass-strong: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.09);
  --teal: #45e6c7;
  --teal-dim: rgba(69,230,199,0.35);
  --coral: #ff5c4d;
  --text: #f2f5f7;
  --text-muted: #8792a2;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color-scheme: dark;
  background: radial-gradient(ellipse at 20% -10%, #121826 0%, var(--bg) 45%, #060709 100%);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* ---------- ambient scanline overlay ---------- */
.scanline-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.012) 0px,
    rgba(255,255,255,0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 40px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10,13,18,0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.brand-mark {
  background: linear-gradient(135deg, var(--teal), #1fae95);
  color: #06110e;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  box-shadow: 0 0 24px var(--teal-dim);
}

.brand-name {
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.brand-dot { color: var(--coral); }

.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  flex-shrink: 0;
}
.menu-toggle svg { width: 20px; height: 20px; }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 280px;
  min-width: 0;
}
.search-icon {
  position: absolute;
  right: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 10px 38px 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#search:focus {
  border-color: var(--teal-dim);
  box-shadow: 0 0 0 3px rgba(69,230,199,0.12);
}

/* ---------- custom dropdown (replaces native select) ---------- */
.dropdown {
  position: relative;
  flex-shrink: 0;
}
.dropdown-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  max-width: 150px;
  cursor: pointer;
}
.dropdown-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dropdown-btn .chev {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform .2s;
}
.dropdown.open .dropdown-btn .chev { transform: rotate(180deg); }

.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  max-width: 280px;
  max-height: 340px;
  overflow-y: auto;
  background: #12151d;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 50px -15px rgba(0,0,0,0.6);
  padding: 6px;
  display: none;
  z-index: 60;
}
.dropdown.open .dropdown-panel { display: block; }

.dropdown-item {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-item:hover { background: var(--glass-strong); color: var(--text); }
.dropdown-item.active { background: rgba(69,230,199,0.12); color: var(--teal); }

.channel-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--glass);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- stage ---------- */
.stage {
  padding: 10px 40px 60px;
  max-width: 1400px;
  margin: 0 auto;
}

.controls-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}
.controls-backdrop.show { display: block; }

/* ---------- monitor (main player) ---------- */
.monitor {
  position: relative;
  z-index: 2;
  perspective: 1400px;
  margin-bottom: 42px;
  isolation: isolate;
}

.monitor-bezel {
  background: linear-gradient(160deg, #1a2029, #0c0f14 60%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 14px;
  box-shadow:
    0 30px 80px -30px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.04);
}

.monitor-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a4048;
  transition: background .3s, box-shadow .3s;
}
.rec-dot.live {
  background: var(--coral);
  box-shadow: 0 0 10px 2px rgba(255,92,77,0.6);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.now-label {
  flex: 1;
  color: var(--text);
  font-weight: 500;
}

.ch-tag {
  color: var(--teal);
  border: 1px solid var(--teal-dim);
  padding: 3px 10px;
  border-radius: 6px;
}

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6);
}

#video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.screen-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}

.screen-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  background: #06070a;
  transition: opacity .3s;
}
.screen-placeholder.hidden { opacity: 0; pointer-events: none; }

/* ---------- channel grid ---------- */
.grid-wrap {
  position: relative;
  z-index: 1;
  isolation: isolate;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px;
  perspective: 1000px;
}

.channel-card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .12s ease-out, border-color .2s, background .2s, box-shadow .2s;
  will-change: transform;
}

.channel-card:hover {
  border-color: var(--teal-dim);
  background: var(--glass-strong);
  box-shadow: 0 18px 40px -20px rgba(69,230,199,0.25);
}

.channel-card.active {
  border-color: var(--teal);
  background: linear-gradient(160deg, rgba(69,230,199,0.12), var(--glass-strong));
  box-shadow: 0 0 0 1px var(--teal-dim), 0 20px 45px -20px rgba(69,230,199,0.35);
}

.card-logo-wrap {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: #eef0f3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transform: translateZ(24px);
  flex-shrink: 0;
}
.card-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.card-logo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  background: linear-gradient(135deg, #2a3140, #171b23);
}

.card-name {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
  transform: translateZ(16px);
}

.card-group {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transform: translateZ(8px);
}

.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* روی دستگاه‌های لمسی افکت سه‌بعدی خاموشه تا کارتی روی پلیر گیر نکنه */
@media (hover: none), (pointer: coarse) {
  .channel-card { transform: none !important; }
  .channel-card:active { background: var(--glass-strong); }
}

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .topbar { padding: 14px 20px; }
  .brand-name { display: none; }
  .menu-toggle { display: flex; }

  .controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #10131a;
    border-bottom: 1px solid var(--border);
    padding: 16px 18px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    transform: translateY(-120%);
    transition: transform .25s ease;
    z-index: 55;
  }
  .controls.open { transform: translateY(0); }

  .search-wrap { max-width: none; }
  .dropdown { width: 100%; }
  .dropdown-btn { width: 100%; max-width: none; justify-content: space-between; }
  .dropdown-panel { left: 0; right: 0; width: 100%; max-width: none; }
  .channel-count { text-align: center; }

  .stage { padding: 6px 18px 40px; }
  .monitor-bezel { border-radius: 16px; padding: 10px; }
  .grid-wrap { padding: 14px; border-radius: 16px; }
  .channel-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .card-logo-wrap { width: 44px; height: 44px; }
  .card-name { font-size: 11.5px; }
  .card-group { display: none; }
  .channel-card { padding: 10px 6px 8px; gap: 6px; }
}

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

