/* ═══════════════════════════════════════════════════════════════
   apo-overlay.css — Le Tidiane v3
   Overlay player plein écran
   Réutilise TOUTES les classes ap-* de audio_player_page.css
   ═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   CONTENEUR OVERLAY — mobile first (flex colonne)
══════════════════════════════════════════════════════════════ */
.apo-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--ap-bg, #0b1a12);
  color: var(--ap-text, #e8eaed);
  font-family: 'DM Sans', system-ui, sans-serif;

  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;

  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Mobile : flex colonne */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 80px;
}

.apo-overlay::-webkit-scrollbar { width: 4px; }
.apo-overlay::-webkit-scrollbar-track { background: transparent; }
.apo-overlay::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.apo-overlay.apo-visible { transform: translateY(0); }

/* Fond flou art */
.apo-overlay .apo-bg-art {
  position: fixed; inset: -20px; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(60px) brightness(0.25) saturate(1.5);
  transform: scale(1.1); pointer-events: none;
  transition: background-image 0.6s ease;
}

/* Tous les enfants au-dessus du fond flou */
.apo-overlay > * { position: relative; z-index: 1; }

/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
.apo-overlay .apo-header-wrap {
  /* padding-top: max(52px, calc(env(safe-area-inset-top) + 14px)); */
}

.apo-overlay .apo-close-btn { text-decoration: none; }

/* ══════════════════════════════════════════════════════════════
   COLONNE PLAYER (mobile : visible inline dans le flux)
══════════════════════════════════════════════════════════════ */
.apo-overlay .apo-player-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   TRACKLIST PANE — mobile : pleine largeur sous le player
══════════════════════════════════════════════════════════════ */
.apo-overlay .apo-tracklist-full {
  width: 100% !important;
  min-width: 0 !important;
  position: static !important;
  height: auto !important;
  overflow: visible !important;
  border-right: none !important;
  border-top: 1px solid var(--ap-border, rgba(255,255,255,0.07));
  margin-top: 8px;
}

/* Header tracklist sticky dans l'overlay */
.apo-overlay .ap-tl-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--ap-bg, #0b1a12);
}

