/**
 * Générateur d'Histoire Familiale - Styles CSS
 * Interface moderne et intuitive pour la génération d'histoires familiales avec IA
 */

/* Variables CSS */
:root {
  --primary-color: #2c5530;
  --primary-light: #4a7c59;
  --primary-dark: #1e3b20;
  --secondary-color: #8b5a2b;
  --accent-color: #d4af37;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --error-color: #e74c3c;
  --info-color: #3498db;
  
  --text-dark: #2c3e50;
  --text-medium: #5a6c7d;
  --text-light: #95a5a6;
  
  --background-light: #ffffff;
  --background-grey: #f8f9fa;
  --background-dark: #ecf0f1;
  
  --border-color: #ddd;
  --border-radius: 8px;
  --shadow-light: 0 2px 10px rgba(0,0,0,0.1);
  --shadow-medium: 0 4px 20px rgba(0,0,0,0.15);
  --shadow-heavy: 0 8px 30px rgba(0,0,0,0.2);
  
  --transition: all 0.3s ease;
}

/* Container principal */
.generateur-section {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.generateur-container {
  background: var(--background-light);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
  overflow: hidden;
}

/* Bannière d'avertissement crédits */
.credits-warning-banner {
  display: flex;
  gap: 15px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
  border-bottom: 2px solid #f5a623;
  color: #5d4e37;
}

.credits-warning-banner .warning-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.credits-warning-banner .warning-content {
  flex: 1;
}

.credits-warning-banner .warning-content strong {
  display: block;
  font-size: 16px;
  color: #8b5a2b;
  margin-bottom: 8px;
}

.credits-warning-banner .warning-content p {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #5d4e37;
}

.credits-warning-banner .warning-content a {
  color: #c17d10;
  font-weight: 600;
  text-decoration: underline;
}

.credits-warning-banner .warning-content a:hover {
  color: #8b5a2b;
}

.credits-warning-banner .warning-note {
  background: rgba(255, 255, 255, 0.6);
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 3px solid #f5a623;
  margin-top: 10px !important;
}

/* Thème sombre */
:root.theme-dark .credits-warning-banner {
  background: linear-gradient(135deg, #3d3520 0%, #4a3f2a 100%);
  border-bottom-color: #d4a53a;
  color: #e8d9c0;
}

:root.theme-dark .credits-warning-banner .warning-content strong {
  color: #ffd54f;
}

:root.theme-dark .credits-warning-banner .warning-content p {
  color: #e0d0b8;
}

:root.theme-dark .credits-warning-banner .warning-content a {
  color: #ffc107;
}

:root.theme-dark .credits-warning-banner .warning-note {
  background: rgba(0, 0, 0, 0.3);
  border-left-color: #ffc107;
}

/* Responsive */
@media (max-width: 600px) {
  .credits-warning-banner {
    flex-direction: column;
    gap: 10px;
    padding: 15px;
  }

  .credits-warning-banner .warning-icon {
    font-size: 24px;
  }

  .credits-warning-banner .warning-content p {
    font-size: 13px;
  }
}

/* Panel de contrôles supérieurs */
.controls-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: var(--background-grey);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.file-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.action-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Boutons de contrôle */
.control-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.import-btn {
  background: var(--primary-color);
  color: white;
}

.import-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.secondary-btn {
  background: var(--background-dark);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}

.secondary-btn:hover {
  background: var(--text-light);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Affichage du statut et crédits */
.status-display {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

#status-text {
  font-weight: 600;
  color: var(--text-dark);
}

#gedcom-info {
  color: var(--text-medium);
}

.credits-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent-color);
  color: white;
  border-radius: var(--border-radius);
  font-weight: 600;
}

/* Container des étapes */
.steps-container {
  display: flex;
  flex-direction: column;
}

/* Indicateur d'étapes */
.steps-indicator {
  display: flex;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, var(--background-grey), var(--background-light));
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
  position: relative;
  opacity: 0.5;
  transition: var(--transition);
}

.step.active {
  opacity: 1;
}

.step.completed {
  opacity: 1;
}

.step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 20px;
  left: calc(50% + 20px);
  width: calc(120px - 40px);
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.step.completed:not(:last-child)::after {
  background: var(--success-color);
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--background-dark);
  color: var(--text-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid var(--border-color);
  position: relative;
  z-index: 2;
}

