/* Lecteur IPTV — ServicesHub.ca : page unique sombre, palette du hub */
:root {
  --nuit: #070d24; --nuit-2: #0d1838; --nuit-3: #14225a; --nuit-4: #1b2c6e;
  --bleu: #2f6bff; --ciel: #38bdf8; --lis: #f6c744; --menthe: #34d399; --rouge: #f87171;
  --texte: #dbe4ff; --doux: #93a3d1; --ligne: rgba(255,255,255,.12); --verre: rgba(255,255,255,.06);
  --rayon: 10px; --ligne-h: 56px; --entete-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--nuit); color: var(--texte);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
a { color: var(--ciel); }
button, input, select { font: inherit; color: inherit; }
button { background: var(--verre); border: 1px solid var(--ligne); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--ciel); }
button:disabled { opacity: .5; cursor: default; }
button.principal { background: var(--bleu); border-color: var(--bleu); color: #fff; font-weight: 600; }
button.principal:hover { filter: brightness(1.12); }
button.danger { color: #ffb4b4; }
button.danger:hover { border-color: var(--rouge); }
button.icone { padding: 6px 10px; }
input[type=text], input[type=url], input[type=search], input[type=password], input:not([type]) {
  width: 100%; background: rgba(0,0,0,.35); border: 1px solid var(--ligne); border-radius: 8px; padding: 8px 10px; color: #fff; }
input:focus { outline: none; border-color: var(--ciel); }
input::placeholder { color: #5f6f9d; }
kbd { background: var(--nuit-3); border: 1px solid var(--ligne); border-radius: 4px; padding: 0 5px; font-size: 11px; }
code { background: rgba(0,0,0,.35); border-radius: 4px; padding: 1px 4px; font-size: 12px; word-break: break-all; }
[hidden] { display: none !important; }
.indice { color: var(--doux); font-size: 12px; margin: 0; }
.info { font-size: 12px; color: var(--doux); min-height: 1em; }
.info.erreur { color: #ffb4b4; }
.info.ok { color: var(--menthe); }
.ligne { display: flex; gap: 6px; flex-wrap: wrap; }
.ligne > .principal { flex: 1; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--doux); font-size: 12px; }

/* ---------- en-tête ---------- */
#entete { height: var(--entete-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: var(--nuit-2); border-bottom: 1px solid var(--ligne); }
.marque { font-size: 17px; white-space: nowrap; }
.marque b { color: var(--ciel); }
#onglets { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
#onglets::-webkit-scrollbar { display: none; }
#onglets button { background: none; border: 1px solid transparent; color: var(--doux); border-radius: 8px; padding: 7px 10px; }
#onglets button:hover { color: #fff; background: var(--verre); }
#onglets button.actif { background: var(--nuit-3); color: #fff; border-color: var(--ligne); }
.recherche { flex: 1; min-width: 120px; max-width: 420px; margin-left: auto; }

/* ---------- disposition ---------- */
#app { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px 360px 1fr; }
#cote, #chaines { background: var(--nuit-2); border-right: 1px solid var(--ligne); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panneau { padding: 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--ligne); }
.panneau h2 { margin: 0; font-size: 15px; color: #fff; }
.defilant { overflow-y: auto; flex: 1; min-height: 0; }
.depot { border: 1px dashed var(--ligne); border-radius: var(--rayon); padding: 10px; text-align: center; color: var(--doux); font-size: 12px; }
.depot.survol { border-color: var(--ciel); color: #fff; background: rgba(56,189,248,.08); }
.sousonglets { display: flex; gap: 4px; flex-wrap: wrap; }
.sousonglets button { padding: 5px 9px; font-size: 12px; color: var(--doux); }
.sousonglets button.actif { background: var(--nuit-3); color: #fff; }

/* groupes et listes publiques */
#groupes { padding: 6px; }
.grp, .pub { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 7px;
  cursor: pointer; color: var(--doux); white-space: nowrap; }
.grp span:first-child, .pub span:first-child { overflow: hidden; text-overflow: ellipsis; }
.grp:hover, .pub:hover { background: var(--verre); color: #fff; }
.grp.actif, .pub.actif { background: var(--bleu); color: #fff; }
.grp small, .pub small { opacity: .7; }
#pubListes { max-height: 42vh; padding: 4px 0; }
.pub .drapeau { font-size: 18px; margin-right: 6px; }
.pub-titre { padding: 8px 10px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); }

/* ---------- liste de chaînes ---------- */
#filAriane { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--ligne); font-size: 13px; }
#filAriane button { padding: 3px 8px; }
#liste { flex: 1; overflow-y: auto; position: relative; }
#taille { position: relative; }
#lignes { position: absolute; left: 0; right: 0; top: 0; }
.ch { height: var(--ligne-h); display: flex; align-items: center; gap: 10px; padding: 0 10px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.05); }
.ch:hover { background: var(--verre); }
.ch.actif { background: var(--nuit-3); }
.ch .num { width: 34px; color: var(--doux); font-size: 11px; text-align: right; flex: none; }
.logo { width: 44px; height: 32px; flex: none; border-radius: 5px; background: #000 center/contain no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--doux); overflow: hidden; }
.ch .nm { flex: 1; min-width: 0; }
.ch .nm b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch .nm small { display: block; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch .nm small.epg { color: var(--ciel); }
.fav { background: none; border: none; color: #3f4d7d; font-size: 18px; padding: 4px 6px; }
.fav.actif, .fav:hover { color: var(--lis); }
.compteur { padding: 6px 12px; color: var(--doux); font-size: 12px; border-top: 1px solid var(--ligne); }

/* ---------- lecteur ---------- */
#lecteur { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #000; }
#scene { flex: 1; position: relative; min-height: 0; }
video { width: 100%; height: 100%; background: #000; display: block; }
#message { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px;
  color: var(--doux); text-align: center; padding: 24px; pointer-events: none; background: radial-gradient(ellipse at center, #0d1838 0%, #000 75%); }
#message.erreur { color: #ffb4b4; }
#message .grand { font-size: 44px; }
#message.cache { display: none; }
.rond { width: 40px; height: 40px; border: 3px solid #223; border-top-color: var(--ciel); border-radius: 50%; animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.flottant { position: absolute; left: 10px; top: 10px; display: none; background: rgba(0,0,0,.6); }
#barre { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--nuit-2); border-top: 1px solid var(--ligne); flex-wrap: wrap; }
#barre .logo { width: 56px; height: 40px; }
#courant { flex: 1; min-width: 120px; }
#courant b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#courant small { display: block; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#courant small.epg { color: var(--ciel); }
#seekbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--nuit-2); border-top: 1px solid var(--ligne); }
#seekbar[hidden] { display: none; }
#seekbar .temps { min-width: 44px; color: var(--doux); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
#positionVOD { flex: 1; min-width: 80px; margin: 0; padding: 0; accent-color: var(--ciel); cursor: pointer; }
#barre button { padding: 6px 9px; }
#barre button.copier-url { color: var(--ciel); }
#volume { width: 100px; padding: 0; accent-color: var(--ciel); }

/* ---------- boîtes et avis ---------- */
dialog { background: var(--nuit-2); color: var(--texte); border: 1px solid var(--ligne); border-radius: 14px; padding: 0; width: min(640px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.65); }
.dh { padding: 14px 18px; border-bottom: 1px solid var(--ligne); font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.fermer { background: none; border: none; font-size: 16px; }
.db { padding: 14px 18px; overflow: auto; max-height: 72vh; }
.db h3 { margin: 12px 0 6px; font-size: 14px; color: var(--ciel); }
.db h3:first-child { margin-top: 0; }
.db ul { margin: 0; padding-left: 18px; }
.db li { margin-bottom: 4px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--nuit-3); border: 1px solid var(--ligne);
  color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.5); }

/* ---------- écrans moyens ---------- */
@media (max-width: 1100px) { #app { grid-template-columns: 260px 300px 1fr; } }

/* ---------- téléphone / tablette : tout en colonne, lecteur en haut ---------- */
@media (max-width: 860px) {
  body { overflow: auto; height: auto; min-height: 100%; }
  #entete { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 8px; }
  .marque { font-size: 15px; }
  #onglets { order: 3; width: 100%; }
  .recherche { max-width: none; order: 2; margin-left: 0; flex: 1; }
  #app { display: flex; flex-direction: column; }
  #lecteur { order: 1; position: sticky; top: 0; z-index: 15; }
  #scene { height: min(56.25vw, 38vh); flex: none; }   /* le lecteur reste visible en haut, la liste défile dessous */
  #scene:fullscreen { height: 100%; }
  #barre { padding: 6px 8px; }
  #seekbar { padding: 7px 10px; gap: 7px; }
  #cote { order: 2; border-right: none; border-bottom: 1px solid var(--ligne); }
  #chaines { order: 3; border-right: none; min-height: 50vh; }
  #liste { min-height: 50vh; }
  #groupes { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; padding: 6px; max-height: none; }
  .grp { flex: none; }
  #pubListes { max-height: 36vh; }
  .flottant { display: block; }
  body.liste-cachee #cote, body.liste-cachee #chaines { display: none; }
  body.liste-cachee #lecteur { position: static; }
  body.liste-cachee #scene { height: calc(100vh - 150px); }
}

/* Enregistrement */
#barre button.rec { color: #ff6b6b; font-variant-numeric: tabular-nums; }
#barre button.rec-actif { background: #dc2626; border-color: #dc2626; color: #fff; animation: rec-pulse 1.6s ease-in-out infinite; }
#barre button.rec-prog { background: rgba(246,199,68,.18); border-color: var(--lis); color: var(--lis); }
@keyframes rec-pulse { 50% { box-shadow: 0 0 0 5px rgba(220,38,38,.25); } }
.rec-db { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.rec-db > label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--doux); }
.rec-db > label.case { flex-direction: row; align-items: center; gap: 8px; color: var(--texte); }
.rec-db select, .rec-db input[type=time] { background: var(--nuit-2); border: 1px solid var(--ligne); border-radius: 8px; padding: 7px 9px; color: var(--texte); }
.rec-db p { margin: 0; }

/* Amazon Silk / Fire TV Cube : interface 10 pieds, texte et cibles télécommande agrandis */
html[data-layout="tv"] { --entete-h: 76px; --ligne-h: 72px; --rayon: 14px; }
html[data-layout="tv"] body { height: 100%; overflow: hidden; font-size: 17px; }
html[data-layout="tv"] #entete { gap: 14px; padding-inline: 18px; }
html[data-layout="tv"] .marque { font-size: 21px; }
html[data-layout="tv"] #onglets { gap: 8px; }
html[data-layout="tv"] #onglets button { font-size: 17px; padding: 12px 15px; }
html[data-layout="tv"] #app { display: grid; flex-direction: initial; grid-template-columns: minmax(320px, 20vw) minmax(380px, 26vw) minmax(460px, 1fr); }
html[data-layout="tv"] #lecteur { order: initial; position: static; }
html[data-layout="tv"] #cote, html[data-layout="tv"] #chaines { order: initial; }
html[data-layout="tv"] #scene { height: auto; flex: 1; }
html[data-layout="tv"] #groupes { display: block; overflow: auto; }
html[data-layout="tv"] .flottant { display: none; }
html[data-layout="tv"] .panneau { padding: 16px; gap: 14px; }
html[data-layout="tv"] .panneau h2 { font-size: 19px; }
html[data-layout="tv"] label, html[data-layout="tv"] .indice { font-size: 15px; }
html[data-layout="tv"] button { min-height: 52px; padding: 10px 15px; font-size: 17px; }
html[data-layout="tv"] input[type=text], html[data-layout="tv"] input[type=url], html[data-layout="tv"] input[type=search], html[data-layout="tv"] input[type=password], html[data-layout="tv"] input:not([type]) { min-height: 52px; padding: 11px 13px; font-size: 17px; }
html[data-layout="tv"] .grp, html[data-layout="tv"] .pub { min-height: 58px; padding: 10px 14px; font-size: 16px; }
html[data-layout="tv"] .ch { gap: 12px; padding-inline: 14px; }
html[data-layout="tv"] .ch .num { width: 42px; font-size: 14px; }
html[data-layout="tv"] .logo { width: 54px; height: 40px; font-size: 14px; }
html[data-layout="tv"] .ch .nm b { font-size: 17px; }
html[data-layout="tv"] .ch .nm small { font-size: 14px; }
html[data-layout="tv"] #filAriane, html[data-layout="tv"] .compteur { padding: 10px 14px; font-size: 15px; }
html[data-layout="tv"] #barre { gap: 12px; padding: 12px 16px; }
html[data-layout="tv"] #barre button { min-width: 54px; min-height: 54px; font-size: 21px; }
html[data-layout="tv"] #barre .logo { width: 66px; height: 48px; }
html[data-layout="tv"] #seekbar { gap: 16px; padding: 12px 20px; }
html[data-layout="tv"] #seekbar .temps { min-width: 58px; font-size: 16px; }
html[data-layout="tv"] #positionVOD { min-height: 28px; }
html[data-layout="tv"] #courant b { font-size: 19px; }
html[data-layout="tv"] #courant small { font-size: 14px; }
html[data-layout="tv"] #volume { width: 140px; }
html[data-layout="tv"] #message { font-size: 20px; }
html[data-layout="tv"] #message .grand { font-size: 60px; }
html[data-layout="tv"] .ch:focus-visible, html[data-layout="tv"] .grp:focus-visible, html[data-layout="tv"] .pub:focus-visible,
html[data-layout="tv"] button:focus-visible, html[data-layout="tv"] input:focus-visible, html[data-layout="tv"] select:focus-visible,
html[data-layout="tv"] a:focus-visible { outline: 4px solid var(--lis); outline-offset: 2px; box-shadow: 0 0 0 7px rgba(246,199,68,.22); position: relative; z-index: 2; }
html[data-layout="tv"] .ch:focus-visible, html[data-layout="tv"] .grp:focus-visible, html[data-layout="tv"] .pub:focus-visible { background: var(--nuit-4); color: #fff; }

@media (max-width: 1200px) {
  html[data-layout="tv"] #app { grid-template-columns: 245px 300px minmax(390px, 1fr); }
  html[data-layout="tv"] #entete { gap: 8px; padding-inline: 10px; }
  html[data-layout="tv"] #onglets { gap: 2px; }
  html[data-layout="tv"] #onglets button { padding-inline: 8px; font-size: 15px; }
}
@media (max-width: 980px) {
  html[data-layout="tv"] #app { grid-template-columns: 210px 270px minmax(320px, 1fr); }
  html[data-layout="tv"] .recherche { min-width: 90px; }
}

/* Safari iOS : respecter la zone sûre du bas, Chrome/Firefox mobiles gardent la disposition tactile existante */
html[data-browser="safari"] #barre { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
html[data-browser="chrome-ios"] #barre, html[data-browser="firefox-ios"] #barre { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
