/* ── Reset & variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface2: #ededf2;
  --accent: #6366f1;
  --accent2: #4f46e5;
  --text: #111118;
  --text-muted: #7b7b8e;
  --border: #e0e0ea;
  --radius: 10px;
  --poster-w: 160px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.header-nav {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 10px;
}

/* ── Tabs ── */
.tabs {
  display: inline-flex;
  background: var(--surface2);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.tab.active {
  background: var(--accent);
  color: #fff;
}

/* ── Boutons ── */
.btn-add {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-add:hover { background: #4f46e5; }

.btn-login {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-login:hover { border-color: var(--accent); color: var(--accent); }
.btn-login.btn-logout { color: #dc2626; border-color: #fca5a5; }
.btn-login.btn-logout:hover { background: #fef2f2; border-color: #dc2626; }

.livraddict-link {
  display: inline-block;
  font-size: 0.88rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.livraddict-link:hover { text-decoration: underline; }

/* ── Stats bar ── */
.stats-bar {
  max-width: 1400px;
  margin: 24px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
  border: 1px solid var(--border);
}
.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent2);
  line-height: 1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Filtres ── */
.filters {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.filters input, .filters select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.filters input { flex: 1; min-width: 200px; }
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.filters select option { background: var(--surface2); }

/* ── Grille ── */
.grid {
  max-width: 1400px;
  margin: 24px auto 60px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--poster-w), 1fr));
  gap: 20px;
}
.loading, .empty {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-muted);
  padding: 80px 0;
  font-size: 1.1rem;
}

/* ── Carte ── */
.movie-card {
  cursor: pointer;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.movie-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.12);
}
.movie-card img {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
}
.movie-card .no-poster {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}
.movie-card .card-info { padding: 10px; }
.movie-card .card-title {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.movie-card .card-sub {
  font-size: 0.72rem;
  color: var(--accent2);
  margin-top: 2px;
  font-weight: 600;
}
.movie-card .card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.movie-card .card-rating { color: #b45309; font-weight: 700; }
.movie-card .btn-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0,0,0,0.45);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.movie-card:hover .btn-delete { display: flex; }
.movie-card .btn-delete:hover { background: var(--accent); }

/* Badge type série */
.card-type-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,0.5);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.5px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid var(--border);
}
.modal h2 { font-size: 1.2rem; margin-bottom: 20px; }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }

/* Recherche TMDB */
.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.search-box input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.95rem;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}
.search-box button:hover { background: #4f46e5; }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
}
.result-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.result-item:hover { border-color: var(--accent); }
.result-item img {
  width: 44px;
  height: 66px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface2);
  flex-shrink: 0;
}
.result-item .result-info { display: flex; flex-direction: column; gap: 3px; }
.result-item .result-title { font-weight: 600; font-size: 0.9rem; }
.result-item .result-year { font-size: 0.8rem; color: var(--text-muted); }

/* Lignes import watchlist (pas cliquables) */
.import-row { cursor: default; }
.import-row:hover { border-color: transparent; }
.import-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.8rem;
  color: var(--text);
  outline: none;
}
.btn-remove-import {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 8px;
  flex-shrink: 0;
}
.btn-remove-import:hover { color: #dc2626; }

/* Sélecteur de saison */
.season-picker {
  margin: 14px 0;
}
.season-picker label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.season-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.season-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.season-btn:hover, .season-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

/* Film/série sélectionné */
.selected-movie { margin-top: 16px; }
.selected-info {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}
.selected-info img { width: 50px; height: 75px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.selected-info strong { display: block; font-size: 1rem; }
.selected-info span { font-size: 0.85rem; color: var(--text-muted); }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-row input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
  color-scheme: dark;
}
.form-row input[type="date"]:focus { border-color: var(--accent); }

/* Étoiles */
.stars { display: flex; gap: 6px; flex-wrap: wrap; }
.star-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.star-btn:hover, .star-btn.active {
  background: #b45309;
  color: #000;
  border-color: #b45309;
  font-weight: 700;
}

.btn-confirm {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}
.btn-confirm:hover { background: #4f46e5; }

/* Modal détail */
.modal-detail { max-width: 480px; }
.detail-content { display: flex; flex-direction: column; gap: 16px; }
.detail-poster {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: 8px;
}
.detail-title { font-size: 1.4rem; font-weight: 700; }
.detail-sub { font-size: 1rem; color: var(--accent2); font-weight: 600; }
.detail-meta { font-size: 0.85rem; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.detail-rating { font-size: 1.1rem; color: #b45309; font-weight: 700; }
.detail-actions { display: flex; gap: 10px; }
.detail-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-edit-rating { background: var(--surface2); color: var(--text); border: 1px solid var(--border) !important; }
.btn-edit-rating:hover { border-color: var(--accent) !important; }
.btn-del-item { background: var(--accent); color: #fff; }
.btn-del-item:hover { background: #4f46e5; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

/* Responsive */
@media (max-width: 600px) {
  :root { --poster-w: 130px; }
  .header-right { gap: 10px; }
  .tab { padding: 5px 10px; font-size: 0.8rem; }
  .stats-bar { gap: 10px; }
  .stat-card { padding: 12px 16px; min-width: 100px; }
  .stat-number {
/* ── Sélecteur de couverture par édition (livres) ── */
.edition-picker { margin-top: 14px; }
.edition-picker-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.edition-picker-covers {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.edition-cover-btn {
  flex: 0 0 auto;
  width: 82px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s, transform 0.15s;
}
.edition-cover-btn:hover { transform: translateY(-2px); }
.edition-cover-btn.active { border-color: var(--accent); }
.edition-cover-btn img {
  width: 100%;
  height: 106px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.edition-cover-btn span {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.edition-cover-btn.active span { color: var(--accent); font-weight: 600; }

/* ── Bookmarklet Livraddict ── */
.bookmarklet-tip {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.9;
}
.bookmarklet-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: grab;
  margin: 0 4px;
}
.bookmarklet-btn:active { cursor: grabbing; }
.bookmarklet-hint { font-size: 0.78rem; }
.book-url-fallback { margin-top: 14px; }
.book-url-fallback summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}
