/* ========================================
   CSS - FUSILLÉS PREMIÈRE GUERRE MONDIALE
   Basé sur le thème morts-pour-la-france
======================================== */

/* ========================================
   1. LAYOUT PRINCIPAL
======================================== */

.fusilles-section {
  background: #f8fafc;
  padding: 3rem 0;
  min-height: 70vh;
}

.fusilles-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ========================================
   2. SECTION INTRODUCTION
======================================== */

.intro-section {
  text-align: center;
  margin-bottom: 2rem;
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.intro-section h2 {
  font-size: 2rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 1rem;
}

.intro-text {
  font-size: 1.1rem;
  color: #4a5568;
  line-height: 1.6;
}

.intro-text strong {
  color: #8B4513;
  font-weight: 700;
}

/* ========================================
   3. FORMULAIRE DE RECHERCHE
======================================== */

.search-wrapper-fusilles {
  max-width: 1100px;
  margin: 0 auto 2rem;
}

.form-fusilles {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Lignes du formulaire */
.form-line {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  align-items: stretch;
  justify-content: center;
}

.identite-line {
  justify-content: center;
}

.dates-line {
  justify-content: center;
}

.options-line {
  justify-content: center;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.buttons-line {
  justify-content: center;
  gap: 12px;
  border-top: 1px solid #eee;
  padding-top: 16px;
  margin-top: 16px;
}

/* Groupes de dates */
.date-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.group-label {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  min-width: 80px;
  white-space: nowrap;
}

/* Conteneur nom avec bouton réglages */
.nom-container {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 200px;
  width: 200px;
}

/* Bouton réglages */
.btn-settings {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  margin-right: 4px;
  border-radius: 3px;
  color: #666;
  transition: all 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-settings:hover {
  background: #f0f0f0;
  color: #8B4513;
}

.btn-settings.active {
  color: #8B4513;
  background: #F5DEB3;
}

/* Popup recherche étendue */
.extended-search-popup {
  position: absolute;
  top: -45px;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #8B4513;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 100;
  display: none;
  animation: slideDown 0.2s ease-out;
}

.extended-search-popup.active {
  display: block;
}

.extended-search-popup label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #333;
  user-select: none;
}

/* Champs de formulaire */
.input-field {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.input-field.input-nom {
  flex: 1;
  width: 100%;
}

.input-field.input-prenom {
  flex: 0 0 200px;
  width: 200px;
}

.input-field:focus {
  outline: none;
  border-color: #8B4513;
  box-shadow: 0 0 0 2px rgba(139, 69, 19, 0.1);
}

.year-field {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}

/* Boutons principaux */
.btn-rechercher {
  padding: 10px 24px;
  background: #8B4513;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-rechercher:hover {
  background: #A0522D;
}

.btn-reset {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset:hover {
  background: #f5f5f5;
}

.btn-plus-options {
  padding: 6px 12px;
  border: 1px solid #8B4513;
  background: white;
  color: #8B4513;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-plus-options:hover {
  background: #8B4513;
  color: white;
}

/* Filtres militaires */
.military-filters-line {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.filter-label {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
  font-weight: bold;
}

.filter-select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  min-width: 140px;
  max-width: 180px;
  width: 180px;
}

.filter-select:focus {
  outline: none;
  border-color: #8B4513;
}

/* Autocomplétion */
.autocomplete-container {
  position: relative;
  flex: 1;
  max-width: 260px;
}

.autocomplete-container .input-field {
  width: 100%;
  font-size: 13px;
  padding: 6px 10px;
}

.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: white;
  border: 1px solid #8B4513;
  border-radius: 4px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.suggestions-dropdown.active {
  display: block;
}

.suggestion-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-item:hover {
  background: #F5DEB3;
}

.suggestion-item .count {
  float: right;
  color: #999;
  font-size: 11px;
}

/* Compteur */
.counter-line {
  text-align: center;
  margin: 1rem 0;
  color: #666;
  font-size: 14px;
}

.counter-line strong {
  color: #8B4513;
  font-weight: 600;
}

/* ========================================
   4. SECTION RÉSULTATS
======================================== */

.results-wrapper {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0;
}

.results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #F5DEB3;
  border-radius: 4px 4px 0 0;
  font-size: 14px;
  border: 1px solid #e0e0e0;
  border-bottom: none;
}

.results-count {
  color: #666;
}

.results-count strong {
  color: #8B4513;
  font-weight: 600;
}

.per-page-select {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 13px;
  margin-left: 4px;
}

.results-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  padding: 6px 12px;
  border: 1px solid #8B4513;
  background: white;
  color: #8B4513;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.btn-action:hover {
  background: #8B4513;
  color: white;
}

/* Tableau de résultats */
#results-table {
  background: white;
  border: 1px solid #e0e0e0;
  border-top: none;
  padding: 0;
  margin-top: 0;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

/* Largeurs des colonnes pour fusillés */
.results-table th:nth-child(1),
.results-table td:nth-child(1) { width: 15%; } /* Nom */

.results-table th:nth-child(2),
.results-table td:nth-child(2) { width: 15%; } /* Prénom */

.results-table th:nth-child(3),
.results-table td:nth-child(3) { width: 10%; } /* Statut */

.results-table th:nth-child(4),
.results-table td:nth-child(4) { width: 15%; } /* Naissance */

.results-table th:nth-child(5),
.results-table td:nth-child(5) { width: 15%; } /* Décès */

.results-table th:nth-child(6),
.results-table td:nth-child(6) { width: 12%; } /* Grade */

.results-table th:nth-child(7),
.results-table td:nth-child(7) { width: 10%; } /* Réhabilitation */

.results-table th:nth-child(8),
.results-table td:nth-child(8) { width: 8%; } /* Actions */

/* En-têtes du tableau */
.results-table th {
  background: #f5f5f5;
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #e0e0e0;
  color: #333;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.results-table th:hover {
  background: #ebebeb;
}

.results-table th.sortable::after {
  content: '↕';
  position: absolute;
  right: 8px;
  opacity: 0.3;
  font-size: 12px;
}

.results-table th.sorted-asc::after {
  content: '↑';
  opacity: 1;
  color: #8B4513;
}

.results-table th.sorted-desc::after {
  content: '↓';
  opacity: 1;
  color: #8B4513;
}

/* Cellules du tableau */
.results-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #f0f0f0;
  color: #555;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
}

.results-table td small {
  display: block;
  color: #888;
  font-size: 12px;
  margin-top: 2px;
}

/* Lignes alternées */
.results-table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.results-table tbody tr:nth-child(even) {
  background: #f8f9fa;
}

.results-table tbody tr:hover {
  background: #F5DEB3 !important;
}

/* Colonnes spéciales */
.col-nom {
  font-weight: 600;
  color: #333;
}

/* Badges */
.badge {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  display: inline-block;
}

.badge-military {
  background: #E3F2FD;
  color: #1565C0;
}

.badge-civil {
  background: #FFF3E0;
  color: #E65100;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-danger {
  background: #f8d7da;
  color: #721c24;
}

/* Bouton détails */
.btn-details {
  padding: 4px 8px;
  background: #8B4513;
  color: white;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-details:hover {
  background: #A0522D;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 1.5rem;
}

.pagination button {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  min-width: 32px;
}

.pagination button:hover:not(:disabled) {
  background: #f5f5f5;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination button.active {
  background: #8B4513;
  color: white;
  border-color: #8B4513;
  font-weight: 600;
}

.pagination span {
  padding: 8px 4px;
  color: #999;
}

/* Loader */
.loader {
  text-align: center;
  padding: 3rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f0f0f0;
  border-top-color: #8B4513;
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

/* ========================================
   5. STATISTIQUES
======================================== */

.stats-section {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  margin-top: 3rem;
}

.stats-section h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 1.5rem;
  text-align: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.stat-card {
  background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  text-align: center;
  transition: all 0.3s ease;
  border: 1px solid #e2e8f0;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #8B4513, #A0522D);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(139, 69, 19, 0.15);
}

.stat-card:hover::before {
  transform: scaleX(1);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: #8B4513;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.9rem;
  color: #4a5568;
  font-weight: 500;
}

/* ========================================
   6. MODAL DÉTAILS
======================================== */

.modal-fusilles {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-fusilles.active {
  display: flex;
}

.modal-content {
  background: white;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  background: linear-gradient(135deg, #8B4513, #A0522D);
  color: white;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  opacity: 0.8;
}

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

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section h3 {
  color: #8B4513;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e0e0e0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-label {
  font-size: 0.875rem;
  color: #666;
  font-weight: 500;
}

.detail-value {
  font-size: 1rem;
  color: #333;
}

.modal-footer {
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.modal-footer .btn-action {
  padding: 8px 16px;
  background: #8B4513;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.modal-footer .btn-action:hover {
  background: #A0522D;
}

/* Contributions dans la modal */
.contributions-section {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1rem;
}

.contributions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.contribution-item {
  background: white;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.contrib-text {
  color: #333;
  line-height: 1.6;
}

.contrib-info {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f0f0f0;
  color: #666;
  font-size: 0.875rem;
}

/* ========================================
   7. LICENCE
======================================== */

.license-simple {
  text-align: center;
  padding: 1rem;
  margin: 2rem auto;
  max-width: 800px;
  font-size: 0.9rem;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 8px;
}

.license-simple a {
  color: #6b7280;
  text-decoration: underline;
}

.license-simple a:hover {
  color: #374151;
}

/* ========================================
   8. ANIMATIONS
======================================== */

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to { 
    transform: rotate(360deg); 
  }
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* ========================================
   9. RESPONSIVE
======================================== */

@media (max-width: 768px) {
  .intro-section {
    display: none;
  }
  
  .form-line {
    flex-direction: column;
    gap: 12px;
  }
  
  .date-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .nom-container,
  .input-field.input-prenom {
    flex: none;
    width: 100%;
    max-width: none;
  }
  
  .military-filters-line {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-item {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  
  .filter-select,
  .autocomplete-container {
    width: 100%;
    max-width: none;
  }
  
  .results-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  /* Masquer certaines colonnes sur mobile */
  .results-table th:nth-child(3),
  .results-table td:nth-child(3),
  .results-table th:nth-child(6),
  .results-table td:nth-child(6),
  .results-table th:nth-child(7),
  .results-table td:nth-child(7) {
    display: none;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    max-width: 100%;
    margin: 10px;
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   10. MODE SOMBRE
======================================== */

:root.theme-dark .fusilles-section {
  background: #0f0f0f;
}

:root.theme-dark .fusilles-container {
  color: #e0e0e0;
}

:root.theme-dark .intro-section {
  background: #1a1a1a;
  border: 1px solid #333;
}

:root.theme-dark .intro-section h2 {
  color: #f0f0f0;
}

:root.theme-dark .intro-text {
  color: #b0b0b0;
}

:root.theme-dark .intro-text strong {
  color: #D2691E;
}

:root.theme-dark .form-fusilles {
  background: #1a1a1a;
  border-color: #333;
}

:root.theme-dark .input-field,
:root.theme-dark .filter-select,
:root.theme-dark .year-field {
  background: #2a2a2a;
  border-color: #444;
  color: #fff;
}

:root.theme-dark .btn-rechercher {
  background: #D2691E;
  color: #1a1a1a;
}

:root.theme-dark .btn-rechercher:hover {
  background: #DEB887;
}

:root.theme-dark .results-table {
  background: #1a1a1a;
}

:root.theme-dark .results-table th {
  background: #2a2a2a;
  color: #f0f0f0;
  border-bottom-color: #444;
}

:root.theme-dark .results-table td {
  color: #ccc;
  border-bottom-color: #333;
}

:root.theme-dark .modal-content {
  background: #1a1a1a;
  border: 1px solid #444;
}

:root.theme-dark .modal-header {
  background: linear-gradient(135deg, #8B4513, #A0522D);
}

:root.theme-dark .modal-body {
  background: #1a1a1a;
  color: #e0e0e0;
}

:root.theme-dark .detail-section h3 {
  color: #D2691E;
  border-bottom-color: #444;
}

:root.theme-dark .detail-label {
  color: #888;
}

:root.theme-dark .detail-value {
  color: #e0e0e0;
}

:root.theme-dark .stat-card {
  background: linear-gradient(135deg, #1a1a1a 0%, #222 100%);
  border-color: #444;
}

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

:root.theme-dark .stat-label {
  color: #b0b0b0;
}

/* Fin du fichier CSS */

/* Onglets contributions */
.contributions-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-button {
    flex: 1;
    padding: 10px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-button:hover {
    background: #e0e0e0;
}

.tab-button.active {
    background: #8B4513;
    color: white;
    border-color: #8B4513;
}

.tab-content {
    display: none;
}

.contributions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.contribution-photo {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
}

.contribution-photo img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
}

.photo-description {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #666;
}

.files-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.file-item-container {
    position: relative;
}

.file-preview-item {
    position: relative;
}

.file-preview-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.remove-file {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.file-description-input {
    width: 100%;
    margin-top: 5px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    resize: none;
}

.add-more-container {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.btn-add-more {
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.btn-add-more:hover {
    background: #e9ecef;
}