/* ================================
   RESET + TOKENS (THEMEABLE)
==================================*/

/* Reset rapide */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

/* ---- Thème clair (par défaut) : issu du 2e CSS ---- */
:root {
  /* Palette */
  --bg: #efdebf;          /* ancien: --font */
  --surface: #fbf2e2;     /* ancien: --font2 */
  --text: #624536;
  --muted: #9ca3af;
  --primary: #c5b497;     /* ancien: --bouton */
  --primary-hover: #8c6f4e; /* ancien: --survol */
  --danger: #ef4444;

  /* Déduits / structurants */
  --border: var(--text);
  --accent: var(--text);   /* utilisé pour des bordures photos, etc. */
  --surface-2: rgba(255,255,255,0.03); /* léger overlay pour headers de cartes */
  --input-bg: var(--primary);
  --input-text: var(--text);
  --input-border: var(--border);

  /* Badges */
  --ok-bg: rgba(16,185,129,.15);
  --ok-fg: #10b981;
  --ko-bg: rgba(239,68,68,.15);
  --ko-fg: #ef4444;
}

/* ---- Thème sombre : reprend proprement le 1er CSS ---- */
.theme-dark {
  --bg: #0b1020;
  --surface: #0d1326;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #5865f2;
  --primary-hover: #4752c4;
  --danger: #ef4444;

  --border: #1f2937;
  --accent: #eab308;      /* utilisé par .title dans le 1er CSS */
  --surface-2: rgba(255,255,255,.03);
  --input-bg: #0d1326;
  --input-text: #e5e7eb;
  --input-border: #1f2937;
}

/* ================================
   STRUCTURE GENERALE
==================================*/

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: grid;
  grid-template-rows: 60px 1fr;   /* topbar + contenu */
  grid-template-columns: 220px 1fr; /* sidebar + main */
}

/* Contenu principal */
main.content {
  grid-column: 2;
  grid-row: 2;
  padding: 1.5rem;
  background: var(--bg);
  border-left: 2px solid var(--border);
}

/* Topbar */
.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--surface);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.9rem;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.7em;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--text);
}

.topbar .brand img,
.topbar .user img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: block;
}
.topbar .user img { width: 38px; height: 38px; }

.topbar .user {
  display: flex;
  align-items: center;
  font-size: 1rem;
  font-weight: bold;
  gap: 0.8rem;
}

.topbar .logout {
  color: var(--danger);
  text-decoration: none;
  font-size: 1rem;
  font-weight: bold;
}

/* Sidebar */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--surface);
  border-right: 2px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.sidebar nav a {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-weight: bold;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  transition: 0.2s;
  margin-bottom: 0.3rem;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--text);
  color: var(--surface);
  font-weight: bold;
}

.group { margin-bottom: 1.5rem; }
.group-title {
  color: var(--text);
  font-weight: 600;
  font-size: 1.2rem;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ================================
   LOGIN
==================================*/

body.login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 2rem 3rem;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.login-card h1 { color: var(--text); margin-bottom: 1rem; }
.login-card p { color: var(--text); margin-bottom: 1.5rem; }

.btn-discord {
  display: inline-block;
  background: var(--primary);
  color: var(--text);
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: 0.2s;
}
.btn-discord:hover {
  background: var(--primary-hover);
  color: var(--surface);
}

/* ================================
   LAYOUTS / GRIDS
==================================*/

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px){ .grid-2 { grid-template-columns: 1fr; } }

/* ================================
   EN-TETE DE PAGE + RECHERCHE
==================================*/

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.title { margin:0; color: var(--accent); }

.page-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--text);
}

.searchbar { display:flex; gap:.5rem; align-items:center; }

.searchbar input[type="text"] {
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.searchbar button,
.searchbar a.btn {
  padding: .55rem .9rem;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: .2s;
}

.searchbar button {
  background: var(--surface);
  color: var(--text);
}
.searchbar button:hover {
  background: var(--primary-hover);
  color: var(--surface);
}

.searchbar a.btn {
  background: var(--text);
  color: var(--surface);
}
.searchbar a.btn:hover { background: var(--primary-hover); }

/* ================================
   CARTES / PANNEAUX
==================================*/

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
}

.card__header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text);
}

.card__body { padding: 1rem; }

/* ================================
   FORMULAIRES
==================================*/

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem 1rem;
}

.field { display:flex; flex-direction:column; gap:.3rem; }
.field--full { grid-column: 1 / -1; }

.label {
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
}