.step.active .step-number {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.step.completed .step-number {
  background: var(--success-color);
  color: white;
  border-color: var(--success-color);
}

.step-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-medium);
  text-align: center;
}

.step.active .step-label {
  color: var(--text-dark);
}

/* Contenu des étapes */
.steps-content {
  padding: 2rem;
}

.step-content {
  display: none;
  animation: fadeIn 0.5s ease;
}

.step-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* En-têtes des étapes */
.step-header {
  text-align: center;
  margin-bottom: 2rem;
}

.step-header h3 {
  font-size: 1.5rem;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.step-header p {
  color: var(--text-medium);
  font-size: 1rem;
}

/* Étape 1: Import GEDCOM */
.gedcom-import-zone {
  margin: 2rem 0;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 3rem 2rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--primary-color);
  background: var(--background-grey);
}

.drop-zone.dragover {
  border-color: var(--primary-color);
  background: var(--background-grey);
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.drop-zone h4 {
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.drop-zone p {
  color: var(--text-medium);
  margin-bottom: 1rem;
}

.drop-zone small {
  color: var(--text-light);
}

/* Barre de progression */
.parsing-progress {
  margin: 2rem 0;
  text-align: center;
}

.progress-container {
  width: 100%;
  margin: 2rem 0;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--background-dark);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #a76107, #d4851b);
  width: 0%;
  transition: width 0.3s linear;
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.progress-percentage {
  font-weight: 600;
  color: var(--primary-color);
}

.progress-time {
  color: var(--text-medium);
  font-size: 0.85rem;
}

.progress-text {
  color: var(--text-medium);
  font-weight: 500;
  text-align: center;
}

/* Résumé GEDCOM */
.gedcom-summary {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--background-grey);
  border-radius: var(--border-radius);
  text-align: center;
}

.summary-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-medium);
  font-weight: 600;
}

/* Boutons de navigation */
.continue-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto;
}

.continue-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
}

.continue-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Recherche et filtres */
.person-search {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-input {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
}


/* Listes de personnes */
.persons-list-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.persons-list {
  display: flex;
  flex-direction: column;
}

.person-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.person-item:hover {
  background: var(--background-grey);
}

.person-item.selected {
  background: var(--primary-color);
  color: white;
}

.person-item:last-child {
  border-bottom: none;
}

.person-icon {
  font-size: 1.5rem;
  margin-right: 1rem;
}

.person-details {
  flex: 1;
}

.person-name {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.person-info {
  font-size: 0.85rem;
  opacity: 0.8;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.person-item.selected .person-info {
  opacity: 0.9;
}

/* Info de lignée (étape 3) */
.lineage-info {
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--background-grey);
  border-radius: var(--border-radius);
  text-align: center;
}

.selected-person {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.person-details strong {
  color: var(--text-dark);
}

.person-details small {
  color: var(--text-medium);
  display: block;
}

.lineage-filter {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
}

.lineage-filter label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 500;
}

/* Configuration (étape 4) */
.lineage-summary {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--background-grey);
  border-radius: var(--border-radius);
}

.selected-lineage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.lineage-person {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lineage-arrow {
  font-size: 1.5rem;
  color: var(--primary-color);
  font-weight: bold;
}

.person-info {
  display: flex;
  flex-direction: column;
}

.generation-info {
  text-align: center;
  color: var(--text-medium);
}

.config-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.config-group h5 {
  margin-bottom: 1rem;
  color: var(--text-dark);
  font-size: 1.1rem;
}

.config-help {
  font-size: 0.85rem;
  color: var(--text-medium);
  margin: -0.5rem 0 1rem 0;
  font-style: italic;
}

.radio-group, .checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.info-text {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
}

.info-text p {
  margin: 0;
  color: var(--text-medium);
  line-height: 1.5;
}

.info-text strong {
  color: var(--primary-color);
}

.radio-group label, .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.radio-group label:hover, .checkbox-group label:hover {
  background: var(--background-grey);
}

.length-slider {
  margin-top: 1rem;
}

.length-slider input[type="range"] {
  width: 100%;
  margin: 1rem 0;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-medium);
}

#length-display {
  font-weight: 600;
  color: var(--text-dark);
}

