/* ==========================================
   RESET GLOBAL
   ========================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell,
    sans-serif;
  background-color: #f8f9fa;
  color: #2c3e50;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================
   LAYOUT PRINCIPAL - 3 COLONNES
   ========================================== */

.app-container {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================
   1. BARRE LATÉRALE GAUCHE
   Explorateur de fichiers
   ========================================== */

.sidebar {
  background-color: #ffffff;
  color: #495057;
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  border-right: 1px solid #e2e8f0;
  user-select: none;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.file-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background-color: white;
}
.folder-title-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.plan-badge {
  display: inline-block;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.plan-badge-free {
  background: #e2e8f0;
  color: #475569;
}

.plan-badge-premium {
  background: #fef3c7;
  color: #92400e;
}

.sidebar-dictionary {
  flex-shrink: 0;
  padding: 12px 4px 4px;
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.dictionary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 2px 10px;
  cursor: pointer;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.dictionary-title-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dictionary-icon {
  font-size: 1rem;
}

.dictionary-counter {
  font-size: 0.75rem;
  font-weight: 500;
  color: #2563eb;
  background: #eff6ff;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Liste des mots */

.sidebar-dictionary .badge-container {
  max-height: 110px;
  padding: 2px 0;
  gap: 5px;
}

.dictionary-add {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.dictionary-add input {
  min-width: 0;
  flex: 1;
  padding: 7px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #ffffff;
  color: #334155;
  font-size: 0.76rem;
  outline: none;
}

.dictionary-add input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px #eff6ff;
}

.dictionary-add button {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 1.2rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.dictionary-add button:hover {
  background: #dbeafe;
}

.folder-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #2c3e50;
  overflow: hidden;
}

.folder-title-box span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Boutons icônes */

.btn-icon {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

/* Arborescence */

.tree-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Ligne d'un dossier */

.tree-folder-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
}

.tree-folder-group {
  flex: 1;
  min-width: 0;
}

.tree-folder-group > summary {
  list-style: none;
}

.tree-folder-group > summary::-webkit-details-marker {
  display: none;
}

.tree-folder {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.tree-folder:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

/* Contenu des dossiers */

.tree-sub-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 16px;
  margin-top: 2px;
  margin-bottom: 4px;
  border-left: 1px dashed #cbd5e1;
  margin-left: 10px;
}

/* Fichiers */

.tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: #475569;
  font-size: 0.86rem;
  transition: background-color 0.15s ease;
}
.tree-item .menu-btn {
  flex: 0 0 auto;
  margin-left: auto;
}

.tree-item:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.tree-item.active {
  background-color: #dbeafe;
  color: #1d4ed8;
  font-weight: 500;
  border-left: 2px solid #3b82f6;
}

.tree-item span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-label {
  flex: 1;
  min-width: 0;
  margin-left: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-item .tree-label {
  padding-right: 12px;
}

/* Boutons de menu des fichiers et dossiers */

.menu-btn {
  position: absolute;
  right: 4px;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  visibility: hidden;
}

.tree-item:hover .menu-btn,
.tree-folder-row:hover .menu-btn,
.menu-btn:focus-visible {
  visibility: visible;
}
#btn-space-menu {
  visibility: visible;
  position: static;
  flex-shrink: 0;
}
.tree-folder-row > .menu-btn {
  flex-shrink: 0;
  margin-top: 3px;
}

.menu-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
}

/* ==========================================
   2. ZONE CENTRALE
   Éditeur et statistiques
   ========================================== */

.editor-bar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  background-color: #fdfbf7;
}

.editor-pane {
  flex: 1;
  background-color: #fdfbf7;
  padding: 30px 50px;
  overflow-y: auto;
  min-height: 0;
}

/* Zone d'écriture */

#editor {
  font-family: "Lora", Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  color: #2c3e50;
  outline: none;
  min-height: 100%;
}

#editor:empty::before {
  content: attr(placeholder);
  color: #94a3b8;
  pointer-events: none;
}

/* Barre de statistiques */

.stats-box {
  display: flex;
  justify-content: space-around;
  background-color: #ffffff;
  padding: 12px 10px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-weight: bold;
  font-size: 1.1rem;
  color: #1e293b;
}

.stat-label {
  font-size: 0.8rem;
  color: #64748b;
}

/* ==========================================
   3. PANNEAU LATÉRAL DROIT
   Outils d'analyse
   ========================================== */

