/* ═══════════════════════════════════════════════════════════════
   VIEW TOGGLE — Boutons liste / carte
   À ajouter à la fin de playlist_page.css
═══════════════════════════════════════════════════════════════ */

/* ── Boutons toggle dans pl-fbar ── */
.pl-view-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 8px;
}

.pl-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.pl-view-btn:hover {
  background: rgba(142,182,155,0.08);
  color: rgba(255,255,255,0.7);
}
.pl-view-btn.active {
  background: rgba(142,182,155,0.12);
  border-color: rgba(142,182,155,0.25);
  color: #8EB69B;
}
body.light-mode .pl-view-btn {
  color: rgba(0,0,0,0.35);
}
body.light-mode .pl-view-btn.active {
  color: #235347;
  background: rgba(35,83,71,0.1);
  border-color: rgba(35,83,71,0.2);
}

/* ═══════════════════════════════════════════════════════════════
   MODE CARTE — grille responsive
═══════════════════════════════════════════════════════════════ */

#pl-list.pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 12px 16px 0;
}

/* ── Carte item ── */
#pl-list.pl-grid .pl-item {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  gap: 0;
  border-radius: 12px;
  border-bottom: none;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  cursor: pointer;
}
#pl-list.pl-grid .pl-item:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(142,182,155,0.2);
  transform: translateY(-2px);
}
#pl-list.pl-grid .pl-item.playing {
  border-color: rgba(142,182,155,0.4);
  background: rgba(142,182,155,0.08);
}
body.light-mode #pl-list.pl-grid .pl-item {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}

/* ── Zone aperçu (haut de la carte) ── */
.pl-card-preview {
  width: 100%;
  aspect-ratio: 5/3;  /* ← était 3/4, on inverse pour moins de hauteur */
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: flex-start;  /* ← aligner en haut pour voir le début de la page */
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

body.light-mode .pl-card-preview {
  background: rgba(0,0,0,0.04);
  border-bottom-color: rgba(0,0,0,0.06);
}

/* Canvas PDF.js */
.pl-card-preview canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  display: block;
}

/* Icône audio dans la carte */
.pl-card-audio-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  color: rgba(142,182,155,0.45);
}
.pl-card-audio-icon svg {
  opacity: 0.6;
}
.pl-card-audio-icon .pl-card-dur {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
body.light-mode .pl-card-audio-icon {
  color: rgba(35,83,71,0.4);
}
body.light-mode .pl-card-audio-icon .pl-card-dur {
  color: rgba(0,0,0,0.4);
}

/* Badge "En lecture" sur la carte */
#pl-list.pl-grid .pl-item.playing .pl-card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(142,182,155,0.12);
  pointer-events: none;
}

/* Equalizer animé sur la carte quand playing */
.pl-card-eq {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}
#pl-list.pl-grid .pl-item.playing .pl-card-eq {
  display: flex;
}

/* ── Infos bas de carte ── */
.pl-card-info {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pl-card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--pl-tx, #e8eaed);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}
#pl-list.pl-grid .pl-item.playing .pl-card-title {
  color: #8EB69B;
}
.pl-card-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.light-mode .pl-card-title { color: #1a2e20; }
body.light-mode .pl-card-meta  { color: rgba(0,0,0,0.4); }

/* Cacher les éléments liste dans la carte */
#pl-list.pl-grid .pl-item-num,
#pl-list.pl-grid .pl-item-eq,
#pl-list.pl-grid .pl-item-icon,
#pl-list.pl-grid .pl-item-info,
#pl-list.pl-grid .pl-item-right {
  display: none !important;
}

/* ── Spinner de chargement PDF dans la carte ── */
.pl-card-pdf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pl-card-pdf-spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(142,182,155,0.2);
  border-top-color: #8EB69B;
  animation: pl-spin 0.75s linear infinite;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* ── Icône PDF fallback si erreur ── */
.pl-card-pdf-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.25);
}
.pl-card-pdf-fallback svg { opacity: 0.5; }
.pl-card-pdf-fallback span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ── Responsive mobile ── */
@media (max-width: 600px) {
  #pl-list.pl-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 8px 0;
  }
  .pl-card-title { font-size: 11px; }
}

@media (max-width: 520px) {
  .pl-view-toggle {
    margin-left: 0;
    margin-right: auto;
  }
}