/* Actions des étapes */
.step-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.back-btn {
  background: var(--background-dark);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
}

.back-btn:hover {
  background: var(--text-light);
}

/* Étape 5: Génération */
.generation-state {
  margin: 2rem 0;
}

.generation-summary {
  padding: 1.5rem;
  background: var(--background-grey);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
}

.summary-details p {
  margin: 0.5rem 0;
  color: var(--text-medium);
}

.summary-details strong {
  color: var(--text-dark);
}

.cost-info {
  padding: 1.5rem;
  background: var(--accent-color);
  color: white;
  border-radius: var(--border-radius);
  margin-bottom: 2rem;
  text-align: center;
}

.cost-info h4 {
  margin-bottom: 0.5rem;
}

.generate-btn {
  background: linear-gradient(135deg, var(--success-color), #2ecc71);
  color: white;
  border: none;
  padding: 1.5rem 3rem;
  border-radius: var(--border-radius);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 auto;
  box-shadow: var(--shadow-medium);
}

.generate-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-heavy);
}

/* Animation de génération */
.progress-animation {
  text-align: center;
  margin: 2rem 0;
}

.ai-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-20px); }
  60% { transform: translateY(-10px); }
}

.generation-steps {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.gen-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.3;
  transition: var(--transition);
  min-width: 120px;
}

.gen-step.active {
  opacity: 1;
  color: var(--primary-color);
}

.gen-step.completed {
  opacity: 1;
  color: var(--success-color);
}

.step-icon {
  font-size: 2rem;
}

/* Actions de l'histoire */
.success-header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--success-color), #2ecc71);
  color: white;
  border-radius: var(--border-radius);
}

.story-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.action-btn.primary {
  background: var(--primary-color);
  color: white;
}

.action-btn.primary:hover {
  background: var(--primary-dark);
}

.action-btn.secondary {
  background: var(--background-dark);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}

.action-btn.secondary:hover {
  background: var(--text-light);
}

/* Menu déroulant de téléchargement */
.download-dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-arrow {
  margin-left: 0.5rem;
  font-size: 0.7em;
  transition: transform 0.3s;
}

.download-dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.download-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 0.5rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 1000;
}

.download-dropdown.active .download-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.download-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.download-option:hover {
  background: var(--background-grey);
}

.download-option:first-child {
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
}

.download-option:last-child {
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
}

.download-option .format-icon {
  font-size: 1.5rem;
}

.download-option .format-name {
  font-weight: 600;
  color: var(--text-dark);
  display: block;
  font-size: 0.95rem;
}

.download-option .format-desc {
  font-size: 0.75rem;
  color: var(--text-medium);
  display: block;
}

.download-option:hover .format-name {
  color: var(--primary-color);
}

/* Modal de lecture */
.story-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}

.story-modal-content {
  background: white;
  border-radius: var(--border-radius);
  max-width: 1200px;
  max-height: 90vh;
  width: 95%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-heavy);
}

.story-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
}

.story-modal-header h3 {
  margin: 0;
  color: var(--text-dark);
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-medium);
  padding: 0.25rem;
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal-btn:hover {
  background: var(--background-grey);
  color: var(--text-dark);
}

.story-modal-body {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.story-content {
  line-height: 1.8;
  font-size: 1rem;
  color: var(--text-dark);
}

.story-modal-footer {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-color);
}

.modal-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border-color);
  background: var(--background-light);
  color: var(--text-dark);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
}

.modal-btn:hover {
  background: var(--background-grey);
}

.modal-btn.secondary {
  background: var(--background-grey);
}

.modal-btn.secondary:hover {
  background: var(--background-dark);
}

.modal-btn.danger {
  background: var(--error-color);
  color: white;
  border-color: var(--error-color);
}

.modal-btn.danger:hover {
  background: #c0392b;
  border-color: #c0392b;
}

