/* ============================================================================
   Liseuse v2 — css/panels.css : styles du module panels.js
   ----------------------------------------------------------------------------
   Panneaux (TDM, marque-pages, préférences), barre de recherche flottante,
   modales (partage, partage d'annotations, Anna's Archive, fiche livre).
   Tokens EXCLUSIVEMENT hérités de v2.css (var(--acc), --glass-*, --stroke,
   --r-*, --shadow-*, --display, --ui, --paper…). Icônes SVG héritent de
   currentColor. Cibles tactiles ≥44px. Cohérent avec le design de verre.
   ========================================================================== */

/* ─────────────────────────── vide de panneau/modale ─────────────────── */
.panel-empty {
  text-align: center; color: var(--text-3); font-size: 14px;
  padding: 34px 16px; line-height: 1.5;
}

/* ═════════════════════════ B. Table des matières ═════════════════════ */
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { margin: 0; }
.toc-item {
  display: block; width: 100%; text-align: left;
  min-height: 44px; padding: 10px 12px; border-radius: var(--r-s);
  color: var(--text-2); font-size: 14px; line-height: 1.4;
  transition: all .15s var(--ease);
}
.toc-item:hover { background: var(--glass-1); color: var(--text); }
.toc-item--sub {
  padding-left: 26px; font-size: 13.5px; color: var(--text-3);
  position: relative;
}
.toc-item--sub::before {
  content: ''; position: absolute; left: 13px; top: 50%; width: 6px; height: 1px;
  background: var(--stroke-lit); transform: translateY(-50%);
}

/* ═════════════════════════ C. Marque-pages ═══════════════════════════ */
.bm-add {
  width: 100%; justify-content: center; margin-bottom: 16px;
}
.bm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bm-row {
  display: flex; align-items: stretch; gap: 6px;
  border-radius: var(--r-m); background: var(--glass-1); border: 1px solid var(--stroke);
  overflow: hidden; transition: border-color .15s var(--ease);
}
.bm-row:hover { border-color: var(--stroke-lit); }
.bm-go {
  flex: 1; min-width: 0; text-align: left; padding: 11px 13px;
  display: flex; flex-direction: column; gap: 3px; min-height: 44px;
}
.bm-go__label {
  color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bm-go__date { color: var(--text-3); font-size: 12px; }
.bm-del {
  width: 44px; flex-shrink: 0; border-radius: 0; border: 0;
  background: transparent; color: var(--text-3);
}
.bm-del:hover { background: rgba(248, 113, 113, .14); color: var(--err); transform: none; }

/* ═════════════════════════ D. Préférences de lecture ═════════════════ */
.set-label {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin: 20px 2px 10px;
}
.set-label:first-child { margin-top: 4px; }

/* vignettes de thème */
.set-themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 8px 10px; border-radius: var(--r-m);
  background: var(--glass-1); border: 1px solid var(--stroke);
  transition: all .18s var(--ease); min-height: 44px;
}
.theme-swatch:hover { border-color: var(--stroke-lit); transform: translateY(-1px); }
.theme-swatch[aria-pressed="true"] {
  border-color: rgba(139, 92, 246, .55);
  box-shadow: var(--shadow-acc), inset 0 0 0 1px rgba(139, 92, 246, .3);
}
.theme-swatch__demo {
  width: 100%; height: 52px; border-radius: var(--r-s);
  display: grid; place-items: center;
  font-family: var(--display); font-size: 20px; font-weight: 600;
  box-shadow: var(--shadow-1);
}
.theme-swatch__label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.theme-swatch[aria-pressed="true"] .theme-swatch__label { color: var(--text); }

/* pas à pas taille du texte */
.set-stepper {
  display: flex; align-items: center; gap: 12px;
  background: var(--glass-1); border: 1px solid var(--stroke); border-radius: var(--r-m);
  padding: 8px 12px;
}
.set-step { font-size: 22px; font-weight: 500; }
.set-stepper__val {
  flex: 1; text-align: center; font-family: var(--display);
  font-size: 18px; font-weight: 600; color: var(--text);
}

