/* ═══════════════════════════════════════════
   Bibliothèques – Tabs, Tables, Pagination
   ═══════════════════════════════════════════ */

/* ── Onglets ── */
.bib-tabs-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 2px solid rgba(var(--fg-rgb), 0.08);
  margin-bottom: 1rem;
}

.bib-tabs-bar .bib-tabs {
  flex: 1;
  min-width: 0;
  border-bottom: none;
  margin-bottom: 0;
}

.bib-tabs-add-account {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  margin-bottom: -2px;
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: color 150ms, border-color 150ms;
}

.bib-tabs-add-account:hover,
.bib-tabs-add-account:focus {
  color: var(--text);
  background: none;
  transform: none;
}

.bib-tabs-add-account-icon {
  display: block;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  object-fit: contain;
  opacity: 0.85;
}

.bib-tabs-add-account-label {
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.bib-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 2px solid rgba(var(--fg-rgb), 0.08);
  margin-bottom: 1rem;
}

.bib-tab {
  background: none;
  border: none;
  padding: 0.55rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 150ms, border-color 150ms;
  white-space: nowrap;
}
.bib-tab:hover { color: var(--text); }
.bib-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Onglets réordonnables (page bibliothèques personnelle) */
.bib-tabs--sortable .bib-tab {
  cursor: grab;
  user-select: none;
}
.bib-tabs--sortable .bib-tab:active {
  cursor: grabbing;
}
.bib-tab-ghost {
  opacity: 0.45;
}
.bib-tab-chosen {
  color: var(--text);
}
.bib-tab-drag {
  opacity: 0.85;
}

/* ── Zone de recherche ── */
.bib-search-zone {
  margin-bottom: 1.2rem;
}

.bib-search-zone input[type="search"] {
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(var(--fg-rgb), 0.08);
  border-radius: var(--radius);
  background: rgba(var(--fg-rgb), 0.03);
  color: var(--text);
  font-size: 0.9rem;
}
.bib-search-zone input[type="search"]:focus {
  outline: none;
  border-color: rgba(var(--fg-rgb), 0.16);
  box-shadow: 0 0 0 3px rgba(50,150,255,0.08);
}

.bib-search-zone input[type="search"]::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

#bib-search-results {
  margin-top: 0.6rem;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid rgba(var(--fg-rgb), 0.06);
  border-radius: var(--radius);
}

.bib-search-table {
  margin: 0;
}

/* ── Contenus d'onglet ── */
.bib-tab-content { display: none; }
.bib-tab-content.active { display: block; }

.bib-empty {
  color: var(--muted);
  padding: 2rem 0;
  text-align: center;
}

/* ── Barre d'actions plateforme ── */
.bib-platform-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.3rem 0 0.9rem;
}

.bib-platform-count {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.bib-platform-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.bib-platform-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bib-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  background: rgba(var(--fg-rgb), 0.05);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, opacity 120ms;
}

.bib-action-btn:hover {
  background: rgba(var(--fg-rgb), 0.1);
  border-color: rgba(var(--fg-rgb), 0.2);
}

.bib-action-btn-sync {
  background: rgba(46,168,255,0.2);
  border-color: rgba(46,168,255,0.45);
}

.bib-action-btn-sync:hover {
  background: rgba(46,168,255,0.3);
}

