/* ═══════════════════════════════════════════════════════════════
   vo-lexique.css — Page CRUD du lexique des termes de règles
   Adapte de vo-sorts.css avec prefixe lex-
   ═══════════════════════════════════════════════════════════════ */

#main {
  padding-top: 70px;
  display: block !important;
}

/* ─── Bouton Nouveau ───────────────────────────────────────── */
.btn-nouveau {
  background: #c8e6c9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
  border-radius: 5px;
  padding: 5px 14px;
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-nouveau:hover { background: #a5d6a7; }

/* ─── Sticky Search Header ─────────────────────────────────── */
.lex-sticky-header {
  position: sticky;
  top: 56px;
  z-index: 5;
  background: #f5f5f5;
  border-bottom: 2px solid #ddd;
  border-radius: 8px 8px 0 0;
  max-width: 900px;
  margin: 0 auto;
}
.lex-filtres {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px 10px 14px;
}
.lex-recherche-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 1 250px;
  min-width: 140px;
  gap: 4px;
}
.lex-recherche-wrap input[type="text"] {
  flex: 1;
  padding: 6px 30px 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95em;
  max-width: none;
}
.lex-recherche-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2em;
  color: #888;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.lex-recherche-clear:hover { color: #333; }
.lex-filtres select {
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9em;
  background: #fff;
}
.lex-compteur {
  font-size: 0.82em;
  color: #888;
  font-style: italic;
}

/* ─── Liste container ──────────────────────────────────────── */
#lex-liste {
  max-width: 900px;
  margin: 0 auto;
}

