/**
 * GEDCOM Implex - Analyseur d'implexes généalogiques
 * Interface moderne cohérente avec les autres outils Gedcom Studio
 */

/* ==================== VARIABLES CSS ==================== */
:root {
  /* Couleurs principales (cohérentes avec gedcom-studio.css) */
  --primary-color: #a76107;
  --secondary-color: #2c3e50;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --error-color: #e74c3c;
  --info-color: #3498db;
  
  /* Couleurs neutres */
  --bg-light: #f8f9fa;
  --bg-dark: #2c3e50;
  --text-light: #666;
  --text-dark: #333;
  --border-color: #ddd;
  --white: #ffffff;
  
  /* Ombres */
  --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);
  
  /* Bordures et transitions */
  --border-radius: 12px;
  --transition: all 0.3s ease;
  
  /* Couleurs spécifiques aux implexes */
  --implexe-gold: #d4af37;
  --implexe-silver: #c0c0c0;
  --implexe-bronze: #cd7f32;
  --podium-bg: linear-gradient(135deg, #fff8e7 0%, #f5f0e7 100%);
}

/* ==================== CONTENEUR PRINCIPAL ==================== */
.implex-container {
  max-width: 1200px;
  margin: 30px auto;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-heavy);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==================== EN-TÊTE ==================== */
.implex-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #8b5a0a 100%);
  color: var(--white);
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.implex-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
  z-index: 1;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(180deg); }
}

.implex-header-content {
  position: relative;
  z-index: 2;
}

.implex-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 15px 0;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.implex-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin: 0;
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

/* ==================== SÉLECTEUR DE PERSONNE ==================== */
.person-selector-section {
  background: var(--bg-light);
  padding: 30px 40px;
  border-bottom: 2px solid #e9ecef;
}

.selector-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 25px;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
}

.selector-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 20px;
}

.selector-icon {
  font-size: 2rem;
  color: var(--primary-color);
}

.selector-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.selector-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: end;
}

.search-group {
  position: relative;
}

.search-label {
  display: block;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.person-search {
  width: 100%;
  padding: 12px 16px 12px 45px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: var(--white);
  transition: var(--transition);
}

.person-search:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(167, 97, 7, 0.1);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1.1rem;
}

.analyze-btn {
  background: linear-gradient(135deg, var(--primary-color) 0%, #8b5a0a 100%);
  color: var(--white);
  border: none;
  padding: 12px 30px;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  min-width: 150px;
  box-shadow: var(--shadow-light);
}

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

.analyze-btn:disabled {
  background: var(--text-light);
  cursor: not-allowed;
  transform: none;
}

/* Dropdown des suggestions */
.person-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 2px solid var(--primary-color);
  border-top: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  box-shadow: var(--shadow-medium);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
}

.person-option {
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: var(--transition);
  position: relative;
}

.person-option:hover {
  background: #f8f9fa;
}

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

/* Option de recherche simple (ancienne) */
.person-option:not(.advanced):not(.no-result) {
  padding: 12px 16px;
}

.person-name {
  font-weight: 600;
  color: var(--text-dark);
}

.person-dates {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* Option de recherche avancée (nouvelle) */
.person-option.advanced {
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.person-main-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.person-name-section {
  flex: 1;
}

.person-full-name {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 1rem;
  margin-bottom: 2px;
}

.person-nicknames {
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
}

.person-relevance {
  display: flex;
  align-items: center;
  margin-left: 15px;
}

.relevance-score {
  background: var(--primary-color);
  color: var(--white);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 30px;
  text-align: center;
}

.person-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}

.person-dates-places {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-item {
  font-size: 0.8rem;
  color: var(--text-light);
  background: var(--bg-light);
  padding: 2px 6px;
  border-radius: 4px;
}

.detail-item.dates {
  background: #e3f2fd;
  color: #1565c0;
}

.detail-item.places {
  background: #e8f5e8;
  color: #2e7d32;
}

.match-reason {
  font-size: 0.75rem;
  color: var(--secondary-color);
  background: #f3e5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.person-rank {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--secondary-color);
  color: var(--white);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* Aucun résultat */
.person-option.no-result {
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  cursor: default;
}

.person-option.no-result:hover {
  background: var(--white);
}

.no-result-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.no-result-text {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 5px;
}

.search-tips {
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
}

/* ==================== SECTION RÉSULTATS ==================== */
.results-section {
  padding: 40px;
  background: var(--white);
}

.results-header {
  text-align: center;
  margin-bottom: 40px;
}

.selected-person {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  background: var(--podium-bg);
  padding: 20px 30px;
  border-radius: var(--border-radius);
  border: 2px solid var(--primary-color);
  margin-bottom: 20px;
}

.selected-person-icon {
  font-size: 2.5rem;
  color: var(--primary-color);
}

.selected-person-info h3 {
  margin: 0 0 5px 0;
  font-size: 1.5rem;
  color: var(--text-dark);
}

.selected-person-info p {
  margin: 0;
  color: var(--text-light);
}

/* ==================== PODIUM DES IMPLEXES ==================== */
.podium-section {
  background: var(--podium-bg);
  border-radius: var(--border-radius);
  padding: 30px;
  margin-bottom: 30px;
  border: 2px solid #f0e68c;
}

.podium-header {
  text-align: center;
  margin-bottom: 30px;
}

.podium-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.podium-icon {
  font-size: 2rem;
  color: var(--implexe-gold);
}

.podium-subtitle {
  color: var(--text-light);
  margin: 0;
}

.podium-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.podium-place {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 25px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-medium);
  transition: var(--transition);
  cursor: pointer;
}

.podium-place:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-heavy);
}