/* Responsive */
@media (max-width: 768px) {
  .generateur-section {
    margin: 1rem auto;
    padding: 0 0.5rem;
  }
  
  .controls-panel {
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
  }
  
  .file-controls, .action-controls {
    justify-content: center;
  }
  
  .steps-indicator {
    padding: 1rem;
  }
  
  .step {
    min-width: 80px;
  }
  
  .step:not(:last-child)::after {
    left: calc(50% + 15px);
    width: calc(80px - 30px);
  }
  
  .step-label {
    font-size: 0.75rem;
  }
  
  .steps-content {
    padding: 1rem;
  }
  
  .summary-stats {
    gap: 1rem;
  }
  
  .config-options {
    grid-template-columns: 1fr;
  }
  
  .selected-lineage {
    flex-direction: column;
    gap: 1rem;
  }
  
  .lineage-arrow {
    transform: rotate(90deg);
  }
  
  .story-actions {
    flex-direction: column;
  }
  
  .generation-steps {
    flex-direction: column;
    align-items: center;
  }
  
  .story-modal {
    padding: 1rem;
  }
  
  .story-modal-content {
    max-height: 95vh;
  }
  
  .story-modal-header,
  .story-modal-body,
  .story-modal-footer {
    padding: 1rem;
  }
}

/* ========== HISTORIQUE DES HISTOIRES ========== */

/* Overlay des modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 1rem;
}

/* Modal d'historique */
#history-modal .modal-dialog,
#delete-confirm-modal .modal-dialog {
  background: var(--background-light);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-heavy);
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#history-modal .modal-dialog.modal-small,
#delete-confirm-modal .modal-dialog.modal-small {
  max-width: 500px;
}

/* Header et body des modals */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--background-grey);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-dark);
}

.modal-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--background-grey);
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-medium);
  cursor: pointer;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.close-btn:hover {
  color: var(--error-color);
}

/* Contrôles de l'historique */
.history-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.sort-select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--background-light);
  color: var(--text-dark);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.sort-select:hover {
  border-color: var(--primary-color);
}

.sort-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(44, 85, 48, 0.1);
}

/* Liste des histoires */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 500px;
  overflow-y: auto;
  padding: 0.5rem;
}

.history-item {
  background: var(--background-grey);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.history-item:hover {
  box-shadow: var(--shadow-light);
  border-color: var(--primary-color);
}

.history-item-info {
  flex: 1;
}

.history-item-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.history-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-medium);
  margin-bottom: 0.5rem;
}

.history-item-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.history-item-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-light);
}

.history-item-stat {
  background: var(--background-light);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.history-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.history-action-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--background-light);
  color: var(--text-dark);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.history-action-btn:hover {
  background: var(--background-grey);
  transform: translateY(-1px);
}

.history-action-btn.view-btn:hover {
  background: var(--info-color);
  color: white;
  border-color: var(--info-color);
}

.history-action-btn.download-btn:hover {
  background: var(--success-color);
  color: white;
  border-color: var(--success-color);
}

.history-action-btn.delete-btn:hover {
  background: var(--error-color);
  color: white;
  border-color: var(--error-color);
}

/* Dropdown des formats d'export dans l'historique */
.history-download-dropdown {
  position: relative;
  display: inline-block;
}

.history-download-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 0.5rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 150px;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 1000;
}

.history-download-dropdown.active .history-download-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.history-download-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
  font-size: 0.85rem;
}

.history-download-option:hover {
  background: var(--background-grey);
}

.history-download-option:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.history-download-option .format-icon {
  font-size: 1rem;
}

.history-download-option .format-name {
  color: var(--text-dark);
  font-weight: 500;
}

/* Message vide */
.no-history {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-medium);
}

.no-history p {
  font-size: 1.1rem;
  margin: 0;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.pagination-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--background-light);
  color: var(--text-dark);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.pagination-btn:not(:disabled):hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#history-page-info {
  color: var(--text-medium);
  font-size: 0.9rem;
}

/* Loading spinner */
.loading-spinner {
  text-align: center;
  padding: 2rem;
  color: var(--text-medium);
  font-size: 1rem;
}

