/* BPA DB Manager — Dark theme */
:root {
  --bg:        #0f1117;
  --bg2:       #1a1d27;
  --bg3:       #242736;
  --border:    #2e3149;
  --text:      #e2e4f0;
  --text-dim:  #7b80a0;
  --accent:    #4f8ef7;
  --accent-h:  #3a7bec;

  --todo:      #5a5e7a;
  --pret:      #d97706;
  --published: #16a34a;
  --todoprev:  #dc2626;
  --en-cours:  #7c3aed;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 48px;
  width: 380px;
  text-align: center;
}
.login-box h1 { font-size: 22px; margin-bottom: 8px; }
.login-box p  { color: var(--text-dim); margin-bottom: 28px; font-size: 13px; }
.login-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 14px;
}
.login-box input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-error { color: var(--todoprev); font-size: 13px; margin-top: 8px; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
#app { display: none; min-height: 100vh; }

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 0 20px 24px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.sidebar-logo span { color: var(--text-dim); font-weight: 400; font-size: 12px; display: block; }
.nav { padding: 16px 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--text-dim);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 14px;
}
.nav-item:hover  { color: var(--text); background: var(--bg3); }
.nav-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--bg3); }
.nav-item .icon  { width: 18px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.logout-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--todoprev); color: var(--todoprev); }

.main {
  margin-left: 220px;
  padding: 32px;
  min-height: 100vh;
}

/* ── Pages ──────────────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Titres ─────────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* ── Boutons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-ghost    { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover    { color: var(--text); border-color: var(--text-dim); }
.btn-danger   { background: transparent; color: var(--todoprev); border: 1px solid var(--todoprev); }
.btn-danger:hover   { background: var(--todoprev); color: #fff; }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards stats ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.stat-label  { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value  { font-size: 32px; font-weight: 700; }
.stat-card.todo      .stat-value { color: var(--todo); }
.stat-card.pret      .stat-value { color: var(--pret); }
.stat-card.published .stat-value { color: var(--published); }
.stat-card.todoprev  .stat-value { color: var(--todoprev); }
.stat-card.total     .stat-value { color: var(--accent); }

/* ── Barres ─────────────────────────────────────────────────────────────────── */
.bar-section { margin-bottom: 32px; }
.bar-section h3 { font-size: 15px; margin-bottom: 16px; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.bar-label { width: 130px; font-size: 13px; color: var(--text-dim); flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: var(--bg3); border-radius: 5px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--accent); border-radius: 5px; transition: width 0.4s; }
.bar-count { width: 40px; text-align: right; font-size: 13px; color: var(--text-dim); }

/* ── Filtres ────────────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}
.filter-select, .filter-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  height: 36px;
}
.filter-select:focus, .filter-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}
option { background: var(--bg2); }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg3);
  padding: 12px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
thead th.sortable {
  cursor: pointer;
  user-select: none;
}
thead th.sortable:hover { color: var(--text); }
.sort-icon { opacity: 0.3; font-size: 10px; margin-left: 4px; }
.sort-icon.active { opacity: 1; color: var(--accent); }
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

/* ── Status badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-todo      { background: #2a2d3e; color: #8b90b0; }
.badge-pret      { background: #3d2e10; color: #d97706; }
.badge-published { background: #0e2d1c; color: #22c55e; }
.badge-todoprev  { background: #2d1010; color: #ef4444; }
.badge-en_cours  { background: #2d1d4a; color: #a78bfa; }

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  color: var(--text-dim);
  font-size: 13px;
}
.pagination-btns { display: flex; gap: 6px; }
.page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled)  { border-color: var(--accent); color: var(--accent); }
.page-btn.active   { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  width: 460px;
  max-width: 95vw;
}
.modal h3 { font-size: 17px; margin-bottom: 20px; }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}
.form-row textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ── Panneau génération IA ──────────────────────────────────────────────────── */
.gen-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 28px;
}
.gen-panel h3 { font-size: 16px; margin-bottom: 18px; }
.gen-fields { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.gen-field { display: flex; flex-direction: column; gap: 6px; }
.gen-field label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.gen-field input, .gen-field select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  height: 36px;
  min-width: 120px;
}
.loader {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gen-result { margin-top: 20px; }
.gen-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: 6px;
}
.gen-meta strong { color: var(--published); }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  animation: fadeIn .2s ease;
  max-width: 320px;
}
.toast-success { background: #14532d; color: #86efac; border: 1px solid #16a34a; }
.toast-error   { background: #450a0a; color: #fca5a5; border: 1px solid #dc2626; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ── Responsive basique ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .nav-item span { display: none; }
  .sidebar-logo span, .sidebar-logo { font-size: 0; }
  .main { margin-left: 60px; padding: 20px 16px; }
  .filters { gap: 8px; }
}

/* ── Utilitaires ────────────────────────────────────────────────────────────── */
.text-dim   { color: var(--text-dim); }
.text-sm    { font-size: 12px; }
.mt-4       { margin-top: 4px; }
.flex       { display: flex; }
.gap-8      { gap: 8px; }
.align-center { align-items: center; }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