.podium-place.first {
  border-top: 4px solid var(--implexe-gold);
}

.podium-place.second {
  border-top: 4px solid var(--implexe-silver);
}

.podium-place.third {
  border-top: 4px solid var(--implexe-bronze);
}

.podium-rank {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--white);
  font-size: 0.9rem;
}

.podium-place.first .podium-rank {
  background: var(--implexe-gold);
}

.podium-place.second .podium-rank {
  background: var(--implexe-silver);
}

.podium-place.third .podium-rank {
  background: var(--implexe-bronze);
}

.podium-person {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 15px 0 5px 0;
}

.podium-dates {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 10px;
  font-style: italic;
}

.podium-count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 5px;
}

.podium-label {
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ==================== GRAPHIQUE EN BARRES ==================== */
.chart-section {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
}

.chart-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 25px;
}

.chart-icon {
  font-size: 1.8rem;
  color: var(--info-color);
}

.chart-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.chart-container {
  position: relative;
  height: 500px;
  overflow: hidden;
}

.chart-bars {
  display: flex;
  align-items: end;
  height: 100%;
  gap: 15px;
  padding: 40px 10px 80px 10px;
  justify-content: space-around;
}

.chart-bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary-color) 0%, #8b5a0a 100%);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 20px;
  transition: var(--transition);
  cursor: pointer;
}

.chart-bar:hover {
  filter: brightness(1.1);
  transform: scaleY(1.05);
}

.chart-bar-info {
  position: absolute;
  bottom: -70px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 100%;
  max-width: 120px;
  padding: 0 5px;
}

.chart-bar-name {
  font-size: 0.75rem;
  color: var(--text-dark);
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 3px;
  height: 2.2em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  hyphens: auto;
}

.chart-bar-dates {
  font-size: 0.65rem;
  color: var(--text-light);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-value {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  background: #000000;
  color: var(--white);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  opacity: 1;
  box-shadow: var(--shadow-light);
  min-width: 30px;
  text-align: center;
}

/* ==================== LISTE DÉTAILLÉE ==================== */
.detailed-list-section {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: var(--shadow-light);
  border: 1px solid var(--border-color);
}

.detailed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
}

.detailed-title-group {
  display: flex;
  align-items: center;
  gap: 15px;
}

.detailed-icon {
  font-size: 1.8rem;
  color: var(--success-color);
}

.detailed-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.detailed-filters {
  display: flex;
  gap: 15px;
}

.filter-btn {
  background: var(--bg-light);
  border: 2px solid var(--border-color);
  color: var(--text-dark);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  font-weight: 500;
}

.filter-btn.active {
  background: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
}

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

.implexes-list {
  display: grid;
  gap: 15px;
}

.implexe-item {
  background: var(--bg-light);
  border-radius: var(--border-radius);
  padding: 20px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
}

.implexe-item:hover {
  background: var(--white);
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.implexe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.implexe-person {
  display: flex;
  align-items: center;
  gap: 15px;
}

.implexe-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
}

.implexe-info h4 {
  margin: 0 0 5px 0;
  font-size: 1.2rem;
  color: var(--text-dark);
}

.implexe-info p {
  margin: 0;
  color: var(--text-light);
  font-size: 0.9rem;
}

.implexe-count {
  text-align: center;
}

.count-number {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
  display: block;
}

.count-label {
  font-size: 0.8rem;
  color: var(--text-light);
  text-transform: uppercase;
}

.implexe-paths {
  margin-top: 15px;
}