/* Warning text dans modal de suppression */
.warning-text {
  color: var(--error-color);
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.story-title-preview {
  background: var(--background-grey);
  padding: 0.75rem;
  border-radius: var(--border-radius);
  border-left: 3px solid var(--error-color);
  font-weight: 600;
  color: var(--text-dark);
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .history-item {
    flex-direction: column;
  }

  .history-item-actions {
    width: 100%;
    justify-content: stretch;
  }

  .history-action-btn {
    flex: 1;
    justify-content: center;
  }

  .history-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-select {
    width: 100%;
  }

  #history-modal .modal-dialog {
    max-height: 95vh;
  }
}

/* ========== THÈME SOMBRE ========== */
:root.theme-dark .generateur-container {
  background: var(--bg-secondary);
  color: var(--text-alt);
}

:root.theme-dark .controls-panel {
  background: var(--bg-page);
  border-bottom-color: var(--btn-border);
}

:root.theme-dark #status-text,
:root.theme-dark .step-header h3,
:root.theme-dark .person-name,
:root.theme-dark .person-details strong,
:root.theme-dark .history-item-title {
  color: var(--text-alt);
}

:root.theme-dark #gedcom-info,
:root.theme-dark .step-header p,
:root.theme-dark .person-info,
:root.theme-dark .summary-details p,
:root.theme-dark .history-item-meta,
:root.theme-dark .no-history,
:root.theme-dark #history-page-info {
  color: var(--text-alt-muted);
}

