/*
 * Annuaire Thérapeutes Leaflet - CSS
 * Version 6.3 - Loader + Filtres actifs
 */

/* =============================================================================
   VARIABLES CSS
   ============================================================================= */
:root {
  --atl-primary: #2196F3;
  --atl-primary-dark: #1976D2;
  --atl-secondary: #FF9800;
  --atl-light-gray: #f5f5f5;
  --atl-medium-gray: #e0e0e0;
  --atl-dark-gray: #757575;
  --atl-border-color: #ddd;
  --atl-radius-sm: 4px;
  --atl-radius-md: 8px;
  --atl-shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --atl-shadow-md: 0 4px 8px rgba(0,0,0,0.15);
}

/* =============================================================================
   CONTENEUR PRINCIPAL
   ============================================================================= */
.atl-container {
  max-width: 100%;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  position: relative;
}

/* =============================================================================
   MESSAGE DE CHARGEMENT GLOBAL
   ============================================================================= */
#atl-loading-message {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  min-height: 400px;
}

.atl-loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--atl-medium-gray);
  border-top-color: var(--atl-primary);
  border-radius: 50%;
  animation: atl-spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes atl-spin {
  to { transform: rotate(360deg); }
}

.atl-loading-text {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  text-align: center;
  margin-bottom: 10px;
}

.atl-loading-progress {
  font-size: 14px;
  color: var(--atl-primary);
  font-weight: 600;
  display: none;
}

/* =============================================================================
   FILTRES
   ============================================================================= */
.atl-filtres-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: white;
  border-radius: var(--atl-radius-md);
  box-shadow: var(--atl-shadow-sm);
}

.atl-filtre-group {
  display: flex;
  gap: 8px;
}

.atl-filtre-item {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--atl-border-color);
  border-radius: var(--atl-radius-sm);
  font-size: 14px;
  background: white;
  transition: all 0.2s ease;
}

.atl-filtre-item:focus {
  outline: none;
  border-color: var(--atl-primary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.atl-filtre-item:hover {
  border-color: var(--atl-primary);
}

/* =============================================================================
   FILTRES ACTIFS - Encadrement bleu
   ============================================================================= */
.atl-filter-active {
  border-color: var(--atl-primary) !important;
  border-width: 2px !important;
  background-color: rgba(33, 150, 243, 0.08) !important;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2) !important;
}

select.atl-filter-active {
  font-weight: 600;
  color: var(--atl-primary-dark);
}

input.atl-filter-active {
  font-weight: 500;
}

/* =============================================================================
   BOUTONS FILTRES
   ============================================================================= */
button.atl-filtre-item,
#atl-adresse-btn,
#atl-reset {
  background: var(--atl-primary);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

button.atl-filtre-item:hover,
#atl-adresse-btn:hover,
#atl-reset:hover {
  background: var(--atl-primary-dark);
}

#atl-reset {
  background: var(--atl-medium-gray);
  color: #333;
}

#atl-reset:hover {
  background: var(--atl-dark-gray);
  color: white;
}

.atl-filtre-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.atl-ico-geoloc {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

#atl-geoloc-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

#atl-geoloc-btn.loading::after {
  content: "...";
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}

/* =============================================================================
   LAYOUT CARTE + LISTE
   ============================================================================= */
#atl-content-wrapper {
  position: relative;
  min-height: 70vh;
}

.atl-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

#atl-listing-wrapper {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: var(--atl-radius-md);
  box-shadow: var(--atl-shadow-sm);
  overflow: hidden;
}

#atl-carte {
  border-radius: var(--atl-radius-md);
  overflow: hidden;
  box-shadow: var(--atl-shadow-sm);
  z-index: 1;
}

.atl-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--atl-light-gray);
  border-bottom: 1px solid var(--atl-border-color);
}

#atl-results-count {
  font-weight: 600;
  color: var(--atl-dark-gray);
}

.atl-tri-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.atl-tri-wrapper label {
  font-size: 13px;
  color: var(--atl-dark-gray);
}

#atl-tri {
  padding: 6px 10px;
  border: 1px solid var(--atl-border-color);
  border-radius: var(--atl-radius-sm);
  font-size: 13px;
  background: white;
}

