/* Fullscreen Video Player */
.player {
  background: radial-gradient(70% 80% at 55% 40%, #1c1626, #060508 75%);
  overflow: hidden;
}
/* Le player est un .overlay qui hérite de overflow-y:auto (détail.css) —
   une scrollbar apparaît dès que les contrôles/menus débordent un poil,
   ce qui n'a aucun sens sur une vidéo plein écran. Forcer hidden partout.
   NOTE: overflow-y: auto sur .overlay (detail.css) doit être écrasé
   explicitement car overflow shorthand ne bat pas overflow-y spécifique. */
#player,
.overlay.player,
#player.overlay {
  overflow: hidden !important;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

/* Fullscreen video in player */
#player-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  z-index: 50;
}

/* Gros bouton central play/pause (visible quand en pause) */
.player-bigplay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 62;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #cbbcff;
  background: linear-gradient(145deg, #100e14, #1b1822);
  box-shadow: inset 3px 3px 7px rgba(0, 0, 0, 0.78), inset -2px -2px 5px rgba(255, 255, 255, 0.05), 0 0 0 1px rgba(167, 139, 250, 0.35), 0 0 60px rgba(167, 139, 250, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.player-bigplay:hover { background: linear-gradient(145deg, #191522, #241f2e); transform: translate(-50%, -50%) scale(1.06); }
.player-bigplay[hidden] { display: none; }

/* Controls bar at bottom */
.player-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 63;
  padding: 1.4rem 1.6rem max(1.4rem, calc(env(safe-area-inset-bottom) + 0.6rem));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Auto-hide: player goes visual fullscreen (no UI) if inactive */
.player.pc-hidden .player-controls { opacity: 0; transform: translateY(12px); pointer-events: none; }
.player.pc-hidden .player-bigplay { display: none; }

.player-controls .pc-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap; /* ponytail: #22 — les labels audio longs wrappent au lieu de pousser les voisins */
  row-gap: 0.5rem;
}

/* ponytail: #22 — label audio/subs tronqué, détail complet dans le menu */
#player-audio, #player-subs {
  width: auto;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: #0a0a0a;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.pc-btn:hover { background: white; color: black; transform: scale(1.05); }

#pc-play {
  width: 56px;
  height: 56px;
  border: 0;
  color: #14101f;
  background: radial-gradient(circle at 30% 22%, #cdbfff, #a78bfa 52%, #7c63de);
  box-shadow: 0 6px 14px -4px rgba(167, 139, 250, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -3px 6px rgba(66, 40, 150, 0.5);
}
#pc-play:hover { background: radial-gradient(circle at 30% 22%, #e2d8ff, #bca7ff 52%, #8f78e8); color: #14101f; }

.pc-btn.pc-vlc {
  width: auto;
  border-radius: var(--radius-full);
  padding: 0 1.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pc-btn.pc-vlc:hover { background: #f15a24; border-color: #f15a24; color: white; }
.pc-btn.pc-vlc {
  background: #f15a24;
  border-color: #ff8a5b;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(241, 90, 36, 0.2);
}

.pc-title {
  flex: 1;
  min-width: 0;
  color: white;
  font-family: 'Bricolage Grotesque', 'Hanken Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 26px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.pc-live {
  flex-shrink: 0;
  background: #c0392b;
  color: #fff;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: none;
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* Seek VOD */
.pc-seek {
  display: flex;
  align-items: center;
  gap: 1rem;
  pointer-events: auto;
}
.pc-seek[hidden] { display: none; }

.pc-time {
  color: white;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  flex-shrink: 0;
}

.pc-seek-wrap {
  flex: 1;
  position: relative; /* anchor for .pc-seek-buffer (absolute) — without it the buffer floats relative to a distant ancestor */
  min-height: 12px;
  height: 6px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-full);
  cursor: pointer;
  pointer-events: auto;
  transition: height 0.15s ease;
}
.pc-seek-wrap:hover { height: 8px; }

.pc-seek-bar {
  height: 100%;
  width: 0;
  position: relative; /* anchor for .pc-seek-bar::after thumb */
  background: var(--grad);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-glow);
}

.pc-seek-buffer {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
}

/* Volume + muet */
.pc-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pc-vol {
  -webkit-appearance: none;
  appearance: none;
  width: 84px;
  height: 4px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.25);
  outline: none;
  cursor: pointer;
}
.pc-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--shadow-glow);
  cursor: pointer;
}
.pc-vol::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: white;
  cursor: pointer;
}

/* Settings popup (quality / audio / subtitles) */
.pc-pop {
  position: relative;
  flex-shrink: 0;
}
.pc-menu {
  position: absolute;
  bottom: calc(100% + 0.8rem);
  right: 0;
  z-index: 65;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  background: #0a0a0a;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
}
.pc-menu[hidden] { display: none; }
.pc-menu-title {
  color: var(--accent-hover);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.6rem 0.8rem 0.3rem;
}
.pc-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: white;
  font-size: 0.9rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.pc-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.pc-menu-item.on { color: var(--accent-hover); font-weight: 700; }
.pc-menu-item.on::after { content: ' — actif'; }

.player-msg {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 64;
  text-align: center;
  background: #0a0a0a;
  border: 1px solid var(--glass-border);
  padding: 1.5rem 2.5rem;
  border-radius: var(--radius-md);
  color: white;
  box-shadow: var(--shadow-lg);
  max-width: 90%;
}

.player-msg p {
  margin-bottom: 0.9rem;
  font-size: 0.98rem;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: max(2.5rem, calc(env(safe-area-inset-bottom) + 1rem));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: white;
  padding: 1rem 1.8rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastIn {
  from { transform: translate(-50%, 1.5rem); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Admin Dashboard */
/* ---------- Admin : dashboard ---------- */
.admin {
  padding: 1.5rem 0 4rem;
  max-width: 1100px;
  margin: 0 auto;
}
.ab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}
.ab-head h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Tuiles KPI */
.ab-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.ab-kpi {
  padding: 1.3rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--glass-border);
}
.ab-kpi-val {
  color: var(--text-bright);
  font-family: 'Outfit', sans-serif;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ab-kpi-label {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.ab-sec { margin-bottom: 2.5rem; }
.ab-sec h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

/* Card wrapping a table (clean rounding, horizontal scroll if narrow) */
.ab-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.admin table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.admin th, .admin td {
  text-align: left;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle; /* fixes "user too tall": cells vertically centered */
}
.admin th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  background: rgba(255, 255, 255, 0.02);
}
.admin tbody tr:last-child td, .admin tr:last-child td { border-bottom: none; }
.admin tr:not(:first-child):hover td { background: rgba(255, 255, 255, 0.02); }

/* User cell: initials avatar + name + role */
.ab-user { display: flex; align-items: center; gap: 0.8rem; }
.ab-av {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-bright);
}
/* modificateur admin: PAS ".admin" (collision avec le conteneur .admin qui posait
   its padding 1.5rem 0 4rem on avatar -> ellipse). Hence ".ab-admin". */
.ab-av.ab-admin {
  background: var(--accent);
  border-color: transparent;
  color: #000;
}
.ab-name {
  font-weight: 600;
  color: var(--text-bright);
  display: flex; align-items: center; gap: 0.3rem;
}
.ab-sub { color: var(--muted); font-size: 0.78rem; margin-top: 0.1rem; }
.ab-muted { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ab-clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badge de type de lecture */
.ab-type {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.ab-movie { background: rgba(255, 255, 255, 0.08); color: #ddd; }
.ab-ep    { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.ab-live  { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }

.admin td.code {
  font-family: ui-monospace, monospace;
  color: var(--accent-hover);
  letter-spacing: 1px;
  font-weight: 600;
}
.admin td.muted { color: var(--muted); }

.admin .row-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.admin .btn-sm {
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
}
.admin .btn-sm:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--border-hover); }
.admin .btn-sm.danger:hover { color: #fca5a5; background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); }

.ab-empty {
  padding: 1.6rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

/* One-time banner (password reset, HTMX): green-tinted, shown once. */
.ab-flash {
  background: rgba(34, 197, 94, 0.08);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem 1.4rem;
  font-size: 0.95rem;
  margin-bottom: 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.ab-flash code {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-sm);
}
.ab-flash .btn-sm { margin-left: auto; }

.admin td.muted {
  color: var(--muted);
  text-decoration: line-through;
}

.empty-inline {
  color: var(--muted);
  margin: 2rem 0 3rem;
}

.admin td {
  color: #ccc;
  font-size: 0.95rem;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  #content {
    padding: 2rem 2rem 5rem;
    padding-top: max(2rem, calc(env(safe-area-inset-top) + 0.5rem));
  }
  .detail-body h1 {
    font-size: 2.5rem;
  }
}

@media (max-width: 768px) {
  /* phantom header reduced to nothing: pill becomes fixed bottom-nav */
  #topbar {
    position: static;
    padding: 0;
    margin: 0;
  }

  .tabs {
    position: fixed;
    left: 50%;
    right: auto;
    width: min(calc(100% - 1.2rem), 520px);
    transform: translateX(-50%);
    bottom: max(0.6rem, env(safe-area-inset-bottom));
    z-index: var(--z-nav);
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 0.3rem;
    gap: 0.25rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  }
  .tabs button {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0.5rem 0.4rem;
    font-size: 0.92rem;
  }
  /* 8 boutons ne tiennent pas en texte dans 390px (chevauchement
     "AdminEnregistrements") -> nav icônes seules, comme le rail desktop */
  .tabs button .label { display: none; }
  /* touch-first: minimum 44px touch target on all compact controls */
  .btn, .btn.sm, .btn-sm, .pill { min-height: 44px; }
  #tab-fav, #tab-admin, #search-btn {
    flex: 0 0 auto;
    width: 52px;
    min-height: 44px;
    padding: 0.5rem 0.65rem;
  }

  #logout {
    top: max(1rem, env(safe-area-inset-top));
    right: 0.8rem;
    width: 44px;
    height: 44px;
  }

  #search-wrap {
    position: fixed;
    left: 0.6rem; right: 0.6rem;
    bottom: calc(max(0.6rem, env(safe-area-inset-bottom)) + 4.4rem);
    z-index: var(--z-search);
    width: auto;
    max-width: none;
    margin: 0;
  }
  #topbar.search-open #search-wrap { margin: 0; }
  #search {
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    font-size: 16px; /* <16px = Safari zoome au focus */
  }

  .admin {
    padding: 0.8rem 0 4rem;
  }
  .admin table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
  }
  .admin th, .admin td { padding: 0.55rem 0.8rem; font-size: 0.82rem; }
  .admin .btn-sm { padding: 0.35rem 0.7rem; font-size: 0.74rem; }
  .ab-head h1 { font-size: 1.3rem; }
  .ab-kpis { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
  .ab-kpi { padding: 0.8rem 1rem; }
  .ab-kpi-val { font-size: 1.5rem; }
  #content {
    /* bottom: fixed bottom-nav (~4.1rem with offset) + margin -- nothing hidden below */
    /* top: clears floating #logout (top:1rem + 44px) + breathing room */
    padding: calc(max(1rem, env(safe-area-inset-top)) + 44px + 0.75rem) 1rem calc(5.5rem + env(safe-area-inset-bottom));
    /* min-height: prevents #content collapse between skeleton + real content (tab switch) */
    min-height: calc(100dvh - 6rem);
  }
  .row {
    margin-bottom: 1.2rem;
  }
  .episodes {
    gap: 1rem;
  }
  .row h2 {
    font-size: 1.15rem;
    margin-bottom: 0.8rem;
  }
  .row-head .see-all { font-size: 0.72rem; }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
  }
  .card {
    width: 150px;
  }
  /* resume 280px ne tient pas sur 320-360px → une carte coupée */
  .card.resume {
    width: 240px;
  }
  .row-scroll {
    gap: var(--sp-3);
  }
  .card .title {
    font-size: 0.85rem;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
  }
  .detail-hero {
    height: 32vh;
    min-height: 260px; /* base 380px écrasait 40vh sur téléphone */
  }
  .detail-body {
    padding: 1.5rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }
  .detail-body h1 {
    font-size: 1.8rem;
  }
  .detail-actions {
    gap: 0.8rem;
    flex-wrap: wrap;
  }
  .btn {
    padding: 0.8rem 1.2rem;
    min-height: 44px; /* Issue #10 — accessible touch target mobile */
    font-size: 0.95rem;
    flex: 1 1 45%;
    justify-content: center;
  }
  /* Lire pleine largeur; VLC + ♥ partagent la ligne suivante (♥ compact) →
     1 row saved vs 3 full-width stacked buttons. */
  .detail-actions .btn.primary { flex: 1 1 100%; }
  .detail-actions .btn.vlc { flex: 1 1 auto; }
  .detail-actions .btn.fav { flex: 0 0 auto; min-width: 60px; padding-left: 1rem; padding-right: 1rem; }
  .detail-poster {
    width: 40%;
    max-width: 160px;
    aspect-ratio: 2/3;
  }
} /* fin @media 768 */