/* ─── Cartes lexique ───────────────────────────────────────── */
.lex-card {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 8px;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.lex-card:hover {
  background: #eef5ff;
  border-color: #aac8e8;
}
.lex-card.surligne {
  background: #fff7d6;
  border-color: #f0c878;
  animation: lex-flash 1.2s ease-out;
}
@keyframes lex-flash {
  0%   { background: #ffe9a0; }
  100% { background: #fff7d6; }
}
.lex-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.lex-card-nom {
  font-weight: bold;
  font-size: 0.95em;
}
.lex-badge {
  font-size: 0.78em;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: bold;
  text-transform: lowercase;
}
.lex-badge[data-cat="effet"]   { background: #ffebee; color: #b71c1c; }
.lex-badge[data-cat="concept"] { background: #e3f2fd; color: #0d47a1; }
.lex-badge[data-cat="objet"]   { background: #e8f5e9; color: #1b5e20; }
.lex-badge[data-cat="action"]  { background: #fff8e1; color: #ef6c00; }
.lex-badge[data-cat="type"]    { background: #f3e5f5; color: #6a1b9a; }
.lex-badge-hidden {
  background: #ffecb3;
  color: #e65100;
}
.lex-card-desc {
  font-size: 0.85em;
  color: #444;
  margin: 4px 0 2px 0;
  padding-left: 4px;
  border-left: 2px solid #ddd;
  /* tronque visuellement à 2 lignes */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Popup detail ─────────────────────────────────────────── */
.lex-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lex-popup-box {
  background: #fff;
  max-width: 700px;
  width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  padding: 20px 24px;
}
.lex-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ddd;
  gap: 8px;
}
.lex-popup-header strong { font-size: 1.15em; }
.lex-popup-fermer {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 0 4px;
}
.lex-popup-fermer:hover { color: #333; }

.lex-popup-infos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #f8f8f8;
  border-radius: 6px;
}
.lex-popup-info-item {
  display: flex;
  flex-direction: column;
}
.lex-popup-info-item.full-width { grid-column: 1 / -1; }
.lex-popup-info-label {
  font-size: 0.78em;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lex-popup-info-val {
  font-size: 0.92em;
  color: #333;
  font-weight: 500;
}
.lex-popup-info-val .edit-btn-inline {
  font-size: 0.9em;
  cursor: pointer;
  opacity: 0.6;
  margin-left: 4px;
  background: none;
  border: none;
  padding: 0;
}
.lex-popup-info-val .edit-btn-inline:hover { opacity: 1; }

/* Bloc définition (markdown rendu) */
.lex-popup-def {
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  font-size: 0.92em;
  color: #222;
  line-height: 1.5;
}
.lex-popup-def p:first-child { margin-top: 0; }
.lex-popup-def p:last-child { margin-bottom: 0; }
.lex-popup-def em { color: #666; }

/* Inline editor */
.lex-inline-editor {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 2px;
  flex-wrap: wrap;
}
.lex-inline-editor input[type="text"],
.lex-inline-editor textarea,
.lex-inline-editor select {
  flex: 1;
  min-width: 160px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
}
.lex-inline-editor textarea { min-height: 110px; font-family: inherit; line-height: 1.4; }
.lex-inline-editor .btn-ie {
  border: 1px solid #ccc;
  background: #f8f8f8;
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 0.85em;
}
.lex-inline-editor .btn-ie:hover { background: #eee; }

/* Admin actions */
.lex-popup-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
}
.btn-supprimer {
  border: 1px solid #e57373;
  background: #ffebee;
  color: #b71c1c;
  border-radius: 5px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.88em;
}
.btn-supprimer:hover { background: #ffcdd2; }

/* ─── Formulaire creation ─────────────────────────────────── */
.lex-form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lex-form-card {
  background: #fff;
  max-width: 700px;
  width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  padding: 20px 24px;
}
.lex-form-card h2 { margin: 0 0 12px; font-size: 1.15em; }
.lex-form-group {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lex-form-group label {
  font-size: 0.78em;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: bold;
}
.lex-form-group input,
.lex-form-group textarea,
.lex-form-group select {
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95em;
  font-family: inherit;
}
.lex-form-group textarea { min-height: 130px; line-height: 1.4; }
.lex-form-group .lex-form-aide {
  font-size: 0.78em;
  color: #888;
  font-style: italic;
}
.lex-form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.lex-form-row > .lex-form-group { flex: 1 1 200px; }
.lex-form-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92em;
}
.lex-form-checkbox input { width: auto; }
.lex-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}
.btn-cancel {
  background: #eee;
  color: #333;
  border: 1px solid #ccc;
  padding: 5px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
}
.btn-cancel:hover { background: #ddd; }
.btn-save {
  background: #c8e6c9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
  padding: 5px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: bold;
}
.btn-save:hover { background: #a5d6a7; }
.lex-form-preview {
  margin-top: 4px;
  padding: 8px 10px;
  background: #fafafa;
  border: 1px dashed #ccc;
  border-radius: 6px;
  font-size: 0.9em;
  color: #333;
  min-height: 24px;
}
.lex-form-preview p:first-child { margin-top: 0; }
.lex-form-preview p:last-child { margin-bottom: 0; }

/* ─── Chips / tags pour l'éditeur d'alias ──────────────────── */
.lex-chips-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lex-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}
.lex-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e3f2fd;
  border: 1px solid #90caf9;
  color: #0d47a1;
  border-radius: 12px;
  padding: 2px 4px 2px 10px;
  font-size: 0.85em;
  line-height: 1.4;
}
.lex-chip-text { white-space: nowrap; }
.lex-chip-x {
  background: transparent;
  border: 0;
  color: #0d47a1;
  font-size: 1.05em;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 50%;
  line-height: 1;
}
.lex-chip-x:hover { background: rgba(13, 71, 161, 0.15); }
.lex-chip-readonly {
  background: #f0f4f8;
  border-color: #cbd5e1;
  color: #334155;
  padding: 2px 10px;
  cursor: default;
}
.lex-chips-readonly { gap: 4px; }
.lex-chips-input {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.9em;
  width: 100%;
  box-sizing: border-box;
}
.lex-chips-input:focus {
  outline: none;
  border-color: #aac8e8;
  box-shadow: 0 0 0 2px rgba(170, 200, 232, 0.3);
}
.lex-chips-aide {
  font-size: 0.78em;
  color: #888;
  font-style: italic;
}

/* Inline editor en mode chips : prend toute la ligne */
.lex-inline-editor-chips {
  flex-direction: column !important;
  align-items: stretch !important;
  width: 100%;
  gap: 8px !important;
}
.lex-inline-editor-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ─── Bandeau de conflits (en haut de la liste) ─────────────── */
.lex-conflits-bandeau {
  max-width: 900px;
  margin: 8px auto;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #ffd54f;
  border-radius: 6px;
  font-size: 0.9em;
  color: #5d4037;
}
.lex-conflits-icone {
  font-size: 1.1em;
  margin-right: 4px;
}
.lex-conflits-toggle {
  color: #1565c0;
  cursor: pointer;
  text-decoration: underline;
}
.lex-conflits-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #ffd54f;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lex-conflit-ligne code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}
.lex-conflit-lien {
  color: #1565c0;
  text-decoration: none;
}
.lex-conflit-lien:hover { text-decoration: underline; }
.lex-conflit-lien small { color: #888; }

/* Badge ⚠ conflit sur la carte */
.lex-badge-conflit {
  background: #ffebee;
  color: #b71c1c;
  border: 1px solid #ef9a9a;
}
.lex-card-conflit {
  border-left: 3px solid #ef5350;
}

/* Section conflits dans le popup */
.lex-popup-conflits {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff8e1;
  border: 1px solid #ffd54f;
  border-radius: 6px;
  font-size: 0.88em;
  color: #5d4037;
}
.lex-popup-conflits-titre {
  font-weight: bold;
  margin-bottom: 6px;
  color: #b71c1c;
}
.lex-popup-conflit-ligne {
  margin: 4px 0;
}
.lex-popup-conflit-ligne code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
}
.lex-popup-conflit-aide {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #ffd54f;
  font-style: italic;
  color: #6d4c41;
  font-size: 0.92em;
}

/* ─── Toaster ──────────────────────────────────────────────── */
#lex-toaster {
  position: fixed;
  top: 50px;
  left: 25%;
  width: 50%;
  padding: 10px 16px;
  background: #f8e5c5;
  color: #000;
  z-index: 2000;
  text-align: center;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: lex-toast-in 0.3s ease;
}
@keyframes lex-toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Vide ─────────────────────────────────────────────────── */
.lex-vide {
  text-align: center;
  color: #888;
  font-style: italic;
  padding: 30px 20px;
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 650px) {
  .lex-sticky-header { top: 36px; }
  .lex-filtres { gap: 6px 8px; padding: 6px 10px; }
  .lex-recherche-wrap { flex-basis: 100%; }
  .lex-filtres select { font-size: 0.82em; }
  .btn-nouveau { padding: 4px 10px; font-size: 0.82em; }
  .lex-popup-infos { grid-template-columns: 1fr; }
  .lex-popup-box, .lex-form-card { width: 96vw; padding: 14px 16px; }
  .lex-form-row { flex-direction: column; }
}
