/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #f1f4f9;
  --bg-card:     #ffffff;
  --bg-sidebar:  #ffffff;
  --bg-input:    #f1f4f9;
  --border:      #e4e8f0;
  --border-h:    #c8d0e0;
  --text:        #1e2533;
  --text-muted:  #8898aa;
  --text-dim:    #5a6a7e;
  --accent:      #6366f1;
  --accent-h:    #4f52e0;
  --green:       #10b981;
  --yellow:      #f59e0b;
  --red:         #ef4444;
  --blue:        #3b82f6;
  --header-h:    60px;
  --sidebar-w:   210px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* ── Header ────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(30,37,51,.06);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.header-logo  { font-size: 1.4rem; }
.header-title { font-size: 1.1rem; font-weight: 700; color: var(--text); line-height: 1; }
.header-sub   { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid transparent;
}
.stat-item:hover, .stat-item.active { background: var(--bg-input); border-color: var(--border); }
.stat-num   { font-size: 1.05rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.stat-todo   .stat-num { color: var(--text-dim); }
.stat-done   .stat-num { color: var(--green); }
.stat-replay .stat-num { color: var(--blue); }
.stat-paused .stat-num { color: var(--yellow); }

/* Search */
.header-right { flex-shrink: 0; }
.search-wrapper { position: relative; display: flex; align-items: center; }
.search-icon {
  position: absolute;
  left: 10px;
  font-size: 0.85rem;
  pointer-events: none;
  opacity: .45;
}
#search {
  width: 200px;
  padding: 7px 12px 7px 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, width .2s, box-shadow .15s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
  width: 260px;
}
#search::placeholder { color: var(--text-muted); }

/* ── Layout ────────────────────────────────────────────────── */
.layout { display: flex; height: calc(100vh - var(--header-h)); }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: relative;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px 32px;
  transition: width .2s, padding .2s;
}
.sidebar.collapsed { width: 0; padding: 0; overflow: hidden; }

.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: -14px;
  width: 28px;
  height: 28px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  z-index: 10;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(30,37,51,.08);
}
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.filter-section { margin-bottom: 22px; }
.filter-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 2px;
}
.filter-list { display: flex; flex-direction: column; gap: 2px; }

.filter-btn {
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: background .1s, color .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.filter-btn:hover  { background: var(--bg-input); color: var(--text); }
.filter-btn.active { background: rgba(99,102,241,.08); color: var(--accent); font-weight: 600; }
.filter-btn .count {
  font-size: 0.67rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}
.filter-btn.active .count { color: var(--accent); background: rgba(99,102,241,.12); }

.sort-select {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.sort-select:focus { border-color: var(--accent); }

/* ── Main ──────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.results-count { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

.btn-add {
  padding: 7px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-add:hover { background: var(--accent-h); }

/* ── List ──────────────────────────────────────────────────── */
.games-list {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(30,37,51,.06);
}

.list-header, .list-row {
  display: grid;
  grid-template-columns: 1fr 82px 130px 56px 66px 54px 30px;
  gap: 12px;
  align-items: center;
  padding: 9px 16px;
}

.list-header {
  background: var(--bg-input);
  border-bottom: 2px solid var(--border);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
}

.list-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover      { background: #f8f9ff; }

.list-row.status-done    { border-left: 3px solid var(--green); }
.list-row.status-replay  { border-left: 3px solid var(--blue); }
.list-row.status-paused  { border-left: 3px solid var(--yellow); }
.list-row.status-dropped { border-left: 3px solid var(--red); opacity: .55; }

.col-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-console { display: flex; }
.col-genre {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-mc, .col-duree, .col-note { font-size: 0.78rem; }
.col-duree { color: var(--text-muted); }
.col-status { font-size: 1rem; text-align: center; }

.row-note { font-weight: 700; color: #92400e; }
.row-empty, .col-mc-empty { color: var(--border-h); }

/* Console badge */
.console-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.7rem;
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.tag-mc             { font-weight: 700; }
.tag-mc.mc-good     { background: rgba(16,185,129,.1);  color: #059669; border-color: rgba(16,185,129,.25); }
.tag-mc.mc-ok       { background: rgba(245,158,11,.1); color: #d97706; border-color: rgba(245,158,11,.25); }
.tag-mc.mc-meh      { background: rgba(239,68,68,.1);  color: #dc2626; border-color: rgba(239,68,68,.25); }
.tag-muted          { color: var(--text-muted); }

/* Empty state */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.hidden { display: none !important; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30,37,51,.35);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative;
  z-index: 1;
  width: min(500px, 94vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(30,37,51,.15);
  max-height: 92vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}
.modal-title-row h2 { font-size: 1.05rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.modal-close {
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--bg-input); }

.modal-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.modal-desc { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; }

/* Add-only fields */
.add-fields { display: flex; flex-direction: column; gap: 12px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
}
.form-hint  { font-weight: 400; text-transform: none; }
.required   { color: var(--red); }

.form-input {
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.form-input::placeholder { color: var(--text-muted); }

.modal-form { display: flex; flex-direction: column; gap: 14px; }

/* Status grid */
.status-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.status-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.65rem;
  text-align: center;
  transition: all .15s;
}
.status-btn .s-icon { font-size: 1.2rem; }
.status-btn:hover   { border-color: var(--accent); color: var(--text); }
.status-btn.active  { border-color: var(--accent); background: rgba(99,102,241,.08); color: var(--accent); font-weight: 600; }

/* Stars */
.rating-row  { display: flex; align-items: center; gap: 10px; }
.stars-row   { display: flex; gap: 3px; }
.star {
  font-size: 1.3rem;
  cursor: pointer;
  opacity: .2;
  color: var(--yellow);
  user-select: none;
  transition: transform .1s, opacity .1s;
}
.star:hover, .star.lit { opacity: 1; }
.star:hover { transform: scale(1.15); }
.rating-value { font-size: 1rem; font-weight: 700; color: var(--yellow); min-width: 2ch; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all .15s;
}
.btn-save   { background: var(--accent); color: #fff; }
.btn-save:hover { background: var(--accent-h); }
.btn-cancel { background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border); }
.btn-cancel:hover { color: var(--text); border-color: var(--border-h); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-h); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .list-header, .list-row {
    grid-template-columns: 1fr 82px 56px 54px 30px;
  }
  .col-genre, .col-duree { display: none; }
}

@media (max-width: 768px) {
  .header { flex-wrap: wrap; height: auto; padding: 10px; gap: 10px; }
  .stats-bar { order: 3; width: 100%; justify-content: center; }
  .header-right { order: 2; }
  #search { width: 160px; }
  #search:focus { width: 200px; }
  .sidebar { width: 0; padding: 0; overflow: hidden; }
  .sidebar.open { width: var(--sidebar-w); padding: 16px 12px 32px; overflow-y: auto; }
  .layout { height: auto; }
  .main { min-height: calc(100vh - 120px); }
  .list-header, .list-row {
    grid-template-columns: 1fr 74px 52px 30px;
  }
  .col-mc { display: none; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .status-grid { grid-template-columns: repeat(3, 1fr); }
}
