/* ============================================
   FLATPICKR CUSTOMIZATION 
   ============================================ */

/* Container principal du calendrier */
.flatpickr-calendar {
    /* Positionnement centré */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
    
    /* Effet Glass */
    background: var(--glass-bg) !important;
    backdrop-filter: var(--glass-backdrop) !important;
    -webkit-backdrop-filter: var(--glass-backdrop) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--glass-shadow), var(--shadow-xl) !important;
    
    /* Dimensions */
    width: auto !important;
    max-width: 90vw !important;
    padding: var(--spacing-md) !important;
    
    /* Animation d'apparition */
    opacity: 0;
    animation: flatpickrFadeIn var(--transition-base) forwards;
}

/* Masquer la petite flèche de flatpickr */
.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after,
.flatpickr-calendar.arrowBottom:before,
.flatpickr-calendar.arrowBottom:after {
    display: none !important;
}

/* Animation d'apparition */
@keyframes flatpickrFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Animation de fermeture */
@keyframes flatpickrFadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
}

/* Overlay sombre derrière le calendrier */
.flatpickr-calendar::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: -1;
    animation: overlayFadeIn var(--transition-base);
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mode responsive - un seul mois sur mobile */
@media (max-width: 768px) {
    .flatpickr-calendar {
        width: 90vw !important;
        max-width: 400px !important;
        padding: var(--spacing-sm) !important;
        /* Amélioration de l'alignement vertical pour superposer avec glass-card */
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    
    /* Note: Le JavaScript gère déjà showMonths: 1 sur mobile,
       donc pas besoin de masquer des éléments ici.
       Le calendrier affichera naturellement un seul mois. */
}

/* ============================================
   PALETTE DE COULEURS BABYLONE
   ============================================ */

/* En-tête du mois */
.flatpickr-months {
    background: transparent !important;
    padding: var(--spacing-sm) 0 !important;
}

.flatpickr-month {
    color: var(--white) !important;
    fill: var(--white) !important;
}

.flatpickr-current-month {
    color: var(--white) !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--white) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.25rem 0.5rem !important;
    transition: all var(--transition-fast) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}

.flatpickr-current-month input.cur-year {
    background: rgba(255, 255, 255, 0.1) !important;
    color: var(--white) !important;
    border: 0px solid var(--glass-border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.25rem 0.5rem !important;
    font-weight: 600 !important;
}

/* Flèches de navigation */
.flatpickr-prev-month,
.flatpickr-next-month {
    fill: var(--white) !important;
    transition: all var(--transition-fast) !important;
    border: none !important;
    background: transparent !important;
}

.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
    fill: var(--accent-color) !important;
    background: transparent !important;
    transform: scale(1.1) !important;
}

/* Forcer la couleur et taille des SVG à l'intérieur */
.flatpickr-prev-month svg,
.flatpickr-next-month svg {
    fill: inherit !important;
    width: 20px !important;
    height: 20px !important;
}

/* Jours de la semaine */
.flatpickr-weekdays {
    background: transparent !important;
    margin-top: var(--spacing-sm) !important;
}

.flatpickr-weekday {
    color: var(--accent-color) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

/* Jours du calendrier */
.flatpickr-days {
    background: transparent !important;
}

.flatpickr-day {
    color: var(--white) !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    transition: all var(--transition-fast) !important;
    font-weight: 500 !important;
    margin: 2px !important;
}

/* Jour au survol */
.flatpickr-day:hover {
    background: rgba(223, 179, 109, 0.2) !important;
    color: var(--white) !important;
    transform: scale(1.05) !important;
}

/* Jour aujourd'hui */
.flatpickr-day.today {
    background: rgba(223, 179, 109, 0.3) !important;
    color: var(--white) !important;
    font-weight: 700 !important;
    border: 2px solid var(--accent-color) !important;
}

.flatpickr-day.today:hover {
    background: rgba(223, 179, 109, 0.4) !important;
}

/* Jour sélectionné */
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--accent-color) !important;
    color: var(--primary-dark) !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 12px rgba(223, 179, 109, 0.4) !important;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: var(--accent-light) !important;
    transform: scale(1.05) !important;
}

/* Plage de dates sélectionnée */
.flatpickr-day.inRange {
    background: rgba(223, 179, 109, 0.25) !important;
    color: var(--white) !important;
    box-shadow: none !important;
}

/* Jours désactivés (passés) */
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: rgba(255, 255, 255, 0.3) !important;
    cursor: not-allowed !important;
}

.flatpickr-day.flatpickr-disabled:hover {
    background: transparent !important;
    transform: none !important;
}

/* ============================================
   EFFETS VISUELS GLASS
   ============================================ */

/* Effet de brillance sur le calendrier */
.flatpickr-calendar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0) 100%
    );
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    pointer-events: none;
}

