/* ---------- 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;
  }

  /* nav mobile: source unique dans player.css (@media 768) */

  #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);
  }

  .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;
  }
  .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: 40vh;
  }
  .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 */
    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;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex: 0 0 40%;
    background: var(--surface);
  }
  .detail-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .detail-head {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
  }
  .detail-head h1 {
    flex: 1;
    min-width: 0;
  }
  .player-controls {
    padding: 1.1rem 1rem max(1.1rem, calc(env(safe-area-inset-bottom) + 0.8rem));
    gap: 0.8rem;
  }
  .pc-btn {
    width: 40px;
    height: 40px;
  }
  .pc-btn.pc-vlc {
    padding: 0 0.9rem;
    font-size: 0.78rem;
  }
  .pc-title {
    font-size: 0.85rem;
  }
  .pc-vol {
    display: none;
  }
  /* seek bar reachable by finger (5px frustrating on touch) */
  .pc-seek-wrap {
    height: 8px;
  }
  .pc-time {
    font-size: 0.75rem;
  }
  .player-bigplay {
    width: 76px;
    height: 76px;
  }
  .ep {
    gap: 0.6rem;
    padding: 0.6rem 0.3rem;
  }
  .ep-index {
    width: 1.6rem;
    font-size: 0.85rem;
  }
  .ep-thumb {
    width: 28vw;
    min-width: 70px;
  }
  .ep .ep-t {
    font-size: 0.9rem;
  }
  .ep-plot {
    -webkit-line-clamp: 1;
    font-size: 0.8rem;
  }
  .ep-meta {
    display: none;
  }
  .btn-icon {
    min-width: 44px;
    min-height: 44px;
  }
  .ep-actions {
    opacity: 1;
  }
  .overlay .close {
    right: 1.2rem;
    width: 44px;
    height: 44px;
  }
  /* alert player section if very close: body:has() fixes overlap with detail */
  .cat-head {
    padding: 0.8rem 1.2rem 1rem;
    padding-top: max(3.5rem, calc(env(safe-area-inset-top) + 2.5rem));
  }
  .cat-grid {
    padding: 0 1.2rem 4rem;
  }
  .overlay .close {
    right: auto;
    left: max(1rem, env(safe-area-inset-left));
  }
}

@media (max-width: 480px) {
  .tabs button { font-size: 0.78rem; padding: 0.5rem 0.2rem; }
  /* Player controls: compact so the whole row fits one line on phones
     (previously play/mute/PiP/Cast/VLC/fs stacked onto 2-3 wrapped lines,
     covering the video). Keep essentials; PiP/cast are useless in portrait. */
  .player-controls .pc-row {
    gap: 0.4rem;
    flex-wrap: nowrap;
  }
  /* #audit-mobile: 40px min tactile (était 36px) — la rangée tient
     toujours sur une ligne (vérifié 360px : 5x40 + gaps + VLC) */
  .player-controls .pc-btn {
    width: 40px;
    height: 40px;
    min-width: 0;
    min-height: 0;
    flex: 0 0 40px;
  }
  .player-controls .pc-btn svg { width: 18px; height: 18px; }
  #player-pip, #player-cast, #player-airplay { display: none !important; }
  .player-controls .pc-btn.pc-vlc {
    flex: 0 0 auto;
    padding: 0 0.7rem;
    font-size: 0.72rem;
    height: 40px;
  }
  .pc-vol { display: none !important; }
  .pc-spacer { flex: 0 0 auto; width: 0; }
  .player-controls { padding: 0.9rem 0.7rem max(0.9rem, calc(env(safe-area-inset-bottom) + 0.4rem)); gap: 0.5rem; }
  .player-controls .pc-row { row-gap: 0.3rem; }
  #tab-fav, #tab-admin, #search-btn { width: 44px; padding: 0.5rem 0.35rem; }
  .row-head { min-height: 44px; align-items: center; }
  .btn { min-height: 44px; flex: 1 1 100%; padding: 0.7rem 1.2rem; font-size: 0.9rem; }
  .card { width: 120px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .card .title { font-size: 0.75rem; margin-top: 0.3rem; }
  /* #audit-prod: 5.5rem seul suffit sans encoche; avec safe-area (iPhone 34px)
     la dernière rangée passait sous la bottom nav — on ajoute l'inset. */
  #content { padding: 0.4rem 0.6rem calc(5.5rem + env(safe-area-inset-bottom)); padding-top: calc(max(1rem, env(safe-area-inset-top)) + 44px + 0.75rem); }
  .row-scroll { gap: var(--sp-3); padding-bottom: 1rem; }
  .row-scroll > .card { flex: 0 0 140px; } /* uniform width mobile */
  .auth-card { padding: 2.5rem 1.5rem; }
  .auth-card h1.brand-logo { font-size: 2rem; margin-bottom: 2rem; }
  .ep { gap: 0.4rem; padding: 0.5rem 0.2rem; }
  .ep-thumb { width: 30vw; min-width: 60px; }
  .ep .ep-t { font-size: 0.82rem; }
  .ep-meta { display: none; }
  .ep-plot { display: none; }
  .detail-hero { height: 35vh; min-height: 250px; }
  .detail-body { padding: 1rem 1rem 2rem; }
  .detail-body h1 { font-size: 1.4rem; }
  .detail-meta { font-size: 0.85rem; gap: 0.5rem; flex-wrap: wrap; }
  .admin { padding: 0.4rem 0.4rem 4rem; }
  .ab-head h1 { font-size: 1.1rem; }
  .ab-kpis { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .ab-kpi { padding: 0.6rem 0.8rem; }
  .admin th, .admin td { padding: 0.4rem 0.5rem; font-size: 0.75rem; }
  .ab-clip { max-width: 120px; }
  .admin .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.68rem; }
  .ab-av { width: 30px; height: 30px; font-size: 0.7rem; }
}

@media (max-width: 380px) {
  .tabs button { font-size: 0.72rem; padding: 0.55rem 0.15rem; }
  #tab-fav, #tab-admin, #search-btn { padding: 0.55rem 0.3rem; }
  .auth-card { padding: 2rem 1rem; }
  .auth-card h1.brand-logo { font-size: 1.6rem; }
  /* #audit-mobile: >=16px sinon iOS/Chrome auto-zoom au focus (piege classique) */
  .auth-card input { padding: 0.9rem 1rem; font-size: 1rem; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
  .card { width: auto; }
  .card .title { font-size: 0.7rem; }
  .row-scroll { gap: var(--sp-3); }
  .row-scroll > .card { flex: 0 0 120px; } /* uniform width extra-small */
  #content { padding: 0.3rem 0.4rem calc(5.5rem + env(safe-area-inset-bottom)); padding-top: calc(max(1rem, env(safe-area-inset-top)) + 44px + 0.75rem); }
  .admin { padding: 0.3rem 0.3rem 4rem; }
  .ab-head h1 { font-size: 1rem; }
  .ab-kpis { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
  .ab-kpi { padding: 0.5rem 0.6rem; }
  .admin th, .admin td { padding: 0.3rem 0.4rem; font-size: 0.7rem; }
  .admin .btn-sm { padding: 0.2rem 0.4rem; font-size: 0.65rem; }
}

/* ============================================================
