/* ==========================================
   ZEBRAWRITER+ STYLES COMPLETS
   Avec numérotation des fragments
   ========================================== */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* Barre de menu */
.menubar {
  background: #2c3e50;
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.menubar h1 {
  color: #3498db;
  font-size: 18px;
  margin-right: 20px;
}

.menubar button {
  background: transparent;
  border: 1px solid #34495e;
  color: #ecf0f1;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.menubar button:hover {
  background: #34495e;
  border-color: #3498db;
}

.menubar button.active {
  background: #3498db;
  border-color: #3498db;
  color: white;
}

/* ── Menus déroulants dans la menubar ── */
.menubar-dropdown {
  position: relative;
  display: inline-block;
}

.menubar-dropdown-toggle {
  background: transparent;
  border: 1px solid #34495e;
  color: #ecf0f1;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.menubar-dropdown-toggle:hover {
  background: #34495e;
  border-color: #3498db;
}

.menubar-dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #2c3e50;
  border: 1px solid #34495e;
  border-radius: 4px;
  min-width: 180px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  overflow: hidden;
}

.menubar-dropdown-content.open {
  display: block;
}

.menubar-dropdown-content button {
  background: transparent;
  border: none;
  border-bottom: 1px solid #34495e;
  color: #ecf0f1;
  padding: 10px 16px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  transition: background 0.15s;
  border-radius: 0;
}

.menubar-dropdown-content button:last-child {
  border-bottom: none;
}

.menubar-dropdown-content button:hover {
  background: #3498db;
  color: white;
}

/* Conteneur de l'éditeur avec colonne fragments */
#editor-container {
  display: flex;
  position: relative;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  max-height: calc(100vh - 150px);
}

/* Colonne des numéros de fragments (à gauche) */
.fragment-numbers {
  position: sticky;
  left: 0;
  top: 0;
  width: 60px; /* 60px par défaut ; JS passe à 100px si N° lignes actifs */
  background: #f8f9fa;
  border-right: 2px solid #3498db;
  flex-shrink: 0;
  z-index: 10;
  overflow: visible;
}

.fragment-numbers-inner {
  position: relative; /* ← Référence pour les enfants absolute */
  width: 100%;
  height: 100%;
}

.fragment-number {
  position: absolute;
  width: 60px; /* largeur fixe de la colonne fragments */
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #3498db;
  font-family: 'Courier New', monospace;
  height: 24px;
  box-sizing: border-box;
}

.fragment-number.active {
  background: #3498db;
  color: white;
}

/* Modes */
.mode {
  display: none;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.mode.active {
  display: flex;
  gap: 20px;
}

/* Éditeur */
.editor-container {
  flex: 1;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: auto;
  max-height: calc(100vh - 150px);
}

#editor-lines {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

.line {
  display: flex;
  position: relative;
  min-height: 24px;
}

.line.fragment-line {
  background: #ecf9ff;
}

.line.fragment-line .line-content {
  font-weight: 500;
}

.line-number {
  /* Géré en position:absolute dans fragment-numbers par virtual-editor.js */
  /* display:none supprimé — la visibilité est contrôlée par showLineNumbers en JS */
  user-select: none;
  font-family: 'Courier New', monospace;
}

.line-content {
  flex: 1;
  padding: 0 10px;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  position: relative;
  z-index: 2;
}

.line-content br {
  display: block;
  content: "";
  margin: 0;
}

.marker-track {
  position: absolute;
  left: 40px;  /* Par défaut sans numéros de ligne (seulement colonne fragments) */
  right: 0;
  top: 0;
  height: 24px;
  pointer-events: none;
  z-index: 3;
  overflow: visible;
}

.marker {
  position: absolute;
  height: 4px;
  top: -5px;
  pointer-events: none;
  opacity: 0.5;
  z-index: 3;
  border-radius: 2px;
}

/* Menu contextuel */
#context-menu {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#context-menu div:hover {
  background: #f0f0f0;
}

/* Panneau de marqueurs */
.marker-panel {
  width: 300px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 15px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  flex-shrink: 0;
}

.marker-panel h3 {
  margin-bottom: 15px;
  color: #2c3e50;
  font-size: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.marker-panel #marker-count {
  font-size: 12px;
  color: #7f8c8d;
  font-weight: normal;
}

.field-item,
.marker-item {
  padding: 10px;
  margin-bottom: 8px;
  background: #f8f9fa;
  border-left: 4px solid #3498db;
  border-radius: 3px;
  font-size: 13px;
}

.marker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.marker-item strong {
  color: #2c3e50;
  font-size: 12px;
}

.marker-item span {
  flex: 1;
  color: #555;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-item button {
  background: #e74c3c;
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.marker-item button:hover {
  background: #c0392b;
}

/* Mode Rapports */
.reports-container {
  flex: 1;
}

.report-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.report-card {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.report-card h3 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 18px;
}

.report-card p {
  color: #7f8c8d;
  font-size: 14px;
  margin-bottom: 15px;
  line-height: 1.5;
}

.report-card button {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.report-card button:hover {
  background: #2980b9;
}

.reports-history h3 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 18px;
}

.report-item {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 15px;
  margin-bottom: 10px;
}

.report-item strong {
  display: block;
  color: #2c3e50;
  margin-bottom: 5px;
}

.report-item small {
  color: #7f8c8d;
  font-size: 12px;
}

.report-item button {
  background: #3498db;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 8px;
}

.report-item button:hover {
  background: #2980b9;
}

/* Barre de statut */
.statusbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #34495e;
  color: #ecf0f1;
  padding: 8px 20px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

/* Modales */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-content h2 {
  color: #2c3e50;
  margin-bottom: 20px;
}

.modal-content button {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 15px;
}

.modal-content button:hover {
  background: #2980b9;
}