/* Spinner de chargement */
.player-loader {
  position: absolute;
  inset: 0;
  transform: translate(-50%, -50%);
  z-index: 61;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.9rem;
  color: #fff;
  text-shadow: 0 2px 8px #000;
  pointer-events: none;
  transform: none;
}
.player-loader-backdrop {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  filter: blur(24px) brightness(0.34);
  transform: scale(1.08);
  opacity: 0.9;
  z-index: -1;
}
.player-loader::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 7, 0.46);
  z-index: -1;
}
.player-loader[hidden] { display: none; }
#player-loader-label {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.spinner-ring {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #a785f2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Nuclear option: kill ANY scrollbar on player + parents (video fullscreen MUST never scroll) */
body:has(#player:not([hidden])),
html:has(#player:not([hidden])),
.overlay:has(#player:not([hidden])) {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}
#player video {
  contain: strict; /* isolate layout, prevent scrollbleed */
}

/* TRUE FULLSCREEN BEHAVIOR: when player is open, KILL browser scrollbar entirely.
   The viewer should feel like native fullscreen — no scroll, no nothing. */
@supports selector(:has(*)) {
  body:has(#player:not([hidden])),
  html:has(#player:not([hidden])) {
    overflow: hidden !important;
    overscroll-behavior: none !important;
  }
}
/* Fallback for browsers without :has() — add class via JS if needed */
body.player-active, html.player-active {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}
