/* ============================================================
   NGPlayer — tv.css
   Interface TV : navigation télécommande, grid Netflix,
   overlay plein écran, focus visible, animations
   ============================================================ */

/* ── RESET TV ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0a0a0f; color: #f0eff8;
  font-family: 'Syne', sans-serif;
  cursor: none; /* pas de curseur sur TV */
  -webkit-font-smoothing: antialiased;
}

/* ── VARIABLES ── */
:root {
  --bg: #0a0a0f; --bg2: #111118; --bg3: #18181f;
  --border: rgba(255,255,255,0.07); --border2: rgba(255,255,255,0.13);
  --accent: #6c63ff; --accent2: #a78bfa;
  --text: #f0eff8; --text2: #8b8a9e; --text3: #4f4e62;
  --danger: #f43f5e; --warn: #f59e0b; --success: #22d3a0;
  --card-w: 180px; --card-h: 100px;
  --row-gap: 28px; --col-gap: 16px;
  --header-h: 72px;
}

/* ── VIDEO BACKGROUND (plein écran permanent) ── */
#tv-video-bg {
  position: fixed; inset: 0; z-index: 0;
  background: #000;
}
#tv-video {
  width: 100%; height: 100%; object-fit: contain;
  display: none;
}
#tv-iframe {
  width: 100%; height: 100%; border: none;
  display: none; background: #000;
}
/* Overlay sombre sur la vidéo quand le menu est ouvert */
#tv-video-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.35s ease;
  pointer-events: none;
}
body.tv-menu-open #tv-video-bg::after {
  background: rgba(0,0,0,0.72);
}

/* ── SPINNER ── */
.tv-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: tv-spin 0.7s linear infinite;
}
@keyframes tv-spin { to { transform: rotate(360deg); } }
@keyframes tv-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes tv-fadein { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
@keyframes tv-slideup { from { opacity:0; transform:translateY(32px); } to { opacity:1; transform:none; } }

/* ── LOADING SCREEN ── */
#tv-loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; background: var(--bg);
  transition: opacity 0.5s ease;
}
#tv-loading.hidden { opacity: 0; pointer-events: none; }
#tv-loading .tv-logo {
  font-size: 32px; font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 12px;
}
#tv-loading .tv-logo-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 32px rgba(108,99,255,0.5);
}
#tv-loading p { font-size: 14px; color: var(--text3); font-family: 'DM Mono', monospace; }

/* ── MAIN UI LAYER ── */
#tv-ui {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
#tv-ui.visible { opacity: 1; pointer-events: auto; }

/* ── TOP BAR (visible en mode menu) ── */
#tv-topbar {
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 60px;
  opacity: 0; transform: translateY(-100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, transparent 100%);
  pointer-events: none;
}
body.tv-menu-open #tv-topbar {
  opacity: 1; transform: none; pointer-events: auto;
}
.tv-logo {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 10px; color: var(--text);
}
.tv-logo-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 16px rgba(108,99,255,0.4);
}
.tv-logo span { color: var(--accent2); font-weight: 400; }
#tv-clock {
  font-size: 28px; font-weight: 700; font-family: 'DM Mono', monospace;
  color: rgba(255,255,255,0.7); letter-spacing: 0.02em;
}
#tv-source-badge {
  font-size: 12px; color: var(--text3); font-family: 'DM Mono', monospace;
  border: 1px solid var(--border2); border-radius: 6px; padding: 4px 10px;
}

/* ── CATEGORY TABS (navigation gauche/droite) ── */
#tv-cats {
  flex-shrink: 0; padding: 0 60px;
  display: flex; gap: 6px; overflow: hidden;
  opacity: 0; transform: translateY(-8px);
  transition: opacity 0.3s ease 0.05s, transform 0.3s ease 0.05s;
  pointer-events: none;
  margin-bottom: 4px;
}
body.tv-menu-open #tv-cats {
  opacity: 1; transform: none; pointer-events: auto;
}
.tv-cat-tab {
  padding: 7px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent;
  color: var(--text3); transition: all 0.15s; cursor: pointer;
  outline: none;
}
.tv-cat-tab.focused {
  color: var(--text); background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  transform: scale(1.05);
}
.tv-cat-tab.selected {
  color: var(--accent2); background: rgba(108,99,255,0.15);
  border-color: rgba(108,99,255,0.35);
}
.tv-cat-tab.selected.focused {
  box-shadow: 0 0 0 2px var(--accent);
}