#atl-listing {
  flex: 1;
  overflow-y: auto;
  max-height: 70vh;
  padding: 8px;
}

.atl-no-results {
  padding: 40px;
  text-align: center;
  color: var(--atl-dark-gray);
}

/* =============================================================================
   ITEMS DE LA LISTE
   ============================================================================= */
.atl-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  background: white;
  border: 1px solid var(--atl-border-color);
  border-radius: var(--atl-radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.atl-item:hover {
  box-shadow: var(--atl-shadow-md);
  transform: translateY(-2px);
}

.atl-item-active {
  border-color: var(--atl-primary);
  background: rgba(33, 150, 243, 0.05);
}

.atl-item-in-view {
  border-left: 3px solid var(--atl-primary);
}

.atl-item-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 80px;
}

.atl-item-right {
  flex: 1;
  min-width: 0;
}

.atl-photo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--atl-border-color);
}

.atl-photo-placeholder {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--atl-light-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  border: 2px solid var(--atl-border-color);
}

.atl-fiche-btn {
  font-size: 12px;
  padding: 6px 12px;
  background: var(--atl-primary);
  color: white;
  text-decoration: none;
  border-radius: var(--atl-radius-sm);
  text-align: center;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.atl-fiche-btn:hover {
  background: var(--atl-primary-dark);
}

.atl-nom {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.atl-adresse {
  font-size: 13px;
  color: var(--atl-dark-gray);
  margin-bottom: 6px;
}

.atl-distance {
  font-size: 0.85em;
  color: #666;
  margin-top: 4px;
}

.atl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.atl-tag {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  background: var(--atl-light-gray);
  color: var(--atl-dark-gray);
  border-radius: var(--atl-radius-sm);
  border: 1px solid var(--atl-medium-gray);
}

.atl-contact {
  font-size: 13px;
  color: var(--atl-dark-gray);
}

.atl-contact-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.atl-contact-line a {
  color: var(--atl-primary);
  text-decoration: none;
}

.atl-contact-line a:hover {
  text-decoration: underline;
}

.atl-ico {
  font-size: 14px;
}

/* =============================================================================
   SYSTÈME DE COULEURS
   ============================================================================= */
.atl-color-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.atl-color-badge {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.atl-color-badge:hover {
  transform: scale(1.4);
  cursor: help;
  z-index: 10;
  position: relative;
}

.atl-item[class*="atl-bg-"] {
  transition: all 0.3s ease;
}

.atl-item[class*="atl-bg-"]:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.atl-item[class*="atl-bg-"] .atl-nom {
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
  position: relative;
  z-index: 1;
}

/* =============================================================================
   MARQUEURS PERSONNALISÉS
   ============================================================================= */
.atl-custom-marker {
  background: transparent !important;
  border: none !important;
}

.atl-svg-marker {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  transition: transform 0.2s ease;
}

.atl-custom-marker:hover .atl-svg-marker {
  transform: scale(1.1);
}

/* =============================================================================
   POPUPS
   ============================================================================= */
.atl-popup .leaflet-popup-content-wrapper {
  border-radius: var(--atl-radius-md);
  padding: 0;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.atl-popup .leaflet-popup-content {
  margin: 0;
  min-width: 250px;
  max-width: 300px;
}

.atl-popup-content {
  padding: 20px;
  text-align: center;
}

.atl-popup-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  margin-bottom: 16px;
  border-radius: var(--atl-radius-sm);
}

.atl-popup-nom {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 700;
  color: #222;
  text-align: center;
}

.atl-popup-adresse,
.atl-popup-tel,
.atl-popup-email {
  margin: 8px 0;
  font-size: 13px;
  color: #555;
  text-align: center;
}

.atl-popup-tel a,
.atl-popup-email a {
  color: var(--atl-primary);
  text-decoration: none;
  font-weight: 500;
}

.atl-popup-tel a:hover,
.atl-popup-email a:hover {
  text-decoration: underline;
}

.atl-popup-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.atl-popup-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: center;
  text-decoration: none;
  border-radius: var(--atl-radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.atl-popup-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.atl-popup-btn-directions {
  background: var(--atl-primary);
  color: white;
}

.atl-popup-btn-directions:hover {
  background: var(--atl-primary-dark);
}

.atl-popup-btn-website {
  background: var(--atl-secondary);
  color: white;
}

.atl-popup-btn-website:hover {
  background: #F57C00;
}

.atl-popup-btn-profile {
  background: var(--atl-medium-gray);
  color: #333;
}

.atl-popup-btn-profile:hover {
  background: var(--atl-dark-gray);
  color: white;
}

.atl-popup .leaflet-popup-tip {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* =============================================================================
   POPUPS COMPACTS
   ============================================================================= */
.atl-popup-content-compact {
  padding: 12px;
  min-width: 200px;
  max-width: 280px;
}

.atl-popup-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e0e0e0;
}

.atl-popup-photo-mini {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e0e0e0;
}

.atl-popup-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  font-size: 20px;
}

.atl-popup-nom-compact {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
}

.atl-popup-adresse-compact,
.atl-popup-contact-compact {
  font-size: 12px;
  color: #666;
  margin: 4px 0;
  line-height: 1.4;
}

.atl-popup-actions-compact {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
}

.atl-popup-icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 50%;
  font-size: 18px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.atl-popup-icon-btn:hover {
  background: var(--atl-primary);
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.atl-popup-icon-btn[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
}

/* =============================================================================
   SKELETON LOADER
   ============================================================================= */
#atl-skeleton-loader {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 70vh;
}

.atl-skeleton-list,
.atl-skeleton-map {
  background: var(--atl-light-gray);
  border-radius: var(--atl-radius-md);
  animation: pulse 1.5s ease-in-out infinite;
}

.atl-skeleton-item {
  height: 120px;
  background: white;
  margin: 12px;
  border-radius: var(--atl-radius-sm);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1024px) {
  .atl-filtres-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
  }
}

@media (max-width: 768px) {
  .atl-layout {
    grid-template-columns: 1fr;
  }

  #atl-carte {
    order: -1;
    height: 50vh !important;
  }

  #atl-listing {
    max-height: 60vh;
  }

  .atl-filtres-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .atl-item {
    flex-direction: column;
  }

  .atl-item-left {
    flex-direction: row;
    width: 100%;
    justify-content: space-between;
  }

  .atl-photo,
  .atl-photo-placeholder {
    width: 60px;
    height: 60px;
  }

  .atl-list-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .atl-tri-wrapper {
    width: 100%;
  }

  #atl-tri {
    flex: 1;
  }

  #atl-skeleton-loader {
    grid-template-columns: 1fr;
  }

  .atl-color-badges {
    gap: 4px;
  }

  .atl-color-badge {
    width: 12px;
    height: 12px;
  }

  .atl-color-legend {
    font-size: 0.8em;
  }

  .atl-popup-buttons {
    gap: 8px;
  }

  .atl-popup-content-compact {
    min-width: 180px;
    max-width: 250px;
    padding: 10px;
  }

  .atl-popup-photo-mini {
    width: 35px;
    height: 35px;
  }

  .atl-popup-nom-compact {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .atl-container {
    font-size: 13px;
  }

  .atl-nom {
    font-size: 15px;
  }

  .atl-popup-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* =============================================================================
   PRINT
   ============================================================================= */
@media print {
  #atl-carte,
  .atl-filtres-grid,
  .atl-list-header,
  .atl-fiche-btn,
  .atl-popup-buttons,
  #atl-loading-message {
    display: none !important;
  }

  .atl-layout {
    grid-template-columns: 1fr;
  }

  .atl-item {
    page-break-inside: avoid;
    border: 1px solid #000;
  }
}

/* =============================================================================
   TAXONOMIES DANS POPUP
   ============================================================================= */
.atl-popup-tax {
  margin: 8px 0;
  font-size: 12px;
  color: #555;
  text-align: center;
}

.atl-popup-tax strong {
  display: block;
  margin-bottom: 4px;
  color: #333;
  font-size: 11px;
  text-transform: uppercase;
}