/**
 * Styles pour le date picker modal des vans
 */

/* Modal du date picker */
.cvpm-date-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cvpm-date-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.cvpm-date-picker-content {
    position: relative;
    background-color: #fff;
    border-radius: 12px;
    padding: 30px;
    width: auto;
    max-width: min(500px, 90%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 2;
    animation: slideIn 0.3s ease-out;
}

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

.cvpm-date-picker-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none!important;
    border: none!important;
    font-size: 32px!important;
    line-height: 1!important;
    cursor: pointer;
    color: #666!important;
    transition: color 0.2s!important;
    padding: 0!important;
    width: 32px!important;
    height: 32px!important;
    display: flex!important;
    align-items: center!important;
    justify-content: center!important;
}

.cvpm-date-picker-close:hover {
    color: #000;
}

.cvpm-date-picker-content h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.cvpm-date-picker-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#cvpm-van-dates-range {
    display: flex;
    justify-content: center;
}

#cvpm-van-dates-range .flatpickr-calendar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    margin: 0 auto;
    box-shadow: none !important;
}

#cvpm-validate-dates {
    padding: 12px 24px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

#cvpm-validate-dates:hover:not(:disabled) {
    background-color: #45a049;
}

#cvpm-validate-dates:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Styles pour les dates dans le calendrier */
/*
.flatpickr-calendar .cvpm-weekend {
    background-color: #ffe0e0;
}
*/

.flatpickr-calendar{
    margin:auto;
}

/* Style de base (sera overridé par les classes conditionnelles) */
.flatpickr-calendar .cvpm-jour-ferie,
.flatpickr-calendar .cvpm-jour-off {
    color: #999;
}

/* Jours fériés et jours off - style conditionnel pour mode "Départ et retour impossibles" */
.flatpickr-day.cvpm-jour-ferie.cvpm-restriction-active,
.flatpickr-day.cvpm-jour-off.cvpm-restriction-active,
.flatpickr-day.cvpm-weekend.cvpm-restriction-active,
.flatpickr-calendar .cvpm-jour-ferie.cvpm-restriction-active,
.flatpickr-calendar .cvpm-jour-off.cvpm-restriction-active {
    color: lightgrey !important;
    font-weight: 700 !important;
}

/* Style pour mode "Départ impossible" uniquement - s'applique seulement avant sélection de la date de départ */
.flatpickr-day.cvpm-jour-ferie.cvpm-retour-restriction,
.flatpickr-day.cvpm-jour-off.cvpm-retour-restriction,
.flatpickr-day.cvpm-weekend.cvpm-retour-restriction,
.flatpickr-calendar .cvpm-jour-ferie.cvpm-retour-restriction,
.flatpickr-calendar .cvpm-jour-off.cvpm-retour-restriction {
    color: lightgrey !important;
    font-weight: 700 !important;
}

/* Dates réservées - grisées et barrées */
.flatpickr-day.cvpm-date-reservee {
    background-color: #f5f5f5 !important;
    color: #999 !important;
    text-decoration: line-through !important;
    font-weight: 400 !important;
    cursor: not-allowed !important;
    position: relative;
}

.flatpickr-day.cvpm-date-reservee:hover {
    background-color: #ececec !important;
    color: #999 !important;
    border-color: #e5e5e5 !important;
}

/* Surcharger le style selected pour les dates réservées */
.flatpickr-day.cvpm-date-reservee.selected,
.flatpickr-day.cvpm-date-reservee.startRange,
.flatpickr-day.cvpm-date-reservee.endRange {
    background-color: #f5f5f5 !important;
    color: #999 !important;
}

/* Légende du calendrier */
.cvpm-calendar-legend {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    margin-top: 10px;
}

.cvpm-calendar-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
}

/* Loader */
.cvpm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 200px;
}

.cvpm-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.cvpm-loading p {
    margin: 0;
    color: #666;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .cvpm-date-picker-content {
        width: 95%;
        padding: 20px;
    }

    .cvpm-date-picker-content h3 {
        font-size: 20px;
    }

    #cvpm-van-dates-range,
    #cvpm-validate-dates {
        font-size: 14px;
    }

    .cvpm-loading {
        min-height: 150px;
        padding: 30px 20px;
    }

    .cvpm-spinner {
        width: 40px;
        height: 40px;
    }

    .cvpm-loading p {
        font-size: 14px;
    }
}