/* ── CHANNEL GRID ── */
#tv-grid-wrap {
  flex: 1; overflow: hidden;
  padding: 8px 60px 40px;
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.3s ease 0.1s, transform 0.3s ease 0.1s;
  pointer-events: none;
  display: flex; flex-direction: column;
}
body.tv-menu-open #tv-grid-wrap {
  opacity: 1; transform: none; pointer-events: auto;
}
#tv-grid-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text3); font-weight: 600; margin-bottom: 14px;
  font-family: 'DM Mono', monospace;
}
#tv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--card-w));
  gap: var(--col-gap);
  overflow-y: auto; overflow-x: hidden;
  flex: 1;
  padding-right: 8px;
  /* smooth scroll for keyboard nav */
  scroll-behavior: smooth;
}
#tv-grid::-webkit-scrollbar { width: 3px; }
#tv-grid::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── CHANNEL CARD ── */
.tv-card {
  width: var(--card-w); height: var(--card-h);
  border-radius: 10px; overflow: hidden; position: relative;
  background: var(--bg3); border: 2px solid transparent;
  cursor: pointer; outline: none; flex-shrink: 0;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
              border-color 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
}
.tv-card:hover { border-color: var(--border2); }
.tv-card.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.35), 0 8px 32px rgba(0,0,0,0.6);
  transform: scale(1.08);
  z-index: 2;
}
.tv-card.active {
  border-color: var(--success);
  box-shadow: 0 0 0 2px rgba(34,211,160,0.3);
}
.tv-card.focused.active {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(34,211,160,0.45), 0 8px 32px rgba(0,0,0,0.6);
}
.tv-card-logo {
  width: 52px; height: 52px; object-fit: contain; border-radius: 8px;
  background: var(--bg2);
}
.tv-card-logo-placeholder {
  width: 52px; height: 52px; border-radius: 8px;
  background: linear-gradient(135deg, var(--bg2), var(--bg3));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text3);
}
.tv-card-name {
  font-size: 11px; font-weight: 600; text-align: center;
  color: var(--text2); padding: 0 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
  transition: color 0.15s;
}
.tv-card.focused .tv-card-name { color: var(--text); }
.tv-card.active .tv-card-name { color: var(--success); }
/* Playing indicator */
.tv-card-playing {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  animation: tv-pulse 1.5s ease-in-out infinite;
  display: none;
}
.tv-card.active .tv-card-playing { display: block; }

/* ── NOW PLAYING OVERLAY (bas gauche, hors menu) ── */
#tv-now-playing {
  position: fixed; bottom: 48px; left: 60px;
  display: flex; align-items: center; gap: 16px;
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none; z-index: 11;
  max-width: 400px;
}
#tv-now-playing.visible { opacity: 1; transform: none; }
body.tv-menu-open #tv-now-playing { opacity: 0; }
#tv-np-logo {
  width: 56px; height: 56px; border-radius: 12px;
  object-fit: contain; background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0; display: none;
}
#tv-np-logo.visible { display: block; }
#tv-np-info {}
#tv-np-name {
  font-size: 22px; font-weight: 700; line-height: 1.2;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9);
}
#tv-np-meta {
  font-size: 13px; color: rgba(255,255,255,0.55);
  margin-top: 4px; font-family: 'DM Mono', monospace;
}
.tv-live-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); margin-right: 6px;
  animation: tv-pulse 1.2s ease-in-out infinite;
  vertical-align: middle;
}

/* ── CHANNEL INFO POPUP (focus prévisualisation) ── */
#tv-preview {
  position: fixed; bottom: 48px; right: 60px;
  background: rgba(10,10,15,0.9); backdrop-filter: blur(16px);
  border: 1px solid var(--border2); border-radius: 14px;
  padding: 20px 24px; min-width: 260px; max-width: 320px;
  opacity: 0; transform: translateX(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none; z-index: 12;
}
#tv-preview.visible { opacity: 1; transform: none; }
body.tv-menu-open #tv-preview.visible { opacity: 1; }
#tv-preview-logo {
  width: 44px; height: 44px; border-radius: 10px;
  object-fit: contain; background: var(--bg3);
  border: 1px solid var(--border); margin-bottom: 12px;
  display: none;
}
#tv-preview-logo.visible { display: block; }
#tv-preview-name {
  font-size: 17px; font-weight: 700; margin-bottom: 6px; line-height: 1.3;
}
#tv-preview-cats {
  font-size: 11px; color: var(--text3); margin-bottom: 8px;
  font-family: 'DM Mono', monospace;
}
#tv-preview-country { font-size: 18px; }
#tv-preview-hint {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.tv-hint-key {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 5px; padding: 2px 7px; font-size: 10px;
  color: var(--text2);
}

/* ── LOADING VIDEO OVERLAY ── */
#tv-stream-loading {
  position: fixed; inset: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  background: rgba(0,0,0,0.7);
  font-size: 14px; color: var(--text3); font-family: 'DM Mono', monospace;
}
#tv-stream-loading.visible { display: flex; }

/* ── ERROR OVERLAY ── */
#tv-stream-error {
  position: fixed; inset: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  font-size: 15px; color: var(--danger);
}
#tv-stream-error.visible { display: flex; }
#tv-stream-error svg { opacity: 0.5; }

/* ── HINT BAR (télécommande) ── */
#tv-hint-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 13;
  height: 40px; padding: 0 60px;
  display: flex; align-items: center; gap: 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  font-size: 11px; color: rgba(255,255,255,0.35);
  font-family: 'DM Mono', monospace;
  opacity: 0; transition: opacity 0.3s ease;
  pointer-events: none;
}
body.tv-menu-open #tv-hint-bar { opacity: 1; }
.tv-hint-item { display: flex; align-items: center; gap: 6px; }
.tv-hint-item .tv-hint-key {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px; padding: 2px 6px; font-size: 10px;
  color: rgba(255,255,255,0.5);
}

/* ── EMPTY STATE ── */
#tv-empty {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  height: 200px; gap: 12px; color: var(--text3);
  font-size: 14px;
}
#tv-empty.visible { display: flex; }
#tv-empty svg { opacity: 0.1; }

/* ── PLACEHOLDER (aucune chaîne lancée) ── */
#tv-placeholder {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(ellipse at 50% 50%, #0e0e1c 0%, #0a0a0f 70%);
  color: var(--text3); font-size: 14px;
}
#tv-placeholder svg { opacity: 0.08; filter: drop-shadow(0 0 40px var(--accent)); }
#tv-placeholder p { font-size: 14px; letter-spacing: 0.04em; }
#tv-placeholder.hidden { display: none; }