/* Effet de lueur sur les jours sélectionnés */
.flatpickr-day.selected::before,
.flatpickr-day.startRange::before,
.flatpickr-day.endRange::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle,
        rgba(223, 179, 109, 0.4) 0%,
        transparent 70%
    );
    border-radius: var(--radius-sm);
    animation: glowPulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Effet de verre sur les dropdowns */
.flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.flatpickr-monthDropdown-months:focus,
.flatpickr-current-month input.cur-year:focus {
    outline: none !important;
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 3px rgba(223, 179, 109, 0.2) !important;
}

/* Effet de profondeur sur les jours */
.flatpickr-day {
    position: relative;
    overflow: hidden;
}

.flatpickr-day::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}

.flatpickr-day:hover::before {
    opacity: 1;
}

/* Séparateur élégant entre les mois */
.flatpickr-months + .flatpickr-weekdays::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--glass-border) 50%,
        transparent 100%
    );
}

/* Animation de fermeture */
.flatpickr-calendar.arrowTop,
.flatpickr-calendar.arrowBottom {
    animation: flatpickrFadeIn var(--transition-base) forwards;
}

.flatpickr-calendar.inline {
    position: relative !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
}

/* Amélioration de la lisibilité sur mobile */
@media (max-width: 768px) {
    .flatpickr-day {
        height: 38px !important;
        line-height: 38px !important;
        font-size: 0.9rem !important;
    }
    
    .flatpickr-weekday {
        font-size: 0.75rem !important;
    }
    
    .flatpickr-current-month {
        font-size: 1rem !important;
    }
}

/* Effet de focus pour l'accessibilité */
.flatpickr-day:focus {
    outline: 2px solid var(--accent-color) !important;
    outline-offset: 2px !important;
    z-index: 10 !important;
}

/* Amélioration du contraste pour les jours dans la plage */
.flatpickr-day.inRange:not(.startRange):not(.endRange) {
    position: relative;
}

.flatpickr-day.inRange:not(.startRange):not(.endRange)::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(223, 179, 109, 0.15) 0%,
        rgba(223, 179, 109, 0.25) 50%,
        rgba(223, 179, 109, 0.15) 100%
    );
    pointer-events: none;
}

/* ============================================
   TOUCHES FINALES & POLISH
   ============================================ */

/* Amélioration du texte du mois */
.flatpickr-current-month .flatpickr-monthDropdown-months {
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
}

/* Effet de pression sur les jours cliquables */
.flatpickr-day:not(.flatpickr-disabled):active {
    transform: scale(0.95) !important;
}

/* Amélioration de l'espacement */
.flatpickr-innerContainer {
    padding: var(--spacing-xs) 0 !important;
}

/* Correction du z-index pour l'overlay */
.flatpickr-calendar.open::before {
    z-index: -1 !important;
}

/* Style pour le bouton de fermeture (si ajouté) */
.flatpickr-close {
    position: absolute !important;
    top: var(--spacing-sm) !important;
    right: var(--spacing-sm) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--radius-full) !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
    color: var(--white) !important;
    font-size: 1.2rem !important;
    line-height: 1 !important;
}

.flatpickr-close:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: rotate(90deg) !important;
}

/* Amélioration du contraste pour les weekends (optionnel) */
.flatpickr-day.weekend:not(.flatpickr-disabled) {
    color: var(--accent-light) !important;
}

/* Animation subtile au chargement des jours */
.flatpickr-day {
    animation: dayFadeIn 0.3s ease-out backwards;
}

@keyframes dayFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Délai progressif pour l'animation des jours */
.flatpickr-day:nth-child(1) { animation-delay: 0.02s; }
.flatpickr-day:nth-child(2) { animation-delay: 0.04s; }
.flatpickr-day:nth-child(3) { animation-delay: 0.06s; }
.flatpickr-day:nth-child(4) { animation-delay: 0.08s; }
.flatpickr-day:nth-child(5) { animation-delay: 0.10s; }
.flatpickr-day:nth-child(6) { animation-delay: 0.12s; }
.flatpickr-day:nth-child(7) { animation-delay: 0.14s; }

/* Désactiver l'animation après le premier affichage */
.flatpickr-calendar.flatpickr-opened .flatpickr-day {
    animation: none;
}

/* Amélioration de la transition entre les mois */
.flatpickr-months .flatpickr-month {
    transition: all var(--transition-base) !important;
}

/* Style pour les tooltips (si utilisés) */
.flatpickr-day[aria-label]::after {
    content: attr(aria-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.9);
    color: var(--white);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: 1000;
}

.flatpickr-day:hover[aria-label]::after {
    opacity: 0; /* Désactivé par défaut, peut être activé si souhaité */
}
