/* ══════════════════════════════════════════════════════════════════
   PALAMA-TV — MODE MOBILE (html.device-mobile)
   Layout vertical · Sidebar drawer · Bottom nav · Qualité réduite
   NE PAS modifier — n'affecte PAS le mode PC (style.css intact)
   ══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────
   APP WRAPPER — colonne verticale
   ───────────────────────────────────────────── */
html.device-mobile .app-wrapper {
  flex-direction: column;
  height: 100dvh;          /* dynamic viewport height (iOS Safari) */
  overflow: hidden;
}

html.device-mobile .main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: auto;
  padding-bottom: 62px;    /* espace pour la bottom nav */
}

/* ─────────────────────────────────────────────
   SIDEBAR — drawer plein écran depuis la gauche
   (même logique que le media query ≤768px mais
    s'applique sur TOUT les écrans en mode mobile)
   ───────────────────────────────────────────── */
html.device-mobile .sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  width: 88vw !important;
  max-width: 340px !important;
  min-width: unset !important;
  transform: translateX(-105%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  box-shadow: 4px 0 32px rgba(0,0,0,0.6);
  height: 100dvh !important;
  padding-bottom: env(safe-area-inset-bottom);
}

html.device-mobile .sidebar.open {
  transform: translateX(0);
}

html.device-mobile .sidebar.collapsed {
  transform: translateX(-105%);
}

/* Overlay sombre derrière le drawer */
html.device-mobile .sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
html.device-mobile .sidebar.open ~ .sidebar-overlay,
html.device-mobile body.sidebar-open .sidebar-overlay { display: block; }

/* Textes sidebar toujours visibles dans le drawer */
html.device-mobile .sidebar .logo-text,
html.device-mobile .sidebar .search-wrapper,
html.device-mobile .sidebar .section-label,
html.device-mobile .sidebar .cat-btn span:last-child,
html.device-mobile .sidebar .channel-name,
html.device-mobile .sidebar .channel-meta,
html.device-mobile .sidebar .channel-count,
html.device-mobile .sidebar .filter-pills,
html.device-mobile .sidebar .source-label,
html.device-mobile .sidebar .source-indicator {
  display: initial !important;
}

/* ─────────────────────────────────────────────
   SIDEBAR DRAWER — ajustements internes
   ───────────────────────────────────────────── */

/* Source-selector : boutons sur 2 lignes si nécessaire */
html.device-mobile .source-selector {
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 10px;
}

html.device-mobile .source-btn {
  flex: 1 1 calc(33% - 5px);
  min-width: 70px;
  font-size: 11px;
  padding: 6px 8px;
  justify-content: center;
}

html.device-mobile .source-label {
  font-size: 11px;
}

/* Source indicator plus compact */
html.device-mobile .source-indicator {
  padding: 5px 10px;
  font-size: 11px;
}