/* choix de police */
.set-fonts, .set-cols { display: flex; gap: 8px; }
.font-choice {
  flex: 1; min-height: 46px; border-radius: var(--r-m);
  background: var(--glass-1); border: 1px solid var(--stroke);
  color: var(--text-2); font-size: 15px; font-weight: 600;
  transition: all .16s var(--ease);
}
.font-choice:hover { border-color: var(--stroke-lit); color: var(--text); }
.font-choice[aria-pressed="true"] {
  color: #fff; background: var(--acc-soft);
  border-color: rgba(139, 92, 246, .5); box-shadow: inset 0 0 16px rgba(139, 92, 246, .12);
}

/* colonnes PDF */
.col-choice {
  flex: 1; min-height: 46px; border-radius: var(--r-m);
  background: var(--glass-1); border: 1px solid var(--stroke);
  color: var(--text-2); font-size: 16px; font-weight: 700;
  transition: all .16s var(--ease);
}
.col-choice:hover { border-color: var(--stroke-lit); color: var(--text); }
.col-choice[aria-pressed="true"] {
  color: #fff; background: var(--acc-soft);
  border-color: rgba(139, 92, 246, .5); box-shadow: inset 0 0 16px rgba(139, 92, 246, .12);
}
.set-hint { color: var(--text-3); font-size: 12.5px; margin: 10px 2px 4px; line-height: 1.5; }

/* ═════════════════════════ E. Recherche dans le livre ════════════════ */
.book-search {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 22; width: min(560px, calc(100% - 28px));
  display: grid; grid-template-columns: auto 1fr auto auto auto auto;
  align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--glass-3); backdrop-filter: var(--blur-3); -webkit-backdrop-filter: var(--blur-3);
  border: 1px solid var(--stroke-lit); border-radius: var(--r-l);
  box-shadow: var(--shadow-3);
  animation: bs-drop .24s var(--ease) both;
}
@keyframes bs-drop { from { opacity: 0; transform: translate(-50%, -12px); } }
.book-search[hidden] { display: none !important; }
.book-search__icon { display: inline-flex; color: var(--text-3); padding-left: 4px; }
.book-search__icon svg { width: 18px; height: 18px; }
.book-search__input {
  min-height: 40px; padding: 0 8px; background: transparent; border: 0;
  color: var(--text); font-size: 14.5px; min-width: 0;
}
.book-search__input:focus { outline: none; }
.book-search__count {
  font-size: 12.5px; font-weight: 600; color: var(--text-3);
  padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.book-search__nav, .book-search__close { width: 40px; height: 40px; }
.book-search__results {
  grid-column: 1 / -1; list-style: none; margin: 6px 0 0; padding: 0;
  max-height: min(46vh, 340px); overflow-y: auto; scrollbar-width: thin;
}
.book-search__results:empty { display: none; }
.book-search__res {
  padding: 10px 12px; border-radius: var(--r-s); cursor: pointer;
  color: var(--text-2); font-size: 13.5px; line-height: 1.5;
  border-bottom: 1px solid var(--stroke);
}
.book-search__res:last-child { border-bottom: 0; }
.book-search__res:hover { background: var(--glass-1); color: var(--text); }
.book-search__res.is-current {
  background: var(--acc-soft); color: var(--text);
  box-shadow: inset 3px 0 0 var(--acc);
}
.book-search__loading { padding: 14px 12px; color: var(--text-3); font-size: 13.5px; text-align: center; }

/* ═════════════════════════ F. Modale Partager ════════════════════════ */
.share-opts { display: flex; flex-direction: column; gap: 8px; }
.share-opt {
  display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 13px 15px; min-height: 44px; border-radius: var(--r-m);
  background: var(--glass-1); border: 1px solid var(--stroke);
  transition: all .16s var(--ease);
}
.share-opt:hover { border-color: var(--stroke-lit); background: var(--glass-2); }
.share-opt.is-active { border-color: rgba(139, 92, 246, .5); box-shadow: inset 0 0 0 1px rgba(139, 92, 246, .3); }
.share-opt.is-loading { opacity: .6; pointer-events: none; }
.share-opt__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px;
  background: var(--acc-soft); color: var(--acc);
}
.share-opt__icon svg { width: 20px; height: 20px; }
.share-opt__txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.share-opt__txt b { font-size: 14.5px; color: var(--text); font-weight: 600; }
.share-opt__txt small { font-size: 12.5px; color: var(--text-3); }

