* {
  font-family: "Helvetica Neue", Arial, sans-serif;
}

.sft-container { user-select: none; width: 100%; height: 100vh; background-color: #1e1e1e; }
.sft-card {
  background: #fff; border-radius: 8px; box-shadow: 0 2px 8px #0001;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 0.9em;
  transition: box-shadow 0.2s; border: 2px solid #fff;
  width: 90px; height: 130px; justify-content: flex-start;
}
.sft-card:hover { box-shadow: 0 4px 16px #0002; }
.sft-img {
  width: 50px; height: 50px; border-radius: 50%; background-size: cover;
  background-position: center; border: 2px solid #eee; flex-shrink: 0;
}
.sft-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex-grow: 1;
  min-width: 0;
  width: 100%;
}
.sft-name { 
  font-weight: bold; 
  margin-bottom: 2px;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9em;
  max-width: 100%;
  word-wrap: break-word;
  line-height: 1.1;
  text-align: center;
}

.sft-last-name {
  margin-bottom: 10px;
}
.sft-dates {
  font-size: 0.7em;
  color: #343434;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  line-height: 1.2;
  word-wrap: break-word;
}

.sft-date-n, .sft-date-d {
  font-size: 0.7em;
  color: #343434;
  text-align: center;
  line-height: 1.1;
  margin: 0;
  max-width: 100%;
  word-wrap: break-word;
}

.sft-date-n, .sft-date-d {
  font-size: 0.7em;
  color: #343434;
  text-align: center;
  line-height: 1.1;
  margin: 0;
  max-width: 100%;
  word-wrap: break-word;
}

.sft-date-separator {
  width: 8px;
  height: 1px;
  background-color: #343434;
  margin: 2px auto;
}

.sft-focus { outline: 3px solid #1976d2; z-index: 2; }

/* =====================================
   STYLES POUR LA POPUP DE STATISTIQUES
   ===================================== */

#stats-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

#stats-content {
  background: white;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  animation: statsModalAppear 0.3s ease-out;
}

@keyframes statsModalAppear {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.stats-tab {
  padding: 12px 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: #666;
  font-weight: normal;
  transition: all 0.2s ease;
  border-bottom: none;
}

.stats-tab:hover {
  color: #1976d2;
  background: rgba(25, 118, 210, 0.05);
}

.stats-tab.active {
  color: #1976d2;
  font-weight: bold;
  border-bottom: 3px solid #1976d2;
}

.stat-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Responsive pour mobile */
@media (max-width: 768px) {
  #stats-content {
    width: 100vw;
    height: 100vh;
    max-height: none;
  }
  
  .stats-tab {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .stat-card {
    padding: 15px;
  }
  
  .stat-card h3 {
    font-size: 24px !important;
  }
}

/* Styles pour la barre de recherche - Tailles normales pour desktop */
.sft-search {
  position: relative;
  width: 280px;
}
.sft-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #ddd;
  border-radius: 20px;
  font-size: 14px;
  font-family: sans-serif;
  outline: none;
  transition: border-color 0.2s;
  height: 38px;
  box-sizing: border-box;
}
.sft-search-input:focus {
  border-color: #1976d2;
}

/* Styles pour les contrôles (boutons de zoom) - Tailles normales pour desktop */
.sft-controls {
  display: flex;
  gap: 8px;
}
.sft-controls button {
  width: 38px;
  height: 38px;
  border: 2px solid #ddd;
  border-radius: 19px;
  background: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sft-controls button:hover {
  border-color: #1976d2;
  background-color: #f5f5f5;
}
.sft-controls button:active {
  transform: scale(0.95);
}

/* Style spécial pour le bouton statistiques */
.sft-controls .sft-stats {
  background: #1976d2;
  color: white;
  border-color: #1976d2;
}

.sft-controls .sft-stats:hover {
  background: #1565c0;
  border-color: #1565c0;
}
.sft-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}
.sft-search-result {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  gap: 10px;
}
.sft-search-result:hover {
  background-color: #f5f5f5;
}
.sft-search-result:last-child {
  border-bottom: none;
}
.sft-search-result-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid #ddd;
  flex-shrink: 0;
}
.sft-search-result-name {
  font-weight: 500;
  font-size: 14px;
}
.sft-search-no-result {
  padding: 12px;
  text-align: center;
  color: #666;
  font-style: italic;
}