/* Liste chaînes : prend tout l'espace disponible */
html.device-mobile .channels-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Catégories : scroll horizontal */
html.device-mobile .cats-bar {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
html.device-mobile .cats-bar::-webkit-scrollbar { display: none; }

/* ─────────────────────────────────────────────
   TOPBAR — simplifié pour mobile
   ───────────────────────────────────────────── */
html.device-mobile .topbar {
  padding: 0 10px;
  gap: 6px;
  height: calc(50px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  flex-shrink: 0;
}

/* Bouton hamburger toujours visible */
html.device-mobile .mobile-menu-btn {
  display: flex;
}

/* Toggle sidebar desktop → caché */
html.device-mobile .sidebar-toggle {
  display: none;
}

/* Mode nav topbar → caché (remplacé par bottom nav) */
html.device-mobile .mode-nav {
  display: none !important;
}

/* Actions topbar : garder seulement l'essentiel */
html.device-mobile #mosaicBtn,
html.device-mobile #recordBtn,
html.device-mobile #backupBtn,
html.device-mobile #pipBtn,
html.device-mobile #logoPickerBtn,
html.device-mobile #sleepWrap,
html.device-mobile .btn-superpower {
  display: none !important;
}

/* Réduire la barre d'actions */
html.device-mobile .topbar-actions {
  gap: 4px;
}

html.device-mobile .btn-icon,
html.device-mobile .btn-quality,
html.device-mobile .btn-release,
html.device-mobile .btn-reset-menu {
  min-height: 36px;
  padding: 0 8px;
}

/* ─────────────────────────────────────────────
   PLAYER — pleine largeur, ratio 16:9
   ───────────────────────────────────────────── */
html.device-mobile .player-container {
  width: 100%;
  min-height: 56.25vw;     /* 16:9 exact */
  max-height: 60vw;
  flex-shrink: 0;
  border-radius: 0;
  position: relative;
}

/* ─────────────────────────────────────────────
   CONTENU SOUS LE PLAYER — scrollable
   ───────────────────────────────────────────── */
html.device-mobile .grid-section,
html.device-mobile .vod-view,
html.device-mobile .yt-view,
html.device-mobile .mosaic-view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Grille chaînes live (sous player) — liste verticale scrollable sur mobile */
html.device-mobile .grid-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  padding: 8px 8px 0;
  overflow: hidden;          /* le scroll est porté par .channel-grid */
}
html.device-mobile .grid-section .channel-grid {
  flex: 1;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 4px;
  padding: 0 0 12px;
}
html.device-mobile .grid-section .grid-card {
  flex-direction: row;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  padding: 8px 12px;
  gap: 12px;
  justify-content: flex-start;
  text-align: left;
}
html.device-mobile .grid-section .grid-card-logo,
html.device-mobile .grid-section .grid-card-logo-fallback {
  width: 34px; height: 34px;
  flex-shrink: 0;
}
html.device-mobile .grid-section .grid-card-name {
  font-size: 14px;
  text-align: left;
  max-width: none;
  flex: 1;
}

/* Grille VOD */
html.device-mobile .vod-grid {
  grid-template-columns: repeat(2, 1fr);  /* 2 colonnes sur mobile */
  gap: 8px;
}

html.device-mobile .vod-header {
  padding: 10px 10px 4px;
}

/* Grille YouTube */
html.device-mobile .yt-results {
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 8px;
  padding: 0 8px;
}

/* ─────────────────────────────────────────────
   TOUCH TARGETS — min 44px (Apple HIG)
   ───────────────────────────────────────────── */
html.device-mobile .channel-item {
  min-height: 56px;
  padding: 0 12px;
}

html.device-mobile .cat-btn {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

html.device-mobile .filter-pill {
  min-height: 40px;
  padding: 0 16px;
  font-size: 13px;
}

html.device-mobile .channel-fav-btn {
  width: 36px;
  height: 36px;
}

html.device-mobile .mode-btn {
  min-height: 44px;
}

/* ─────────────────────────────────────────────
   BOTTOM NAVIGATION — fixe en bas
   ───────────────────────────────────────────── */
.mbn {
  display: none;              /* caché par défaut (mode PC) */
}

html.device-mobile .mbn {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 150;
  background: rgba(8,8,18,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}

.mbn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.38);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .02em;
  transition: color 0.15s, background 0.15s;
  min-height: 54px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.mbn-btn:active {
  background: rgba(255,255,255,0.04);
}

.mbn-btn.active {
  color: #7c6aff;
}

/* Indicateur actif sous le bouton */
.mbn-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2.5px;
  background: #7c6aff;
  border-radius: 0 0 3px 3px;
}

.mbn-btn svg {
  flex-shrink: 0;
}

.mbn-btn span {
  line-height: 1;
}

/* Badge sur un bouton bottom nav (ex: nombre de favoris) */
.mbn-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 14px);
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ─────────────────────────────────────────────
   LANDING PAGE en mode mobile
   ───────────────────────────────────────────── */
html.device-mobile .landing-center {
  padding: 20px 16px;
}

html.device-mobile .palama-logo {
  font-size: clamp(32px, 10vw, 52px);
}

html.device-mobile .landing-tagline {
  font-size: 13px;
}

/* ─────────────────────────────────────────────
   OVERLAYS & PANELS — adaptés mobile
   ───────────────────────────────────────────── */
html.device-mobile .vod-slow-panel {
  bottom: 56.25vw; /* au dessus du player */
}

/* Now playing bar */
html.device-mobile .now-playing {
  max-width: 130px;
  font-size: 11px;
}

/* ─────────────────────────────────────────────
   HIDE elements non pertinents mobile
   ───────────────────────────────────────────── */
/* NB : .grid-section N'EST PLUS masquée sur mobile — elle affiche la liste
   des chaînes sous le player (la visibilité par mode est gérée en JS via
   liveGridSection.style.display). */

html.device-mobile .mosaic-view .mosaic-size-btns button[data-cols="5"],
html.device-mobile .mosaic-view .mosaic-size-btns button[data-cols="6"] {
  display: none;
}