.input, .textarea, .select {
  width: 100%;
  background: var(--input-bg);
  color: var(--input-text);
  font-weight: bold;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: .55rem .75rem;
  outline: none;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--border);
  box-shadow: 0 0 0 2px rgba(65, 49, 2, 0.37);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
  gap: .5rem;
  margin-top: .5rem;
}

/* ================================
   BOUTONS
==================================*/

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: .55rem .9rem;
  cursor: pointer;
  transition: .15s ease;
  text-decoration: none;
  background: var(--surface); /* neutre par défaut */
  color: var(--text);
}

.btn:hover {
  background: var(--primary-hover);
  color: var(--surface);
}

.btn--primary {
  background: var(--primary);
  color: var(--text);
}
.btn--primary:hover {
  background: var(--primary-hover);
  color: var(--surface);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}
.btn--danger:hover { filter: brightness(0.9); }

.btn--sm {
  padding: .4rem .6rem;
  border-radius: 6px;
  font-size: .9rem;
}

/* ================================
   BOUTON SUPPORT PROCUREUR
==================================*/

.btn-support {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: var(--primary);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .8rem 1.3rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.btn-support:hover {
  background: var(--primary-hover);
  color: var(--surface);
  transform: translateY(-1px);
}

.btn-support:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* ================================
   LISTES DOCS / ROW ACTIONS
==================================*/

.doc-list {
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:.75rem;
}

.doc-item {
  background: var(--primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
}

.doc-item__title { font-weight:700; }
.doc-item__desc { color: var(--text); font-size:.92rem; }
.doc-row-actions { display:flex; gap:.4rem; align-items:center; }

.muted { color: var(--muted); }

/* ================================
   TABLES
==================================*/

.table-wrapper { 
  width:100%; 
  overflow-x:auto; 
  overflow-y: visible;
  position: relative;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table th, .table td {
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: normal;
}

.table thead th {
  background: rgba(255,255,255,.05);
  font-weight: 600;
  color: var(--text);
}

/* ✅ Flex uniquement sur un WRAPPER interne, pas sur le <td> */
.table .actions {
  display:flex;
  align-items:center;
  gap:.4rem;
  flex-wrap: wrap;          /* pour éviter les débordements en petit écran */
}
.table .actions > * { flex:0 0 auto; }  /* les boutons ne s’étirent pas */
.table .actions form { margin:0; }      /* reset margin */

.table tr:last-child td { border-bottom: none; }
.cell--right { text-align: right; }
.table .muted { color: var(--muted); text-align: center; }

/* ================================
   BADGES
==================================*/

.badge {
  display: inline-block;
  padding: .25rem .6rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
}

.badge--open   { background: var(--ok-bg); color: var(--ok-fg); }
.badge--closed { background: var(--ko-bg); color: var(--ko-fg); }

/* ================================
   AUTEUR
==================================*/

.author-info {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.author-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

/* ================================
   DIVERS
==================================*/

/* Page matrix_view */
.matrix-box{
  width:100%;
  background: var(--surface);
  color: var(--text);
  border:1px solid var(--border);
  border-radius:8px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb {
  background: var(--surface);
  border-radius: 4px;
}
::-webkit-scrollbar-track { background: var(--bg); }

/* ========= Autocomplete – champ + liste (look propre) ========= */
.calc-row .ac-wrap { position: relative; width: 100%; }

.ac-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--surface, #fff);
  border: none;                /* 🔥 enlève la bordure beige */
  border-radius: 8px;          /* arrondis doux */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* ombre légère propre */
  overflow-y: auto;
  max-height: 350px;
  padding: 0;                /* léger padding intérieur */
}

/* Éléments de la liste */
.ac-item {
  border-radius: 0;          /* arrondi local */
  margin: 0;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.ac-item > :first-child { overflow: hidden; text-overflow: ellipsis; }

.ac-item:hover,
.ac-item.active {
  filter: brightness(1.05);
  transform: none;      /* retire le petit décalage horizontal pour éviter les liserés */
}

.ac-item:first-child { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.ac-item:last-child  { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }

.ac-empty { padding: .75rem .9rem; color: var(--muted); }

.ac-item + .ac-item {
  box-shadow: inset 0 1px 0 rgba(0,0,0,.08); /* trait très discret */
}

/* ================================
   EX-inline vers CSS
==================================*/

/* Barre de total (remplace style inline) */
#totalbar { text-align: center; font-weight: 800; }

/* Champ otages (remplace max-width inline, sans toucher le JS) */
.calc-row input[type="number"] { max-width: 80px; }

/* Message d’erreur PHP */
.error-text { color: #c00; }

/* Champ de recherche plus lisible + icône loupe */
.input.infQuery {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 40px;
  padding: 0 .9rem 0 2.3rem; /* place pour l’icône */
  font-weight: 600;
  line-height: 40px;
  transition: box-shadow .15s ease, border-color .15s ease;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23624536' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 10px center;
}

.input.infQuery:focus {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px rgba(140,111,78,.18);
  outline: none;
}

.table td:first-child .ac-wrap { min-width: 320px; }

/* Badges de catégorie (mêmes couleurs que la page Code pénal) */
.cat-contravention {
  background-color: #2ecc71;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.cat-delit-mineur {
  background-color: #f1c40f;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.cat-delit-majeur {
  background-color: #e67e22;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.cat-crime {
  background-color: #e74c3c;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.cat-crime-federaux {
  background-color: #9b59b6;
  white-space: nowrap;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.cat-autre {
  background-color: #95a5a6;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

/* Couleurs semi-transparentes pour la liste autocomplete */
.ac-item.cat-contravention { background-color: rgba(46, 204, 113, 0.8); color: #fff; }
.ac-item.cat-delit-mineur  { background-color: rgba(241, 196, 15, 0.8); color: #fff; }
.ac-item.cat-delit-majeur  { background-color: rgba(230, 126, 34, 0.8); color: #fff; }
.ac-item.cat-crime         { background-color: rgba(231, 76, 60, 0.8); color: #fff; }
.ac-item.cat-crime-federaux{ background-color: rgba(155, 89, 182, 0.8); color: #fff; }
.ac-item.cat-autre         { background-color: rgba(149, 165, 166, 0.8); color: #fff; }

/* Hover un peu plus vif */
.ac-item.cat-contravention:hover { background-color: rgba(46, 204, 113, 1); }
.ac-item.cat-delit-mineur:hover  { background-color: rgba(241, 196, 15, 1); }
.ac-item.cat-delit-majeur:hover  { background-color: rgba(230, 126, 34, 1); }
.ac-item.cat-crime:hover         { background-color: rgba(231, 76, 60, 1); }
.ac-item.cat-crime-federaux:hover{ background-color: rgba(155, 89, 182, 1); }
.ac-item.cat-autre:hover         { background-color: rgba(149, 165, 166, 1); }

/* Optionnel : petit style global pour uniformiser */
.ac-item {
  padding: 6px 10px;
  border-radius: 4px;
  margin: 2px 0;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* Conteneur dropdown déjà en place, on stylise la liste interne */
.cp-list { 
  padding:.25rem 0; 
  background:#fff; 
}
.cp-cat {
  position: sticky; 
  top:0;
  background:#faf7f2; 
  border-bottom:1px solid #ece7df;
  padding:.35rem .8rem; 
  font-weight:600; 
  font-size:.95rem; 
  color:#6b4e2e;
}
.cp-row {
  display:flex; align-items:center; justify-content:space-between;
  gap:1rem; padding:.55rem .8rem; border-bottom:1px solid #f3efe8;
}
.cp-row:nth-child(even) { background:#fffdf8; }
.cp-row.is-active { outline:2px solid #c8a97e; background:#fff8ec; }
.cp-title { font-weight:600; line-height:1.25; }
.cp-meta { font-size:.9rem; margin-top:.15rem; }
.cp-add { white-space:nowrap; }
.cp-add .btn { padding:.25rem .55rem; }
mark { background:#fff1a8; color:inherit; padding:0 .08em; border-radius:.15em; }
.cp-picker{ position:relative; }
#chargeDropdown{
  position:absolute; left:0; right:0; top:calc(100% + 6px); z-index:999;
  background:#fff; border:1px solid #ddd; border-radius:.5rem;
  box-shadow:0 8px 24px rgba(0,0,0,.12);
  max-height:320px; overflow:auto; display:none;
}

/* Cases à cocher stylées */
input[type="checkbox"] {
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
}

input[type="checkbox"]:checked::after {
  content: '✔';
  color: var(--border);
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
}

input[type="checkbox"]:hover {
  border-color: var(--border);
  background: rgba(0, 0, 0, 0.05);
}

input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--border);
}

/* ================================
   RESPONSIVE
==================================*/

@media (max-width: 900px) {
  body { grid-template-columns: 180px 1fr; }
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .table td:first-child .ac-wrap { min-width: 0; }
  .input.infQuery { height: 44px; }
}

