*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F5F5F8;
  --surface: #FFFFFF;
  --surface2: #EDEDF3;
  --accent: #7C3AED;
  --accent2: #5B21B6;
  --text: #18181B;
  --text-muted: #71717A;
  --border: #E4E4E7;
  --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;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── 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: #6D28D9; }

.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: var(--accent2); border-color: var(--accent2); }
.btn-login.btn-logout:hover { background: rgba(124,58,237,0.08); border-color: var(--accent); }

/* ── Stats ── */
.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: 110px;
  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; }

/* ── Listes (tabs) ── */
.lists-bar {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.list-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}
.list-tab:hover { border-color: var(--accent); color: var(--accent); }
.list-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.list-tab-img {
  width: 18px; height: 18px;
  border-radius: 50%;
  object-fit: cover;
}
.list-edit {
  opacity: 0.6;
  font-size: 0.75rem;
  padding: 2px;
}
.list-edit:hover { opacity: 1; }
.list-tab-add {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
}
.list-tab-add:hover { border-color: var(--accent); color: var(--accent); }

/* ── 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); }

.btn-toggle-view {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
}
.btn-toggle-view:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-toggle-view.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── 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(124,58,237,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-year {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.movie-card .btn-delete,
.movie-card .btn-watched {
  position: absolute;
  background: rgba(0,0,0,0.55);
  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 .btn-delete  { top: 6px; right: 6px; }
.movie-card .btn-watched { top: 6px; right: 38px; font-size: 0.85rem; }
.movie-card:hover .btn-delete,
.movie-card:hover .btn-watched  { display: flex; }
.movie-card .btn-delete:hover  { background: #7f1d1d; }
.movie-card .btn-watched:hover { background: #166534; }

.card-type-badge {
  position: absolute;
  top: 6px; left: 6px;
  background: rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  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); }

/* Tabs Film/Série dans la modal */
.type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 4px;
}
.type-tab {
  flex: 1;
  background: none; border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.type-tab.active { background: var(--accent); color: #fff; }

/* Recherche */
.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: #6D28D9; }

.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); }

/* Item 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); }

/* Bouton confirmer */
.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: #6D28D9; }

/* Login */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block; font-size: 0.82rem;
  color: var(--text-muted); margin-bottom: 6px;
}
.input-pwd {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 10px 14px;
  font-size: 0.95rem; outline: none; margin-top: 4px;
}
.input-pwd:focus { border-color: var(--accent); }

/* Select liste sur les cartes / modal */
.card-list-select {
  width: 100%;
  margin-top: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 0.72rem;
  outline: none;
}
#addToList {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.9rem;
  outline: none;
}

/* Modal liste */
.list-image-preview-wrap { margin: 6px 0; }
.list-image-preview {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.btn-delete-list {
  width: 100%;
  background: none;
  border: 1px solid #dc2626;
  color: #dc2626;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.2s;
}
.btn-delete-list:hover { background: rgba(220,38,38,0.1); }

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

@media (max-width: 600px) {
  :root { --poster-w: 130px; }
  .stats-bar { gap: 10px; }
  .stat-card { padding: 12px 16px; min-width: 90px; }
  .stat-number { font-size: 1.6rem; }
}