/* Styles pour la barre latérale de détails - Thème sombre moderne */
.sft-details-panel {
  position: fixed;
  color: #e0e0e0;
  top: 0;
  right: -420px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  width: 420px;
  height: 100vh;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  box-shadow: -4px 0 20px rgba(0,0,0,0.4);
  z-index: 1000;
  transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow-y: auto;
  border-left: 4px solid #64b5f6;
  backdrop-filter: blur(10px);
}

.sft-details-panel.open {
  right: 0;
}

.sft-details-panel::-webkit-scrollbar {
  width: 8px;
}

.sft-details-panel::-webkit-scrollbar-track {
  background: #2d2d2d;
}

.sft-details-panel::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 4px;
}

.sft-details-panel::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.sft-details-panel .sft-details-header {
  padding: 25px;
  border-bottom: 1px solid #404040;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.sft-details-panel .sft-details-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  border: 2px solid #64b5f6;
  background: rgba(100, 181, 246, 0.1);
  color: #64b5f6;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.sft-details-panel .sft-details-close:hover {
  background: #64b5f6;
  color: #1a1a1a;
  transform: rotate(90deg);
}

.sft-details-panel .sft-person-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 15px;
}

.sft-details-panel .sft-person-img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 4px solid #64b5f6;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(100, 181, 246, 0.3);
  transition: transform 0.3s ease;
}

.sft-details-panel .sft-person-img:hover {
  transform: scale(1.05);
}

.sft-details-panel .sft-person-info h2 {
  margin: 0 0 8px 0;
  font-size: 1.4em;
  color: #ffffff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.sft-details-panel .sft-person-info .sft-person-dates {
  color: #b0b0b0;
  font-size: 0.9em;
  margin: 0;
  font-weight: 400;
}

.sft-details-panel .sft-details-content {
  padding: 25px;
}

.sft-details-panel .sft-details-section {
  margin-bottom: 30px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid rgba(100, 181, 246, 0.1);
  transition: all 0.3s ease;
}

.sft-details-panel .sft-details-section:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(100, 181, 246, 0.2);
}