.bib-filter-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.bib-filter-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.bib-filter-summary-empty {
  font-size: 0.76rem;
  color: var(--muted);
}
.bib-filter-tags .bib-igdb-chip {
  cursor: pointer;
}
.bib-filter-popup {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  min-width: min(620px, 92vw);
  max-width: min(700px, 95vw);
  z-index: 30;
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(var(--fg-rgb), 0.14);
  background: #1f1f1f;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
}
.bib-filter-popup.open { display: block; }
.bib-filter-section { margin-bottom: 0.55rem; }
.bib-filter-section:last-child { margin-bottom: 0; }
.bib-filter-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}
.bib-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}
.bib-filter-actions {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(var(--fg-rgb), 0.1);
  display: flex;
  gap: 0.45rem;
}
.bib-filter-btn {
  border: 1px solid rgba(var(--fg-rgb), 0.16);
  background: rgba(var(--fg-rgb), 0.06);
  color: var(--text);
  border-radius: 6px;
  padding: 0.28rem 0.62rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.bib-filter-btn:hover {
  background: rgba(var(--fg-rgb), 0.1);
}

.bib-action-btn.is-disabled,
.bib-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Tableau ── */
.bib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.bib-table th,
.bib-table td {
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(var(--fg-rgb), 0.07);
  vertical-align: middle;
}

.bib-table thead th {
  background: rgba(var(--fg-rgb), 0.03);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  user-select: none;
}

.bib-table thead th.col-max-players {
  white-space: normal;
  line-height: 1.05;
  font-size: 0.68rem;
  text-align: center;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.bib-table tbody tr:hover {
  background: rgba(var(--fg-rgb), 0.02);
}

/* sortable headers */
.sortable { cursor: pointer; }
.sortable:hover { color: var(--text); }
.sort-arrow {
  display: inline-block;
  font-size: 0.7rem;
  margin-left: 0.2rem;
  opacity: 0.5;
}
.sortable.asc .sort-arrow::after  { content: '▲'; }
.sortable.desc .sort-arrow::after { content: '▼'; }
.sortable.asc .sort-arrow,
.sortable.desc .sort-arrow { opacity: 1; }

/* ── Colonnes ── */
.col-fav      { width: 40px; text-align: center; }
.col-mod,
.col-del      { width: 44px; text-align: center; }
.col-remove   { width: 36px; text-align: center; }
.col-cover    { width: 80px; text-align: center; vertical-align: middle; }
.col-name     { min-width: 140px; }
.col-account  { width: 46px; text-align: center; }
.col-playtime { width: 100px; text-align: center; }
.col-platform { width: 50px; text-align: center; }
.col-friends  { width: 130px; }
.col-note     { width: 80px; text-align: center; }
.col-vis      { width: 76px; text-align: center; }
.col-max-players { width: 56px; min-width: 56px; max-width: 56px; text-align: center; }

.bib-table td.col-max-players {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

/* ── Jaquette ── */
.game-cover-link {
  display: block;
  margin: 0 auto;
  line-height: 0;
  border-radius: 4px;
  transition: opacity 120ms, box-shadow 120ms;
}
.game-cover-link:hover {
  opacity: 0.85;
  box-shadow: 0 0 0 2px var(--accent);
}
.game-cover {
  max-height: 80px;
  max-width: 56px;
  width: auto;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}

.bib-table td.col-cover {
  padding: 4px 6px;
}

/* ── Lien nom de jeu ── */
.game-link {
  color: var(--text);
  text-decoration: none;
  transition: color 120ms;
}
.game-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Icône plateforme ── */
.platform-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* ── Bouton favoris ── */
.btn-toggle-fav {
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 120ms;
}
.btn-toggle-fav:hover { background: rgba(var(--fg-rgb), 0.06); }

/* ── Bouton note ── */
.btn-edit-note {
  background: none;
  border: 0;
  padding: 2px 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
  border-radius: 4px;
  transition: background 120ms;
}
.btn-edit-note:hover { background: rgba(var(--fg-rgb), 0.06); }

.note-value {
  font-variant-numeric: tabular-nums;
}

/* ── Grille amis ── */
.friends-grid {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 3px;
  position: relative;
}

.friend-link {
  display: block;
  width: 32px;
  height: 32px;
  line-height: 0;
  overflow: hidden;
  border-radius: 50%;
}

.friend-avatar {
  width: 32px;
  height: 32px;
  object-fit: cover;
  display: block;
}

.friend-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(46,168,255,0.25);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.friend-more-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px dashed var(--muted);
  background: rgba(var(--fg-rgb), 0.04);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms;
}
.friend-more-btn:hover {
  background: rgba(var(--fg-rgb), 0.08);
  color: var(--text);
}

.friends-expanded {
  display: grid !important;
  grid-template-columns: repeat(3, 32px);
  gap: 3px;
  margin-top: 4px;
}

/* ── Popup note ── */
.note-popup {
  position: fixed;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  border-radius: var(--radius);
  padding: 0.75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 180px;
}

.note-popup-inner label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.note-popup-inner input[type="number"] {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
}

.note-popup-actions {
  display: flex;
  gap: 0.35rem;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.note-popup .btn-primary   { background: rgba(35,35,35,0.8); color: #fff; }
.note-popup .btn-secondary { background: rgba(var(--fg-rgb), 0.08); color: var(--text); }
.note-popup .btn-danger    { background: rgba(220,60,60,0.2); color: #e55; }
.note-popup .btn-primary:hover   { filter: brightness(1.15); }
.note-popup .btn-secondary:hover { background: rgba(var(--fg-rgb), 0.14); }
.note-popup .btn-danger:hover    { background: rgba(220,60,60,0.35); }

.playtime-popup {
  min-width: 300px;
  max-width: min(100vw - 24px, 380px);
}

.playtime-popup-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.35rem;
}
.playtime-popup-row #playtime-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(var(--fg-rgb), 0.12);
  background: rgba(0,0,0,0.2);
  color: inherit;
}
/* <select> : styles par défaut globaux (forms.css) — pas de fond transparent ici */
.playtime-popup-row #playtime-unite {
  min-width: 120px;
  flex-shrink: 0;
}
.playtime-popup .playtime-help {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.35;
}
.delete-game-message {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ── Pagination ── */
.bib-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  flex-wrap: wrap;
}

.bib-pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.bib-pagination-pages button {
  background: rgba(var(--fg-rgb), 0.05);
  border: 1px solid rgba(var(--fg-rgb), 0.1);
  color: var(--text);
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  min-width: 30px;
  transition: background 120ms;
}
.bib-pagination-pages button:hover { background: rgba(var(--fg-rgb), 0.1); }
.bib-pagination-pages button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.bib-pagination-pages button:disabled {
  opacity: 0.4;
  cursor: default;
}

.bib-pagination-size {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.bib-size-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.bib-size-select {
  padding: 0.2rem 0.4rem;
  border: 1px solid rgba(var(--fg-rgb), 0.04);
  border-radius: 4px;
  background: #1f1f1f;
  color: var(--text);
  color-scheme: dark;
  font-size: 0.78rem;
  cursor: pointer;
}
.bib-size-select:focus {
  outline: none;
  border-color: rgba(var(--fg-rgb), 0.14);
  box-shadow: 0 0 0 2px rgba(var(--fg-rgb), 0.05);
}

.bib-size-select option,
.bib-size-select optgroup {
  background-color: #1f1f1f;
  color: #f5f5f5;
}

.bib-size-select option:hover,
.bib-size-select option:focus,
.bib-size-select option:checked {
  background-color: #2a2a2a;
  color: #f5f5f5;
}

/* ── Avatar compte ── */
.account-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

.account-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--fg-rgb), 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* ── Bouton supprimer favori ── */
.btn-remove-fav {
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 120ms, background 120ms;
}
.btn-remove-fav:hover { opacity: 1; background: rgba(220,60,60,0.12); }

/* ── Visibilité range (dans les tableaux) ── */
.bib-visibility-range {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.bib-visibility-range .vis-range-label {
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1;
}

.label-text.label-0 { color: var(--vis-prive); }
.label-text.label-1 { color: var(--vis-ami); }
.label-text.label-2 { color: var(--vis-public); }

.bib-vis-range {
  -webkit-appearance: none;
  appearance: none;
  width: 42px;
  height: 14px;
  background: rgba(var(--fg-rgb), 0.06);
  border-radius: 10px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
}

.bib-vis-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffd8b5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.bib-vis-range::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffd8b5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.bib-vis-range[data-step="1"]::-webkit-slider-thumb { background: var(--vis-prive); }
.bib-vis-range[data-step="2"]::-webkit-slider-thumb { background: var(--vis-ami); }
.bib-vis-range[data-step="3"]::-webkit-slider-thumb { background: var(--vis-public); }
.bib-vis-range[data-step="1"]::-moz-range-thumb { background: var(--vis-prive); }
.bib-vis-range[data-step="2"]::-moz-range-thumb { background: var(--vis-ami); }
.bib-vis-range[data-step="3"]::-moz-range-thumb { background: var(--vis-public); }

.bib-vis-range:focus { box-shadow: 0 0 0 3px rgba(0,0,0,0.04); }

/* ── Métadonnées IGDB (genres / thèmes / modes / multijoueur) ── */
.bib-name-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
  max-width: 28rem;
  font-size: 0.93rem; /* Titre du jeu légèrement plus lisible */
}
.bib-igdb-meta {
  font-size: 0.72rem; /* Libellés + libellés des tags plus compacts */
  line-height: 1.35;
  color: var(--muted, #9aa0a6);
  width: 100%;
}
.bib-igdb-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
  margin-top: 0.15rem;
}
.bib-igdb-meta-label {
  font-weight: 600;
  color: var(--text, #e8e8e8);
  opacity: 0.85;
  margin-right: 0.15rem;
  font-size: 0.72rem;
}
.bib-igdb-chip {
  display: inline-block;
  padding: 0.07rem 0.4rem;
  border-radius: 999px;
  background: rgba(var(--fg-rgb), 0.06);
  border: 1px solid rgba(var(--fg-rgb), 0.1);
  font-size: 0.66rem;
}

/* Filtres : état sélectionné — même vert que le libellé « Public » (--vis-public), après .bib-igdb-chip pour gagner la cascade */
.bib-igdb-chip.bib-filter-chip-selected,
.bib-filter-tags .bib-igdb-chip.bib-filter-popup-tag-selected {
  background: var(--vis-public);
  border-color: var(--vis-public);
  color: #0d0d0d;
  font-weight: 700;
}
.bib-igdb-mp-block {
  flex-direction: column;
  align-items: stretch;
}
.bib-igdb-mp-card {
  margin-top: 0.35rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(var(--fg-rgb), 0.08);
}
.bib-igdb-mp-title {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text, #e8e8e8);
  margin-bottom: 0.2rem;
}
.bib-igdb-mp-list {
  margin: 0;
  padding-left: 1rem;
}
.bib-igdb-mp-list li {
  margin: 0.1rem 0;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .bib-tabs-bar { flex-wrap: wrap; align-items: stretch; gap: 0.65rem; }
  .bib-tabs { gap: 0; overflow-x: auto; flex-wrap: nowrap; }
  .bib-tabs-add-account { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
  .bib-tabs-add-account-icon { width: 14px; height: 14px; }
  .bib-tab  { font-size: 0.8rem; padding: 0.4rem 0.65rem; }
  .bib-platform-actions { flex-direction: column; align-items: flex-start; }
  .bib-table { font-size: 0.8rem; }
  .col-friends { width: 70px; }
  .friends-grid { grid-template-columns: repeat(2, 28px); }
  .friend-link { width: 28px; height: 28px; }
  .friend-avatar, .friend-avatar-placeholder, .friend-more-btn { width: 28px; height: 28px; }
}