:root.theme-dark .secondary-btn {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .secondary-btn:hover {
  background: var(--arrow-bg);
}

:root.theme-dark .steps-indicator {
  background: var(--bg-page);
  border-bottom-color: var(--btn-border);
}

:root.theme-dark .step-number {
  background: var(--bg-page);
  color: var(--text-alt-muted);
  border-color: var(--btn-border);
}

:root.theme-dark .step-label {
  color: var(--text-alt-muted);
}

:root.theme-dark .step.active .step-label {
  color: var(--text-alt);
}

:root.theme-dark .drop-zone {
  border-color: var(--btn-border);
  background: var(--bg-page);
}

:root.theme-dark .drop-zone:hover,
:root.theme-dark .drop-zone.dragover {
  border-color: #d4851b;
  background: var(--bg-secondary);
}

:root.theme-dark .drop-zone h4 {
  color: var(--text-alt);
}

:root.theme-dark .drop-zone p {
  color: var(--text-alt-muted);
}

:root.theme-dark .drop-zone small {
  color: var(--text-alt-muted);
  opacity: 0.7;
}

:root.theme-dark .progress-bar {
  background: var(--bg-page);
}

:root.theme-dark .progress-fill {
  background: linear-gradient(90deg, #d4851b, #FFB061);
}

:root.theme-dark .progress-text {
  color: var(--text-alt-muted);
}

:root.theme-dark .progress-percentage {
  color: #FFB061;
}

:root.theme-dark .progress-time {
  color: var(--text-alt-muted);
}

:root.theme-dark .gedcom-summary,
:root.theme-dark .lineage-summary,
:root.theme-dark .lineage-info,
:root.theme-dark .generation-summary {
  background: var(--bg-page);
}

:root.theme-dark .stat-number {
  color: #FFB061;
}

:root.theme-dark .stat-label,
:root.theme-dark .generation-info {
  color: var(--text-alt-muted);
}

:root.theme-dark .persons-list-container {
  border-color: var(--btn-border);
  background: var(--bg-page);
}

:root.theme-dark .person-item {
  border-bottom-color: var(--btn-border);
  color: var(--text-alt);
}

:root.theme-dark .person-item:hover {
  background: var(--bg-secondary);
}

:root.theme-dark .search-input {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .search-input::placeholder {
  color: var(--text-alt-muted);
  opacity: 0.6;
}

:root.theme-dark .search-input:focus {
  border-color: #FFB061;
}

:root.theme-dark .info-text {
  background: var(--bg-page);
  border-color: var(--btn-border);
}

:root.theme-dark .info-text p {
  color: var(--text-alt-muted);
}

:root.theme-dark .info-text strong {
  color: #FFB061;
}

:root.theme-dark .config-group h5 {
  color: var(--text-alt);
}

:root.theme-dark .config-help {
  color: var(--text-alt-muted);
}

:root.theme-dark .radio-group label,
:root.theme-dark .checkbox-group label {
  color: var(--text-alt);
}

:root.theme-dark .radio-group label:hover,
:root.theme-dark .checkbox-group label:hover {
  background: var(--bg-page);
}

:root.theme-dark #length-display {
  color: var(--text-alt);
}

:root.theme-dark .slider-labels {
  color: var(--text-alt-muted);
}

:root.theme-dark .step-actions {
  border-top-color: var(--btn-border);
}

:root.theme-dark .back-btn {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .back-btn:hover {
  background: var(--arrow-bg);
}

:root.theme-dark .cost-info {
  background: #b8860b;
}

:root.theme-dark .summary-details strong {
  color: var(--text-alt);
}

:root.theme-dark .story-modal-content,
:root.theme-dark .modal-dialog {
  background: var(--bg-secondary);
}

:root.theme-dark .story-modal-header,
:root.theme-dark .modal-header {
  background: var(--bg-page);
  border-bottom-color: var(--btn-border);
}

:root.theme-dark .story-modal-header h3,
:root.theme-dark .modal-header h2 {
  color: var(--text-alt);
}

:root.theme-dark .story-modal-body,
:root.theme-dark .modal-body {
  background: var(--bg-secondary);
  color: var(--text-alt);
}

:root.theme-dark .story-content {
  color: var(--text-alt);
}

:root.theme-dark .story-modal-footer,
:root.theme-dark .modal-footer {
  background: var(--bg-page);
  border-top-color: var(--btn-border);
}

:root.theme-dark .close-modal-btn,
:root.theme-dark .close-btn {
  color: var(--text-alt-muted);
}

:root.theme-dark .close-modal-btn:hover,
:root.theme-dark .close-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-alt);
}

:root.theme-dark .modal-btn {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .modal-btn:hover {
  background: var(--bg-secondary);
}

:root.theme-dark .modal-btn.secondary {
  background: var(--bg-secondary);
}

:root.theme-dark .modal-btn.secondary:hover {
  background: var(--arrow-bg);
}

:root.theme-dark .action-btn.secondary {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .action-btn.secondary:hover {
  background: var(--arrow-bg);
}

:root.theme-dark .download-menu {
  background: var(--bg-secondary);
  border-color: var(--btn-border);
}

:root.theme-dark .download-option {
  color: var(--text-alt);
}

:root.theme-dark .download-option:hover {
  background: var(--bg-page);
}

:root.theme-dark .download-option .format-name {
  color: var(--text-alt);
}

:root.theme-dark .download-option .format-desc {
  color: var(--text-alt-muted);
}

:root.theme-dark .download-option:hover .format-name {
  color: #FFB061;
}

:root.theme-dark .history-item {
  background: var(--bg-page);
  border-color: var(--btn-border);
}

:root.theme-dark .history-item:hover {
  border-color: #FFB061;
}

:root.theme-dark .history-item-stat {
  background: var(--bg-secondary);
  border-color: var(--btn-border);
  color: var(--text-alt-muted);
}

:root.theme-dark .history-action-btn {
  background: var(--bg-secondary);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .history-action-btn:hover {
  background: var(--bg-page);
}

:root.theme-dark .history-download-menu {
  background: var(--bg-secondary);
  border-color: var(--btn-border);
}

:root.theme-dark .history-download-option {
  color: var(--text-alt);
}

:root.theme-dark .history-download-option:hover {
  background: var(--bg-page);
}

:root.theme-dark .history-download-option:not(:last-child) {
  border-bottom-color: var(--btn-border);
}

:root.theme-dark .history-download-option .format-name {
  color: var(--text-alt);
}

:root.theme-dark .sort-select {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .sort-select:hover,
:root.theme-dark .sort-select:focus {
  border-color: #FFB061;
}

:root.theme-dark .pagination-btn {
  background: var(--bg-page);
  color: var(--text-alt);
  border-color: var(--btn-border);
}

:root.theme-dark .pagination-btn:not(:disabled):hover {
  background: #a76107;
  border-color: #a76107;
}

:root.theme-dark .warning-text {
  color: #ff6b6b;
}

:root.theme-dark .story-title-preview {
  background: var(--bg-page);
  border-left-color: #ff6b6b;
  color: var(--text-alt);
}

:root.theme-dark .loading-spinner {
  color: var(--text-alt-muted);
}