.sft-details-panel .sft-details-section h3 {
  margin: 0 0 18px 0;
  font-size: 1.2em;
  color: #64b5f6;
  border-bottom: 2px solid rgba(100, 181, 246, 0.3);
  padding-bottom: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sft-details-panel .sft-details-section h3::before {
  content: '';
  width: 4px;
  height: 20px;
  background: linear-gradient(135deg, #64b5f6, #42a5f5);
  border-radius: 2px;
}

.sft-details-panel .sft-info-row {
  display: flex;
  margin-bottom: 12px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sft-details-panel .sft-info-row:last-child {
  border-bottom: none;
}

.sft-details-panel .sft-info-label {
  font-weight: 600;
  color: #a0a0a0;
  min-width: 100px;
  margin-right: 15px;
  margin-top: 5px;
  flex-shrink: 0;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sft-details-panel .sft-info-value {
  color: #e0e0e0;
  flex-grow: 1;
  line-height: 1.5;
  font-weight: 400;
}

.sft-details-panel .sft-family-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sft-details-panel .sft-family-list li {
  padding: 12px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}

.sft-details-panel .sft-family-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: linear-gradient(135deg, #64b5f6, #42a5f5);
  transition: width 0.3s ease;
}

.sft-details-panel .sft-family-list li:hover {
  background: rgba(100, 181, 246, 0.1);
  transform: translateX(5px);
  color: #ffffff;
}

.sft-details-panel .sft-family-list li:hover::before {
  width: 4px;
}

.sft-details-panel .sft-family-list li:last-child {
  border-bottom: none;
}

.sft-details-panel .sft-family-list li:active {
  transform: translateX(3px) scale(0.98);
}

.sft-details-panel .sft-relationship-type {
  font-size: 0.8em;
  color: #64b5f6;
  font-weight: 500;
  margin-left: 8px;
  opacity: 0.8;
}

/* ================================ */
/* STYLES MOBILES ET TABLETTES     */
/* ================================ */

/* Tablettes et écrans moyens */
@media (max-width: 768px) {
  .sft-container .sft-search {
    width: 230px !important;
  }
  
  .sft-container .sft-search-input {
    padding: 10px 14px !important;
    font-size: 15px !important;
    border-radius: 22px !important;
    height: 44px !important;
    box-sizing: border-box !important;
  }
  
  .sft-container .sft-controls button {
    width: 44px !important;
    height: 44px !important;
    font-size: 16px !important;
    border-radius: 22px !important;
  }
  
  .sft-details-panel {
    width: 380px;
    right: -380px;
  }
}

/* Mobiles */
@media (max-width: 480px) {
  /* Cartes de l'arbre plus grandes et plus espacées sur mobile */
  .sft-card {
    width: 80px;
    height: 105px;
    max-height: 105px;
    padding: 5px;
    gap: 3px;
    font-size: 0.75em;
  }
  
  .sft-img {
    width: 32px;
    height: 32px;
  }
  
  .sft-name {
    font-size: 1em;
    margin-bottom: 4px;
  }
  
  .sft-dates {
    font-size: 0.85em;
  }
  
  .sft-container .sft-search {
    width: calc(100vw - 160px) !important;
    max-width: 230px !important;
  }
  
  .sft-container .sft-search-input {
    padding: 10px 14px !important;
    font-size: 15px !important;
    border-radius: 22px !important;
    border-width: 2px !important;
    height: 44px !important;
    box-sizing: border-box !important;
  }
  
  .sft-container .sft-controls {
    gap: 8px !important;
  }
  
  .sft-container .sft-controls button {
    width: 44px !important;
    height: 44px !important;
    font-size: 16px !important;
    border-radius: 22px !important;
    border-width: 2px !important;
  }
  
  .sft-controls button:active {
    transform: scale(0.92);
  }
  
  .sft-search-results {
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  }
  
  .sft-search-result {
    padding: 12px 14px;
    gap: 12px;
  }
  
  .sft-search-result-img {
    width: 36px;
    height: 36px;
  }
  
  .sft-search-result-name {
    font-size: 15px;
  }
  
  .sft-search-no-result {
    padding: 16px;
    font-size: 15px;
  }
  
  /* Panneau de détails en plein écran sur mobile */
  .sft-details-panel {
    width: 100vw;
    right: -100vw;
    border-left: none;
    border-top: 4px solid #64b5f6;
  }
  
  .sft-details-panel .sft-details-close {
    width: 36px;
    height: 36px;
    font-size: 20px;
    top: 15px;
    right: 15px;
  }
  
  .sft-details-panel .sft-person-header {
    flex-direction: column;
    text-align: center;
    gap: 15px;
  }
  
  .sft-details-panel .sft-person-img {
    width: 80px;
    height: 80px;
  }
  
  .sft-details-panel .sft-person-info h2 {
    font-size: 1.3em;
  }
  
  .sft-details-panel .sft-family-list li {
    padding: 14px 16px;
    font-size: 15px;
  }
  
  .sft-details-panel .sft-family-list li:hover {
    transform: none;
  }
  
  .sft-details-panel .sft-family-list li:active {
    transform: scale(0.98);
    background: rgba(100, 181, 246, 0.2);
  }
}

/* Très petits écrans (moins de 360px) */
@media (max-width: 360px) {
  .sft-container .sft-search {
    width: calc(100vw - 160px) !important;
    max-width: 170px !important;
  }
  
  .sft-container .sft-search-input {
    padding: 10px 14px !important;
    font-size: 15px !important;
    height: 42px !important;
    box-sizing: border-box !important;
  }
  
  .sft-container .sft-controls {
    gap: 6px !important;
  }
  
  .sft-container .sft-controls button {
    width: 42px !important;
    height: 42px !important;
    font-size: 16px !important;
    border-radius: 21px !important;
  }
  
  .sft-details-panel .sft-details-header {
    padding: 20px 15px;
  }
  
  .sft-details-panel .sft-details-content {
    padding: 20px 15px;
  }
}

/* Solution alternative pour les très petits écrans (moins de 320px) */
@media (max-width: 320px) {
  .sft-container .sft-search {
    width: calc(100vw - 20px) !important;
    max-width: none !important;
    top: 10px !important;
    left: 10px !important;
  }
  
  .sft-container .sft-search-input {
    height: 40px !important;
    font-size: 15px !important;
    padding: 10px 14px !important;
  }
  
  .sft-container .sft-controls {
    top: 60px !important;
    right: 10px !important;
    gap: 5px !important;
  }
  
  .sft-container .sft-controls button {
    width: 40px !important;
    height: 40px !important;
    font-size: 16px !important;
    border-radius: 20px !important;
  }
}

/* =====================================
   STYLES POUR LES BAR CHARTS
   ===================================== */

/* Styles pour les graphiques en barres */
.chart-container {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.chart-container:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.chart-bar {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
  border-radius: 6px 6px 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.chart-bar:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.chart-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.1) 100%);
}

.chart-label {
  font-size: 10px;
  color: #666;
  margin-top: 8px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Styles pour les bar charts dans le thème sombre */
.dark-theme .chart-container {
  background: #2d2d2d;
  color: #e0e0e0;
}

.dark-theme .chart-label {
  color: #e0e0e0;
}

/* Responsive pour les bar charts */
@media (max-width: 768px) {
  .chart-container {
    padding: 15px;
  }
  
  .chart-bar {
    min-height: 15px;
  }
  
  .chart-label {
    font-size: 9px;
    margin-top: 6px;
  }
  
  /* Graphiques en colonne sur mobile */
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  
  .ages-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}

@media (max-width: 480px) {
  .chart-container {
    padding: 10px;
  }
  
  .chart-bar {
    min-height: 12px;
    font-size: 10px;
  }
  
  .chart-label {
    font-size: 8px;
    margin-top: 4px;
  }
  
  /* Graphiques en colonne sur mobile - écrans très petits */
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }
  
  .ages-grid {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }
}

/* Amélioration de l'expérience tactile */
@media (hover: none) and (pointer: coarse) {
  .sft-container .sft-search-input:focus {
    transform: scale(1.02) !important;
    transition: transform 0.2s ease !important;
  }
  
  .sft-container .sft-controls button:active {
    transform: scale(0.9) !important;
    transition: transform 0.1s ease !important;
  }
  
  .sft-container .sft-search-result:active {
    background-color: rgba(25, 118, 210, 0.1) !important;
    transform: scale(0.98) !important;
  }
  
  /* Suppression des effets hover sur les appareils tactiles */
  .sft-card:hover {
    box-shadow: 0 2px 8px #0001 !important;
  }
  
  .sft-container .sft-search-input:hover {
    border-color: #ddd !important;
  }
  
  .sft-container .sft-controls button:hover {
    border-color: #ddd !important;
    background-color: white !important;
  }
  
  .sft-container .sft-search-result:hover {
    background-color: transparent !important;
  }
  
  /* Suppression des effets hover sur les bar charts tactiles */
  .chart-bar:hover {
    transform: none !important;
  }
}