.share-result { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.share-link-row { display: flex; gap: 8px; align-items: center; }
.share-link {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 14px;
  background: rgba(0, 0, 0, .28); border: 1px solid var(--stroke); border-radius: 13px;
  color: var(--text-2); font-size: 13.5px; font-family: var(--ui);
}
.share-link:focus { border-color: var(--acc); outline: none; color: var(--text); }
.share-expiry { color: var(--text-3); font-size: 12.5px; margin: 10px 2px 14px; }
.share-channels { display: flex; flex-wrap: wrap; gap: 8px; }
.share-channels .btn { flex: 1 1 auto; justify-content: center; min-width: 130px; }
.share-channels .btn svg { width: 18px; height: 18px; }

/* ═════════════════════ G. Partage d'annotations ═════════════════════ */
.share-ann__intro { color: var(--text-2); font-size: 14px; line-height: 1.55; margin: 0 0 16px; }
.share-ann__list { display: flex; flex-direction: column; gap: 8px; }
.share-ann__row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; min-height: 44px; border-radius: var(--r-m);
  background: var(--glass-1); border: 1px solid var(--stroke); cursor: pointer;
  transition: border-color .15s var(--ease);
}
.share-ann__row:hover { border-color: var(--stroke-lit); }
.share-ann__who { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.avatar--sm { width: 34px; height: 34px; font-size: 12px; }
.share-ann__id { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.share-ann__id b { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-ann__id small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-ann__toggle {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 46px; height: 28px; border-radius: 999px; cursor: pointer;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--stroke);
  position: relative; transition: all .2s var(--ease);
}
.share-ann__toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--text-2); transition: all .2s var(--spring);
}
.share-ann__toggle:checked { background: var(--acc-soft); border-color: rgba(139, 92, 246, .5); }
.share-ann__toggle:checked::after { left: 20px; background: var(--acc); }
.share-ann__toggle:disabled { opacity: .5; }

/* ═════════════════════ H. Anna's Archive ════════════════════════════ */
.aa__form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.aa__q {
  width: 100%; min-height: 48px; padding: 0 16px;
  background: rgba(0, 0, 0, .28); border: 1px solid var(--stroke); border-radius: 13px;
  color: var(--text); font-size: 15px;
}
.aa__q:focus { border-color: var(--acc); outline: none; }
.aa__filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.aa__filter {
  display: flex; flex-direction: column; gap: 5px; flex: 1 1 120px;
  font-size: 12px; font-weight: 600; color: var(--text-3);
}
.aa__filter select { min-height: 44px; width: 100%; }
.aa__go { flex: 0 0 auto; min-width: 130px; justify-content: center; }
.aa__go svg { width: 18px; height: 18px; }

.aa-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.aa-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-m);
  background: var(--glass-1); border: 1px solid var(--stroke);
  transition: border-color .15s var(--ease);
}
.aa-row:hover { border-color: var(--stroke-lit); }
.aa-row__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.aa-row__meta b { font-size: 14.5px; color: var(--text); font-weight: 600; line-height: 1.35; }
.aa-row__author { font-size: 13px; color: var(--text-2); }
.aa-row__bits { font-size: 12px; color: var(--text-3); }
.aa-row__ext { flex-shrink: 0; }

