/* Reset Global pour éviter les débordements notamment sur mobile */
#calendar-container,
.custom-modal * {
    box-sizing: border-box;
    /* Crucial : inclut padding/border dans la largeur */
}

/* Variables globales */
:root {
    --fc-event-bg-color: #8B4513;
    --fc-event-border-color: #5D2E0A;
    --fc-today-bg-color: #fdf5e6;
    --fc-button-bg-color: #a0522d;
    --fc-button-border-color: #a0522d;
    --fc-button-active-bg-color: #8B4513;
    --fc-border-color: #eee;
}

/* Conteneur du Calendrier */
#calendar-container {
    max-width: 1100px;
    margin: 20px auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    /* Empêche le calendrier de dépasser */
}

/* Personnalisation des boutons FullCalendar */
.fc .fc-button-primary {
    text-transform: capitalize;
}

/* Fenêtre Pop-up (Modal) */
.custom-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    /* Priorité maximale */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    /* Effet de flou en arrière-plan */
    overflow-y: auto;
    overflow-x: hidden;
    /* Bloque le mouvement horizontal */
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 25px;
    width: 90%;
    max-width: 850px;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    /* Force le texte à revenir à la ligne */
}

/* Grille interne de la pop-up */
.modal-grid {
    display: flex;
    flex-direction: row;
    gap: 30px;
    margin-top: 15px;
}

/* Gestion de l'image */
.modal-image-container {
    flex: 1;
    min-width: 300px;
    max-height: 500px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f8f8;
}

#modalImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Informations textuelles */
.modal-info {
    flex: 1.2;
    line-height: 1.7;
    color: #333;
    overflow-wrap: break-word;
    /* Sécurité supplémentaire contre le débordement de texte */
}

.modal-info p {
    margin-bottom: 12px;
}

.modal-info hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 20px 0;
}

/* Bouton PDF */
.btn-pdf {
    display: inline-block;
    background-color: #a0522d;
    color: white !important;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 10px;
    transition: background 0.3s;
}

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

/* Fermeture pop-up */
.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 35px;
    font-weight: bold;
    color: #8B4513;
    cursor: pointer;
}

/* responsive design mobile */

@media (max-width: 768px) {

    /* calendrier on réduit les textes et les espaces */
    #calendar-container {
        padding: 10px;
        margin: 5px;
    }

    .fc .fc-toolbar {
        flex-direction: column;
        gap: 12px;
    }

    .fc .fc-toolbar-title {
        font-size: 1.1rem !important;
    }

    .fc .fc-button {
        font-size: 0.8rem !important;
        padding: 5px 8px !important;
    }

    /* Réduction de la taille des jours et événements */
    .fc .fc-col-header-cell-cushion,
    .fc .fc-daygrid-day-number {
        font-size: 0.8rem;
    }

    .fc .fc-event-title {
        font-size: 0.75rem !important;
        padding: 1px 3px !important;
    }

    /* pop-up on empile l'image et le texte */
    .modal-grid {
        flex-direction: column;
        /* On empile l'image et le texte */
        gap: 15px;
        width: 100%;
        /* S'assure de ne pas dépasser */
    }

    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
        /* Légèrement plus étroit pour laisser une marge de sécurité */
        max-width: 100vw;
    }

    .modal-image-container {
        min-width: 100%;
        width: 100%;
        max-height: 400px;
        /* On laisse plus de place en hauteur sur mobile */
    }

    #modalImage {
        height: auto;
        /* L'image prendra sa hauteur naturelle */
        max-height: 100%;
    }

    .modal-info {
        font-size: 0.95rem;
        width: 100%;
    }

    .btn-pdf {
        width: 100%;
        /* Le bouton prend toute la largeur pour le tactile */
        text-align: center;
        box-sizing: border-box;
    }

    .close-modal {
        top: 5px;
        right: 15px;
    }

}