.paths-summary {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.paths-list {
  display: none;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.implexe-item.expanded .paths-list {
  display: block;
}

.path-item {
  background: var(--white);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 10px;
  border-left: 4px solid var(--info-color);
}

.path-item:last-child {
  margin-bottom: 0;
}

.path-degree {
  font-weight: 600;
  color: var(--info-color);
  font-size: 0.9rem;
}

.path-chain {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-dark);
  line-height: 1.4;
}

.path-arrow {
  color: var(--primary-color);
  margin: 0 5px;
}

/* ==================== ÉTATS VIDES ==================== */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.no-results-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  color: var(--text-light);
}

.no-results h3 {
  color: var(--text-dark);
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.no-results p {
  color: var(--text-light);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 500px;
  margin: 0 auto;
}

/* ==================== LOADING ==================== */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-light);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--bg-light);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-dark);
  font-size: 1.1rem;
  font-weight: 500;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .implex-container {
    margin: 15px;
  }
  
  .implex-header {
    padding: 30px 20px;
  }
  
  .implex-title {
    font-size: 2rem;
  }
  
  .person-selector-section {
    padding: 20px;
  }
  
  .selector-controls {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .results-section {
    padding: 20px;
  }
  
  .podium-container {
    grid-template-columns: 1fr;
  }
  
  .detailed-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .detailed-filters {
    width: 100%;
    justify-content: space-between;
  }
  
  .implexe-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .chart-container {
    height: 300px;
  }
  
  .chart-bars {
    gap: 5px;
  }
  
  .chart-bar-label {
    font-size: 0.7rem;
    width: 80px;
  }
}

@media (max-width: 480px) {
  .implex-header {
    padding: 20px 15px;
  }
  
  .implex-title {
    font-size: 1.8rem;
  }
  
  .person-selector-section,
  .results-section {
    padding: 15px;
  }
  
  .selector-card,
  .chart-section,
  .detailed-list-section {
    padding: 20px;
  }
  
  .podium-section {
    padding: 20px;
  }
  
  .chart-container {
    height: 250px;
  }
  
  .detailed-filters {
    flex-direction: column;
  }
  
  .filter-btn {
    text-align: center;
  }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ==================== CORRECTIONS COMPATIBILITÉ ==================== */
/* Correction pour que la grille des stats GEDCOM reste sur 4 colonnes */
.file-info .info-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 1.5rem !important;
}

@media (max-width: 1024px) {
  .file-info .info-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 600px) {
  .file-info .info-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==================== UTILITAIRES ==================== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

/* ==================== MINI ARBRE IMPLEX ==================== */
.mini-tree-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mini-tree-modal.active {
  opacity: 1;
  visibility: visible;
}

.mini-tree-container {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 25px 20px;
  max-width: 700px; /* Augmenté de 500px à 700px */
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-heavy);
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.mini-tree-modal.active .mini-tree-container {
  transform: scale(1);
}

.mini-tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px; /* Réduit de 30px */
  padding-bottom: 15px; /* Réduit de 20px */
  border-bottom: 2px solid var(--border-color);
}

.mini-tree-title {
  font-size: 1.2rem; /* Réduit de 1.4rem */
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
}

.mini-tree-close {
  background: none;
  border: none;
  font-size: 1.3rem; /* Réduit de 1.5rem */
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
  width: 35px; /* Réduit de 40px */
  height: 35px; /* Réduit de 40px */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.mini-tree-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.mini-tree-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px; /* Réduit de 20px */
  padding: 10px 0; /* Réduit de 20px */
}

.tree-person-box {
  background: var(--white);
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  padding: 8px 20px; /* Augmenté le padding horizontal de 15px à 20px */
  text-align: center;
  min-width: 280px; /* Augmenté de 180px à 280px */
  max-width: 280px; /* Force toutes les boîtes à 280px */
  box-shadow: var(--shadow-light);
  position: relative;
}

.tree-person-box.implexed {
  background: var(--podium-bg);
  border-color: var(--implexe-gold);
  border-width: 3px;
}

.tree-person-box.root {
  background: #e3f2fd;
  border-color: var(--info-color);
}

.tree-person-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dark);
  margin-bottom: 2px;
  white-space: nowrap; /* Force le texte sur une ligne */
  overflow: hidden;
  text-overflow: ellipsis; /* Au cas où un nom serait vraiment trop long */
}

.tree-person-dates {
  font-size: 0.75rem; /* Réduit de 0.9rem */
  color: var(--text-light);
  font-style: italic;
}

.tree-person-label {
  position: absolute;
  top: -10px; /* Ajusté de -12px */
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  padding: 1px 6px; /* Réduit de 2px 10px */
  font-size: 0.65rem; /* Réduit de 0.75rem */
  font-weight: 600;
  color: var(--primary-color);
  border-radius: 8px; /* Réduit de 10px */
  border: 1.5px solid var(--primary-color); /* Réduit de 2px */
}

.tree-person-box.implexed .tree-person-label {
  color: var(--implexe-gold);
  border-color: var(--implexe-gold);
}