/* ═════════════════════ I. Fiche livre ═══════════════════════════════ */
.book-sheet__top { display: flex; gap: 20px; align-items: flex-start; }
.book-sheet__cover {
  width: 132px; flex-shrink: 0; aspect-ratio: 2 / 3; border-radius: var(--r-m);
  overflow: hidden; position: relative;
  background: linear-gradient(155deg, #453973, #221e40 70%); box-shadow: var(--shadow-2);
}
.book-sheet__cover[data-kind="pdf"] { background: linear-gradient(155deg, #7a4a33, #33201a 70%); }
.book-sheet__cover[data-kind="audio"] { background: linear-gradient(155deg, #1f5f6b, #122831 70%); }
.book-sheet__cover[data-kind="bd"] { background: linear-gradient(155deg, #8a5a2a, #3a2413 70%); }
.book-sheet__cover[data-kind="texte"], .book-sheet__cover[data-kind="docx"] { background: linear-gradient(155deg, #4a6141, #1f2b1a 70%); }
.book-sheet__cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-sheet__ph {
  position: absolute; inset: 0; display: none; padding: 14px;
  align-items: flex-end; font-family: var(--display); font-weight: 600; font-size: 14px;
  color: rgba(255, 255, 255, .85); line-height: 1.3;
}
.book-sheet__cover.no-img .book-sheet__ph { display: flex; }

.book-sheet__info { flex: 1; min-width: 0; }
.book-sheet__title { font-family: var(--display); font-size: 23px; font-weight: 600; margin: 0 0 4px; line-height: 1.2; }
.book-sheet__author { color: var(--text-2); font-size: 15px; margin: 0 0 14px; }
.book-sheet__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 16px; }
.book-sheet__facts div { min-width: 0; }
.book-sheet__facts dt { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 2px; }
.book-sheet__facts dd { margin: 0; font-size: 14px; color: var(--text); }
.book-sheet__prog { margin-bottom: 16px; }
.book-sheet__bar {
  display: block; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, .1);
  position: relative; overflow: hidden; margin-bottom: 6px;
}
.book-sheet__bar::after { content: ''; position: absolute; inset: 0; width: var(--p, 0%); background: var(--grad-acc); border-radius: 5px; }
.book-sheet__prog small { color: var(--text-3); font-size: 12.5px; }
.book-sheet__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.book-sheet__actions .btn { flex: 1 1 auto; justify-content: center; min-width: 150px; }
.book-sheet__actions .btn svg { width: 18px; height: 18px; }

.book-sheet__ai:not(:empty) { margin-top: 22px; }
.book-sheet__summary, .book-sheet__suggest { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.book-sheet__ai-label {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--acc); margin: 0 0 8px;
}
.book-sheet__ai-text { color: var(--text-2); font-size: 14px; line-height: 1.6; margin: 0; }
.book-sheet__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-chip { text-align: left; }

/* ═════════════════════════ RESPONSIVE ═══════════════════════════════ */
@media (max-width: 640px) {
  .book-search {
    top: 8px; left: 8px; right: 8px; transform: none; width: auto;
    grid-template-columns: auto 1fr auto auto auto;
  }
  @keyframes bs-drop { from { opacity: 0; transform: translateY(-10px); } }
  /* la barre mobile masque les 2 flèches distinctes au profit du compteur */
  .book-search__nav { width: 40px; height: 40px; }

  .book-sheet__top { flex-direction: column; align-items: center; text-align: center; }
  .book-sheet__cover { width: 148px; }
  .book-sheet__facts { grid-template-columns: 1fr 1fr; text-align: left; }
  .book-sheet__actions .btn { min-width: 0; flex: 1 1 100%; }
  .share-channels .btn { flex: 1 1 100%; }
}
