/* ============================================
   STYLES POUR LE CALENDRIER AVEC ALTERNATIVES
   ============================================ */

/* ============================================
   COULEURS DU CALENDRIER
   ============================================ */

/* Date disponible - Vert très clair/transparent */
.flatpickr-day:not(.flatpickr-disabled):not(.date-indisponible):not(.date-alternative) {
  background-color: rgba(20, 244, 71, 0.5) !important;
  color: #333 !important;
  border-color: rgba(20, 244, 71, 0.7) !important;
}

.flatpickr-day:not(.flatpickr-disabled):not(.date-indisponible):not(.date-alternative):hover {
  background-color: rgba(20, 244, 71, 0.6) !important;
  border-color: rgba(20, 244, 71, 0.8) !important;
}

/* Date d'aujourd'hui - Bleu */
.flatpickr-day.date-aujourdhui {
  background-color: #007bff !important;
  color: white !important;
  border-color: #0056b3 !important;
  font-weight: bold;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.flatpickr-day.date-aujourdhui:hover {
  background-color: #0056b3 !important;
  border-color: #004085 !important;
}

/* Date indisponible - Gris moyen avec texte blanc */
.flatpickr-day.date-indisponible {
  background-color: #6c757d !important;
  color: #ffffff !important;
  border-color: #6c757d !important;
  cursor: not-allowed !important;
  opacity: 1;
  font-weight: 600;
}

/* Dates passées (disabled par Flatpickr) */
.flatpickr-day.flatpickr-disabled:not(.date-alternative) {
  background-color: #e3e1e1cf !important;
  color: #000 !important;
  border-color: #6c757d52 !important;
  cursor: not-allowed !important;
  opacity: 1;
  font-weight: 600;
}

/* Date avec alternatives - Orange (priorité absolue) */
.flatpickr-day.date-alternative,
.flatpickr-calendar .flatpickr-day.date-alternative {
  background-color: #ff8c00e3 !important;
  color: white !important;
  border-color: #ff8c00e3 !important;
  cursor: pointer !important;
  position: relative;
  font-weight: bold;
  opacity: 1 !important;
  /* Surcharger les styles de désactivation */
  pointer-events: auto !important;
}

.flatpickr-day.date-alternative:hover,
.flatpickr-calendar .flatpickr-day.date-alternative:hover {
  background-color: #ff7700e3 !important;
  border-color: #ff6600e3 !important;
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(255, 140, 0, 0.4);
  transition: all 0.2s ease;
}

/* Emoji retiré - causait un rectangle transparent */
/*.flatpickr-day.date-alternative::after {
  content: '🟠';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 8px;
  pointer-events: none;
}*/

/* ============================================
   POPUP DES ALTERNATIVES
   ============================================ */

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.popup-overlay.popup-overlay-visible {
  opacity: 1;
}

.popup-alternatives {
  position: fixed;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  padding: 20px;
  min-width: 280px;
  max-width: 380px;
  z-index: 99999;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.3s ease;
}

.popup-alternatives.popup-visible {
  opacity: 1;
  transform: scale(1);
}

.popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: #6c757d;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.popup-close:hover {
  background-color: #f1f3f5;
  color: #495057;
  transform: rotate(90deg);
}

.popup-titre {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: normal;
  color: #212529;
  padding-right: 30px;
  line-height: 1.4;
  text-align: center;
}

.popup-espaces {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.popup-espace {
  padding: 12px 14px;
  background-color: #f8f9fa;
  border-radius: 6px;
  border: 2px solid #dee2e6;
  cursor: pointer;
  transition: all 0.2s ease;
}

.popup-espace:hover {
  background-color: #fff4e6;
  border-color: #ff8c00;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(255, 140, 0, 0.2);
}

.popup-espace-nom {
  font-size: 14px;
  font-weight: 600;
  color: #212529;
  line-height: 1.3;
}

.popup-espace-plages {
  font-size: 13px;
  color: #495057;
  line-height: 1.4;
}

/* ============================================
   LÉGENDE DU CALENDRIER - VERSION INLINE DANS FLATPICKR
   ============================================ */

.calendar-legend-inline {
  margin-top: 12px;
  padding: 12px 16px 8px 16px;
  border-top: 1px solid #e9ecef;
  background-color: #f8f9fa;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  align-items: center;
}

.calendar-legend-inline .calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #495057;
}

.calendar-legend-inline .calendar-legend-circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.calendar-legend-inline .calendar-legend-circle.aujourdhui {
  background-color: #007bff;
  border-color: #0056b3;
}

.calendar-legend-inline .calendar-legend-circle.disponible {
  background-color: rgba(20, 244, 71, 0.5);
  border-color: rgba(20, 244, 71, 0.7);
}

.calendar-legend-inline .calendar-legend-circle.alternative {
  background-color: #ff8c00e3;
  border-color: #ff8c00e3;
}

.calendar-legend-inline .calendar-legend-circle.occupe {
  background-color: #e3e1e1cf;
  border-color: #6c757d52;
}

/* Masquer l'ancienne légende externe */
#calendar-legend {
  display: none !important;
}

/* Placeholder pour le champ date */
.flatpickr-input[readonly]:not([value]):before,
input[type="date"]:not([value]):before {
  content: 'Choisir une date';
  color: #6c757d;
}

input[type="date"]:not([value])::-webkit-datetime-edit {
  color: transparent;
}

input[type="date"]:not([value]):before {
  content: attr(placeholder);
  color: #6c757d;
}

/* Style du champ altInput de Flatpickr */
.flatpickr-input.flatpickr-mobile {
  background-color: white !important;
}

/* ============================================
   FIX POUR LES FLÈCHES DU CALENDRIER
   ============================================ */

/* Empêcher le chevauchement des flèches de navigation */
.flatpickr-months {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flatpickr-prev-month,
.flatpickr-next-month {
  position: absolute;
  top: 0;
  height: 40px;
  padding: 10px;
  z-index: 3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flatpickr-prev-month {
  left: 0;
}

.flatpickr-next-month {
  right: 0;
}

.flatpickr-current-month {
  padding: 0 40px;
  text-align: center;
  flex-grow: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .popup-alternatives {
    left: 10px !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) scale(0.9);
    max-width: calc(100vw - 20px);
    min-width: auto;
  }

  .popup-alternatives.popup-visible {
    transform: translateY(-50%) scale(1);
  }

  .calendar-legend {
    flex-direction: column;
    gap: 12px;
  }

  .calendar-legend-item {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .popup-titre {
    font-size: 16px;
  }

  .popup-espace-nom {
    font-size: 14px;
  }

  .popup-espace-plages {
    font-size: 13px;
  }
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */

.popup-close:focus,
.popup-espace:focus {
  outline: 2px solid #ff8c00;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .popup-alternatives,
  .popup-overlay,
  .popup-close,
  .popup-espace,
  .flatpickr-day {
    transition: none !important;
    animation: none !important;
  }
}

/* ============================================
   AMÉLIORATION DU CONTRASTE
   ============================================ */

@media (prefers-contrast: high) {
  .flatpickr-day.date-alternative {
    border: 3px solid #000;
  }

  .popup-espace {
    border: 3px solid #000;
  }
}