.tree-person-box.root .tree-person-label {
  color: var(--info-color);
  border-color: var(--info-color);
}

.tree-connector {
  width: 2px;
  height: 12px; /* Réduit de 30px */
  background: var(--border-color);
  position: relative;
}

.tree-connector::before,
.tree-connector::after {
  content: '';
  position: absolute;
  width: 6px; /* Réduit de 8px */
  height: 6px; /* Réduit de 8px */
  border-radius: 50%;
  background: var(--primary-color);
  left: 50%;
  transform: translateX(-50%);
}

.tree-connector::before {
  top: -3px; /* Ajusté de -4px */
}

.tree-connector::after {
  bottom: -3px; /* Ajusté de -4px */
}

.path-item.clickable {
  cursor: pointer;
  transition: all 0.3s ease;
}

.path-item.clickable:hover {
  background: #e3f2fd;
  transform: translateX(5px);
}

.path-chain {
  position: relative;
}

.path-click-hint {
  font-size: 0.75rem;
  color: var(--info-color);
  margin-top: 5px;
  opacity: 0.7;
  transition: opacity 0.3s ease;
  text-align: right;
}

.path-item.clickable:hover .path-click-hint {
  opacity: 1;
}

/* Styles pour les couples dans le mini arbre */
.tree-person-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0; /* Réduit à 0 pour que la ligne touche les boîtes */
  position: relative;
}

.tree-marriage-link {
  width: 20px; /* Largeur de la ligne de connexion */
  height: 2px;
  background: var(--border-color);
  position: relative;
}

.tree-marriage-link::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--white);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.marriage-symbol {
  display: none;
}

.tree-person-box.spouse {
  background: #f5f5f5;
  border-style: dashed;
}

.tree-person-box.spouse.implexed {
  background: var(--podium-bg);
  border-color: var(--implexe-gold);
  border-style: dashed;
}

/* Ajustements pour mobile */
@media (max-width: 600px) {
  .tree-person-row {
    flex-direction: column;
    gap: 0;
  }
  
  .tree-marriage-link {
    width: 2px;
    height: 20px;
  }
  
  .mini-tree-container {
    padding: 15px; /* Réduit de 20px */
    max-width: 95%;
  }
  
  .tree-person-box {
    min-width: 150px; /* Encore plus petit sur mobile */
    padding: 6px 10px;
  }
  
  .tree-person-name {
    font-size: 0.85rem;
  }
  
  .tree-person-dates {
    font-size: 0.7rem;
  }
}

.mini-tree-container {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 25px 20px;
  max-width: 700px; /* Augmenté de 500px à 700px */
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-heavy);
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.tree-person-box {
  background: var(--white);
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  padding: 8px 20px; /* Augmenté le padding horizontal de 15px à 20px */
  text-align: center;
  min-width: 280px; /* Augmenté de 180px à 280px */
  max-width: 280px; /* Force toutes les boîtes à 280px */
  box-shadow: var(--shadow-light);
  position: relative;
}

.tree-person-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dark);
  margin-bottom: 2px;
  white-space: nowrap; /* Force le texte sur une ligne */
  overflow: hidden;
  text-overflow: ellipsis; /* Au cas où un nom serait vraiment trop long */
}

/* Ajustements pour mobile */
@media (max-width: 768px) {
  .mini-tree-container {
    max-width: 95%;
  }
  
  .tree-person-box {
    min-width: 240px; /* Un peu plus petit sur mobile */
    max-width: 240px;
    padding: 6px 15px;
  }
}

.person-gender-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 1rem;
    opacity: 0.7;
}

/* Pour les boîtes avec label, ajuster la position */
.tree-person-box.implexed .person-gender-icon,
.tree-person-box.root .person-gender-icon {
    top: 15px; /* Plus bas pour éviter le label */
}

/* Couleurs optionnelles pour les genres */
.tree-person-box .person-gender-icon {
    color: var(--text-light);
}

/* Icônes de genre avec images */
.gender-icon-img {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.person-gender-icon .gender-icon-img {
    width: 20px;
    height: 20px;
}

/* Ajustement pour mobile */
@media (max-width: 600px) {
    .person-gender-icon .gender-icon-img {
        width: 16px;
        height: 16px;
    }
}

/* Remplacez les styles .person-gender-icon par : */
.person-gender-icon {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

/* Pour les boîtes avec label, ajuster la position */
.tree-person-box.implexed .person-gender-icon,
.tree-person-box.root .person-gender-icon {
    top: 15px; /* Plus bas pour éviter le label */
}

/* Ajustement pour mobile */
@media (max-width: 600px) {
    .person-gender-icon {
        width: 16px;
        height: 16px;
    }
}