/* Responsive pour petits écrans (mobile) */
@media (max-width: 400px) {
    .cvpm-date-picker-content {
        padding: 15px;
        max-width: 95%;
        border-radius: 8px;
    }

    .cvpm-date-picker-content h3 {
        font-size: 18px;
        margin: 0 0 15px 0;
    }

    .cvpm-date-picker-close {
        top: 10px;
        right: 10px;
        font-size: 28px;
        width: 28px;
        height: 28px;
    }

    .cvpm-date-picker-form {
        gap: 12px;
    }

    /* Réduire la taille du calendrier flatpickr */
    .flatpickr-calendar {
        font-size: 13px !important;
        width: 280px !important;
    }

    .flatpickr-months {
        padding: 5px 0 !important;
    }

    .flatpickr-month {
        height: 32px !important;
    }

    .flatpickr-current-month {
        font-size: 14px !important;
        padding: 5px 0 0 0 !important;
    }

    .flatpickr-prev-month,
    .flatpickr-next-month {
        padding: 5px !important;
    }

    .flatpickr-weekdays {
        height: 28px !important;
        width: 100% !important;
    }

    .flatpickr-weekday {
        font-size: 11px !important;
        flex: 1 !important;
        max-width: 40px !important;
    }

    .flatpickr-days {
        width: 280px !important;
    }

    .dayContainer {
        width: 280px !important;
        min-width: 280px !important;
        max-width: 280px !important;
    }

    .flatpickr-day {
        height: 36px !important;
        line-height: 36px !important;
        flex-basis: 14.2857% !important;
        max-width: 14.2857% !important;
        font-size: 12px !important;
    }

    .cvpm-calendar-legend {
        padding: 8px;
        margin-top: 8px;
    }

    .cvpm-calendar-legend-item {
        font-size: 11px;
        gap: 6px;
    }

    .cvpm-calendar-legend-color {
        width: 12px;
        height: 12px;
    }

    #cvpm-validate-dates {
        padding: 10px 20px;
        font-size: 14px;
    }

    .cvpm-loading {
        padding: 20px 15px;
        min-height: 120px;
    }

    .cvpm-spinner {
        width: 35px;
        height: 35px;
    }

    .cvpm-loading p {
        font-size: 13px;
    }
}

/* Responsive pour très petits écrans (320px) */
@media (max-width: 340px) {
    .cvpm-date-picker-content {
        padding: 10px;
        max-width: 98%;
    }

    .cvpm-date-picker-content h3 {
        font-size: 16px;
        margin: 0 0 12px 0;
    }

    .cvpm-date-picker-close {
        top: 8px;
        right: 8px;
        font-size: 24px;
        width: 24px;
        height: 24px;
    }

    /* Calendrier encore plus compact */
    .flatpickr-calendar {
        font-size: 11px !important;
        width: 266px !important;
    }

    .flatpickr-months {
        padding: 4px 0 !important;
    }

    .flatpickr-month {
        height: 28px !important;
    }

    .flatpickr-current-month {
        font-size: 12px !important;
    }

    .flatpickr-current-month .flatpickr-monthDropdown-months {
        font-size: 12px !important;
    }

    .flatpickr-current-month input.cur-year {
        font-size: 12px !important;
    }

    .flatpickr-prev-month,
    .flatpickr-next-month {
        padding: 4px !important;
        width: 24px !important;
        height: 24px !important;
    }

    .flatpickr-prev-month svg,
    .flatpickr-next-month svg {
        width: 12px !important;
        height: 12px !important;
    }

    .flatpickr-weekdays {
        height: 24px !important;
        width: 100% !important;
    }

    .flatpickr-weekday {
        font-size: 10px !important;
        flex: 1 !important;
        max-width: 38px !important;
    }

    .flatpickr-days {
        width: 266px !important;
    }

    .dayContainer {
        width: 266px !important;
        min-width: 266px !important;
        max-width: 266px !important;
    }

    .flatpickr-day {
        height: 34px !important;
        line-height: 34px !important;
        flex-basis: 14.2857% !important;
        max-width: 14.2857% !important;
        font-size: 11px !important;
    }

    .cvpm-calendar-legend {
        padding: 6px;
        margin-top: 6px;
    }

    .cvpm-calendar-legend-item {
        font-size: 10px;
        gap: 4px;
    }

    .cvpm-calendar-legend-color {
        width: 10px;
        height: 10px;
    }

    #cvpm-validate-dates {
        padding: 8px 16px;
        font-size: 13px;
    }

    .cvpm-loading {
        padding: 15px 10px;
        min-height: 100px;
    }

    .cvpm-spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }

    .cvpm-loading p {
        font-size: 12px;
    }
}