/* Sort menu z-index au-dessus de l'overlay */
.apo-overlay .ap-tl-sort-menu { z-index: 9500; background: #0e2418; }

/* ══════════════════════════════════════════════════════════════
   MENU CONTEXTUEL
══════════════════════════════════════════════════════════════ */
.ap-ctx-menu {
  position: fixed;
  background: #0e2418;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  min-width: 190px;
  z-index: 9600;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  display: none;
}
.ap-ctx-menu.open { display: block; }

.ap-ov-bg {
  display: none; position: fixed; inset: 0; z-index: 9550;
}
.ap-ov-bg.on { display: block; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .apo-overlay .ap-cover-inner { max-width: 220px; }
  .apo-overlay .ap-controls { gap: 8px; padding: 10px 16px 6px; }
  .apo-overlay .ap-btn-play { width: 58px; height: 58px; }
  .apo-overlay .ap-btn-sm { width: 40px; height: 40px; }
  .apo-overlay .ap-btn-md { width: 44px; height: 44px; }
  .apo-overlay .ap-zikr-section { margin: 4px 12px 0; width: 95%; }
  .apo-overlay .ap-volume-row { padding: 4px 20px 10px; }
  .apo-overlay .ap-tl-header { padding: 12px 14px 10px; }
}

/* ══════════════════════════════════════════════════════════════
   LIGHT MODE
══════════════════════════════════════════════════════════════ */
html.light-mode .apo-overlay,
body.light-mode .apo-overlay { background: var(--ap-bg, #f4f6f3); }

html.light-mode .apo-overlay .ap-tl-header,
body.light-mode .apo-overlay .ap-tl-header { background: var(--ap-bg, #f4f6f3); }

html.light-mode .ap-ctx-menu,
body.light-mode .ap-ctx-menu { background: #f0f4f1; }

/* ══════════════════════════════════════════════════════════════
   TABLET / DESKTOP ≥ 768px — GRID 2 COLONNES
   Gauche : tracklist | Droite : player
══════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {

  /* 1. Passer en grid et annuler le flex de base */
  .apo-overlay {
    display: grid !important;
    flex-direction: unset !important;
    align-items: unset !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
    height: 100vh;

    grid-template-columns: 1fr 360px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "header header"
      "list   player";
  }

  /* 2. Header — toute la largeur */
  .apo-overlay .ap-header.apo-header-wrap {
    grid-area: header;
    align-self: start;
  }

  /* 3. Tracklist — colonne gauche, scrollable */
  .apo-overlay .ap-tracklist-pane.apo-tracklist-full {
    grid-area: list;
    overflow-y: auto !important;
    height: 100% !important;
    border-right: 1px solid rgba(255,255,255,0.08) !important;
    border-top: none !important;
    margin-top: 0 !important;
    padding-bottom: 40px;
    width: 100% !important;
  }

  .apo-overlay .ap-tl-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(6,18,8,0.96);
    backdrop-filter: blur(12px);
  }

  /* 4. Colonne player — droite, centrée verticalement */
  .apo-overlay .apo-player-col {
    grid-area: player;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    height: 100%;
    padding: 16px 20px 24px;
    gap: 6px;
    width: 100%;
  }

  /* Cover compacte */
  .apo-overlay .apo-player-col .ap-cover-wrap {
    padding-bottom: 8px;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .apo-overlay .apo-player-col .ap-cover-inner {
    width: 190px !important;
    height: 190px !important;
  }

  /* Éléments pleine largeur dans la colonne droite */
  .apo-overlay .apo-player-col .ap-track-info,
  .apo-overlay .apo-player-col .ap-progress-wrap,
  .apo-overlay .apo-player-col .ap-controls,
  .apo-overlay .apo-player-col .ap-secondary,
  .apo-overlay .apo-player-col .ap-volume-row,
  .apo-overlay .apo-player-col .ap-zikr-section {
    width: 100%;
  }

  /* Fond flou — position fixed pour couvrir toute la fenêtre */
  .apo-overlay .apo-bg-art {
    position: fixed !important;
    grid-area: unset;
  }

  /* Light mode tablet */
  html.light-mode .apo-overlay .ap-tl-header,
  body.light-mode .apo-overlay .ap-tl-header {
    background: rgba(244,246,243,0.96);
  }
}

/* ══════════════════════════════════════════════════════════════
   LARGE DESKTOP ≥ 1100px
══════════════════════════════════════════════════════════════ */
@media (min-width: 1100px) {

  .apo-overlay {
    grid-template-columns: 1fr 420px;
  }

  .apo-overlay .apo-player-col .ap-cover-inner {
    width: 230px !important;
    height: 230px !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   DESKTOP ≥ 768px — overlay à droite de la sidebar
══════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1023px) {
  .apo-overlay {
    left: 0 !important;
  }
}

@media (min-width: 1024px) {
  .apo-overlay {
    left: var(--nt-sidebar-w, 220px) !important;
  }
}

/* ── États actifs des boutons de contrôle overlay ── */
#apo-shuffle.active,
#apo-repeat.active {
  background: rgba(142,182,155,0.12) !important;
}

#apo-shuffle.active svg,
#apo-repeat.active svg {
  color: var(--ap-mint, #8EB69B) !important;
  fill: var(--ap-mint, #8EB69B) !important;
}

#apo-speed.active {
  border-color: rgba(142,182,155,0.4) !important;
  background: rgba(142,182,155,0.1) !important;
  color: var(--ap-mint, #8EB69B) !important;
}

/* Page player fixe */
#ap-shuffle-btn.active svg,
#ap-repeat-btn.active svg {
  color: var(--ap-mint, #8EB69B) !important;
  fill: var(--ap-mint, #8EB69B) !important;
}

#ap-shuffle-btn.active,
#ap-repeat-btn.active {
  background: rgba(142,182,155,0.12) !important;
}

/* ── Loader sur le bouton play ── */
.ap-btn-play {
  position: relative;
}

.ap-btn-play.loading::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid rgba(142,182,155,0.2);
  border-top-color: #8EB69B;
  animation: ap-btn-spin 0.75s linear infinite;
  z-index: 2;
}

.ap-btn-play.loading svg {
  opacity: 0.3;
}

@keyframes ap-btn-spin {
  to { transform: rotate(360deg); }
}