.analysis-bar {
  padding: 16px;
  overflow-y: auto;
  background-color: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-section {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 12px;
  border-radius: 8px;
}

.analysis-category {
  display: flex;
  flex-direction: column;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 8px;
}

/* Titres des catégories */

.category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

summary {
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

/* Titres des éléments d'analyse */

/* Accordéons des mots analysés */
.analysis-item {
  position: relative;
  display: inline-block;
  width: auto;
  vertical-align: top;
  margin: 2px;
}

.analysis-item > summary.word-title {
  display: flex;
  align-items: center;
  width: auto;
}

.analysis-item:hover .ignore-btn {
  visibility: visible;
}

.analysis-item > summary.word-title > .badge {
  min-width: 0;
}

.analysis-item .span_priority {
  margin-left: auto;
  flex-shrink: 0;
}

/* Bouton d'exclusion des répétitions : frère du summary */
.ignore-btn {
  position: static;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1;
  visibility: hidden;
}

.ignore-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  visibility: visible;
}

.sidebar-section h3 {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: #475569;
  margin-bottom: 8px;
}

.sidebar-section h3 .stat-value {
  font-size: inherit;
  color: inherit;
}

/* Section des actions */

.actions-section {
  display: flex;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 0;
}

/* Boutons */

.btn {
  flex: 1;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: #2563eb;
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

.btn-secondary {
  background-color: #e2e8f0;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

/* ==========================================
   RECHERCHE DE MOTS
   ========================================== */

.search-box {
  display: flex;
  gap: 6px;
  align-items: center;
}

.search-box input {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  width: 100%;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.88rem;
  outline: none;
}

.search-box input:focus {
  border-color: #2563eb;
}

#search-counter {
  font-size: 0.8rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
#btn-search-prev,
#btn-search-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 16px;
  cursor: pointer;
  transition:
    background-color 0.2s,
    color 0.2s;
}

#btn-search-prev:hover,
#btn-search-next:hover {
  background: #e2e8f0;
  color: #1e293b;
}

#btn-search-prev:active,
#btn-search-next:active {
  background: #cbd5e1;
}

.btn-clear-search {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear-search:hover {
  background-color: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

.btn-clear-search:active {
  transform: scale(0.92);
}

.btn-clear-search:focus-visible {
  outline: 2px solid #f87171;
  outline-offset: 2px;
}

/* ==========================================
   BADGES D'ANALYSE
   ========================================== */

.badge-container {
  max-height: 130px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.badge:hover {
  transform: translateY(-1px);
}

.badge small {
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Couleurs des badges */

.badge_weak_word {
  background-color: #fee2e2;
  color: #991b1b;
}

.suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 16px;
}

.suggestion-word {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 500;
}

.badge_weak_word small {
  background-color: #fecaca;
  color: #7f1d1d;
}

.badge_repeat_word {
  background-color: #d1fae5;
  color: #065f46;
}

.badge_repeat_word small {
  background-color: #a7f3d0;
  color: #047857;
}

.badge_adverb_word {
  background-color: #fef3c7;
  color: #92400e;
}

.badge_adverb_word small {
  background-color: #fde68a;
  color: #b45309;
}

.badge_ignored_word {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: #dbeafe;
  color: #2563eb;
  border-radius: 15px;
  padding: 3px 7px;
  font-size: 0.78rem;
}

.badge_ignored_word:hover {
  border-color: #bfdbfe;
  color: #2563eb;
  transform: none;
}

.badge_ignored_word .ignore-btn {
  position: static;
  visibility: hidden;
}

.badge_ignored_word:hover .ignore-btn,
.badge_ignored_word .ignore-btn:focus-visible {
  visibility: visible;
}

/* ==========================================
   SURLIGNAGES DANS L'ÉDITEUR
   CSS Custom Highlight API
   ========================================== */

/* Tous les résultats */
::highlight(search-results) {
  background-color: #ffeb00;
  color: #1a1a1a;
}

/* Résultat actuellement sélectionné */
::highlight(search-active) {
  background-color: #ff8c00;
  color: #1a1a1a;
}

::highlight(weak-words) {
  text-decoration: wavy underline #dc2626;
  color: #dc2626;
  text-shadow:
    0.3px 0 #dc2626,
    -0.3px 0 #dc2626;
}

::highlight(repetitions) {
  color: #059669;
  text-shadow:
    0.3px 0 #059669,
    -0.3px 0 #059669;
}

::highlight(adverbs) {
  color: #d97706;
  text-decoration: underline dashed #e5a34b;
  text-shadow:
    0.3px 0 #d97706,
    -0.3px 0 #d97706;
}

/* ==========================================
   TOOLTIPS
   ========================================== */

.section-title-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title-container h3 {
  margin: 0;
}

.tooltip {
  position: relative;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
}

.tooltiptext {
  visibility: hidden;
  width: 170px;
  background-color: #1e293b;
  color: #ffffff;
  border: 1px solid #475569;
  border-radius: 6px;
  text-align: center;
  padding: 6px 8px;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  right: 0;
  font-size: 0.75rem;
  line-height: 1.3;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  font-weight: normal;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}

/* ==========================================
   MENU CONTEXTUEL
   ========================================== */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px;
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.85rem;
  color: #334155;
  border-radius: 4px;
  cursor: pointer;
}

.context-menu button:hover {
  background: #e2e8f0;
}

.context-menu button:last-child {
  color: #dc2626;
}

.context-menu hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 4px 2px;
}

/* ==========================================
   GLISSER-DÉPOSER
   ========================================== */

.drop-target {
  background-color: #dbeafe !important;
  outline: 1px dashed #3b82f6;
}

body.dragging .tree-folder > * {
  pointer-events: none;
}

/* ==========================================
   INDICATEURS DE PRIORITÉ
   ========================================== */

.priority-label {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
}

.priority-highPriority {
  background-color: #fee2e2;
  color: #b91c1c;
}

.priority-contextual {
  background-color: #fef3c7;
  color: #92400e;
}

.priority-lowPriority {
  background-color: #e0e7ff;
  color: #3730a3;
}
