/* ============================================================
   Modale de prise de rendez-vous MRAUK-U — Google Calendar
   Partagée entre tarifs-financements.html et parcours-itm.html
   Préfixe : bm- (booking modal)
   ============================================================ */

/* --- Overlay --- */
.bm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background-color: rgba(10, 12, 20, 0.62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.bm-overlay.is-open {
    display: flex;
}

/* --- Modale --- */
.bm-modal {
    position: relative;
    width: min(1180px, 92vw);
    max-height: 92vh;
    max-height: 92dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-container-lowest, #ffffff);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-ambient);
    padding: 2.25rem;
}

.bm-modal:focus {
    outline: none;
}

/* --- Bouton fermer --- */
.bm-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 5;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background-color: var(--surface-container-high, #f1f1f4);
    color: var(--on-surface);
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.bm-close:hover {
    background-color: var(--outline-variant);
    transform: rotate(90deg);
}

.bm-close:focus-visible,
.bm-modal a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* --- En-tête --- */
.bm-head {
    text-align: center;
    margin-bottom: 1.25rem;
    flex-shrink: 0;
}

.bm-head .bm-icon {
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--primary-soft, rgba(176, 141, 87, 0.14));
    color: var(--primary);
}

.bm-head h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    margin: 0 0 0.4rem;
    color: var(--secondary);
}

.bm-head p {
    font-size: 0.95rem;
    color: var(--on-surface-variant);
    margin: 0;
    line-height: 1.5;
}

.bm-head .bm-subnote {
    font-size: 0.85rem;
    color: var(--secondary);
    opacity: 0.9;
    margin-top: 0.6rem;
    line-height: 1.5;
}

/* --- Récapitulatif (badges) --- */
.bm-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    margin-bottom: 1.25rem;
    flex-shrink: 0;
}

.bm-summary .bm-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background-color: var(--surface-container-high, #f1f1f4);
    border: 1px solid var(--outline-variant);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--secondary);
}

.bm-summary .bm-chip svg {
    width: 14px;
    height: 14px;
    color: var(--primary);
    flex-shrink: 0;
}

.bm-summary .bm-summary-hint {
    font-size: 0.85rem;
    color: var(--on-surface-variant);
    margin: 0;
}

/* --- Conteneur Google Calendar inline --- */
.bm-google-embed {
    width: 100%;
    flex: 1 1 auto;
    min-height: 600px;
    overflow: hidden;
    border-radius: 18px;
    background-color: #ffffff;
    position: relative;
}

.bm-google-embed iframe {
    width: 100%;
    height: 100%;
    min-height: 650px;
    border: 0;
    display: block;
}

/* --- Lien de secours (fallback) --- */
.bm-fallback {
    margin: 0.9rem 0 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--on-surface-variant);
    flex-shrink: 0;
}

.bm-fallback a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- Pied de modale --- */
.bm-foot {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.82rem;
    color: var(--on-surface-variant);
    opacity: 0.85;
    flex-shrink: 0;
}

/* --- Message d'erreur d'enregistrement (form-handler) --- */
.mrauku-form-error {
    display: none;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background-color: rgba(176, 58, 46, 0.1);
    border: 1px solid rgba(176, 58, 46, 0.35);
    color: #b03a2e;
    font-size: 0.88rem;
    line-height: 1.5;
    text-align: center;
}

/* ============================================================
   Responsive smartphone (<= 576 px)
   Refonte Fullscreen Application Overlay :
     - Modale en 100dvh (plein écran fluide)
     - L'iframe occupe 100% de la hauteur disponible entre header et footer
     - Google Calendar gère son propre défilement interne à 100% de hauteur
     - En-tête (croix ×) et footer ("Retour au site") fixes et toujours visibles
   ============================================================ */
@media (max-width: 576px) {

    /* --- Overlay plein écran --- */
    .bm-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    /* --- Modale plein écran app-style (zero outer scroll) --- */
    .bm-modal {
        display: flex;
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100dvh;
        margin: 0;
        padding: 0;
        border-radius: 0;
        overflow: hidden;
        background-color: var(--surface-container-lowest, #ffffff);
    }

    /* --- En-tête fixe en haut --- */
    .bm-head {
        margin: 0;
        padding: 0.65rem 2.8rem 0.5rem 0.9rem;
        text-align: left;
        flex-shrink: 0;
        background-color: var(--surface-container-lowest, #ffffff);
        border-bottom: 1px solid var(--outline-variant);
    }

    .bm-head h3 {
        margin: 0;
        font-size: 1rem;
        line-height: 1.2;
    }

    /* Bouton fermer toujours visible en haut à droite */
    .bm-close {
        top: 0.45rem;
        right: 0.5rem;
        z-index: 10;
    }

    /* Statut CRM compact --- */
    .bm-lead-status {
        margin: 0 !important;
        padding: 0.4rem 0.75rem !important;
        font-size: 0.85rem;
        line-height: 1.3;
        gap: 0;
        flex-shrink: 0;
    }

    .bm-lead-status__sub {
        display: none;
    }

    /* --- Corps : flex 1 1 auto, occupe 100% de la hauteur disponible --- */
    .bm-booking-body {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    /* --- Zone Google & Iframe : 100% hauteur, défilement interne Google --- */
    .bm-google-embed {
        flex: 1 1 auto;
        display: block;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        border-radius: 0;
    }

    #bm-google-booking-frame {
        display: block;
        width: 100%;
        height: 100%;
        min-height: 100%;
        border: 0;
    }

    /* --- Masquer textes redondants --- */
    #bm-booking-subtitle,
    #bm-booking-subnote,
    .bm-summary,
    .bm-icon {
        display: none;
    }

    /* --- Fallback compact au-dessus du footer --- */
    .bm-fallback {
        flex-shrink: 0;
        margin: 0;
        padding: 0.25rem 0.5rem;
        font-size: 0.72rem;
        line-height: 1.25;
        text-align: center;
        background-color: var(--surface-container-lowest, #ffffff);
        border-top: 1px solid var(--outline-variant);
    }

    /* --- Footer fixe en bas avec safe-area iOS --- */
    .bm-done-zone {
        flex-shrink: 0;
        margin: 0 !important;
        padding: 0.35rem 0.55rem calc(0.35rem + env(safe-area-inset-bottom)) !important;
        border-top: 1px solid var(--outline-variant);
        background-color: var(--surface-container-lowest, #ffffff);
    }

    .bm-done-btn {
        width: 100%;
        min-height: 40px !important;
        padding: 0.55rem 0.9rem;
        font-size: 0.9rem;
    }
}

/* ============================================================
   Tarifs-financements.html — modale intégrée simplifiée
   Le modificateur .bm-overlay--financement isole ces règles afin de
   ne pas modifier le comportement des autres pages utilisant bm-*.
   ============================================================ */

.bm-overlay--financement {
    z-index: 2000;
}

.bm-overlay--financement .bm-modal {
    width: min(1100px, 94vw);
    height: min(850px, 92vh);
    height: min(850px, 92dvh);
    min-height: 520px;
    max-height: none;
    padding: 0;
    border-radius: var(--radius-xl, 20px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.bm-overlay--financement .bm-close {
    top: 0.75rem;
    right: 0.85rem;
    font-size: 1.5rem;
    line-height: 1;
}

.bm-overlay--financement .bm-head {
    flex: 0 0 auto;
    margin: 0;
    padding: 1rem 4rem 0.85rem 1.25rem;
    text-align: left;
    background-color: var(--surface-container-lowest, #ffffff);
    border-bottom: 1px solid var(--outline-variant, #e3e3e8);
}

.bm-overlay--financement .bm-head h3 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.25;
}

.bm-overlay--financement .bm-head p {
    margin: 0.3rem 0 0;
    font-size: 0.88rem;
    line-height: 1.4;
}

.bm-overlay--financement .bm-lead-status {
    flex: 0 0 auto;
    padding: 0.45rem 1rem;
    font-size: 0.84rem;
    line-height: 1.35;
    text-align: center;
    color: var(--on-surface-variant);
    background-color: var(--surface-container-low, #f7f7f9);
    border-bottom: 1px solid var(--outline-variant, #e3e3e8);
}

.bm-overlay--financement .bm-lead-status.is-empty {
    display: none;
}

.bm-overlay--financement .bm-lead-status--saved {
    color: var(--secondary);
    background-color: var(--primary-soft, rgba(176, 141, 87, 0.14));
}

.bm-overlay--financement .bm-lead-status--error {
    color: #b03a2e;
    background-color: rgba(176, 58, 46, 0.1);
}

.bm-overlay--financement .bm-booking-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background-color: #ffffff;
}

.bm-overlay--financement .bm-google-embed {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 0;
    background-color: #ffffff;
}

.bm-overlay--financement #bm-google-booking-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    border: 0;
    background-color: #ffffff;
}

.bm-overlay--financement .bm-done-zone {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    margin: 0;
    padding: 0.65rem 0.85rem;
    background-color: var(--surface-container-lowest, #ffffff);
    border-top: 1px solid var(--outline-variant, #e3e3e8);
}

.bm-overlay--financement .bm-done-btn {
    min-height: 40px;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--radius-md, 10px);
    background-color: var(--primary, #b08d57);
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.bm-overlay--financement .bm-done-btn:hover {
    background-color: var(--secondary, #243a5c);
}

.bm-overlay--financement .bm-done-btn:focus-visible {
    outline: 2px solid var(--primary, #b08d57);
    outline-offset: 2px;
}

@media (max-width: 576px) {
    .bm-overlay--financement {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
        background-color: #ffffff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .bm-overlay--financement .bm-modal {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        max-width: none;
        max-height: none;
        margin: 0;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .bm-overlay--financement .bm-head {
        margin: 0;
        padding: 0.62rem 3.2rem 0.55rem 0.8rem;
        text-align: left;
    }

    .bm-overlay--financement .bm-head h3 {
        margin: 0;
        font-size: 1rem;
        line-height: 1.2;
    }

    .bm-overlay--financement #bm-booking-subtitle,
    .bm-overlay--financement .bm-summary,
    .bm-overlay--financement .bm-icon,
    .bm-overlay--financement .bm-fallback {
        display: none;
    }

    .bm-overlay--financement .bm-close {
        top: 0.35rem;
        right: 0.4rem;
        width: 2.35rem;
        height: 2.35rem;
        z-index: 10;
    }

    .bm-overlay--financement .bm-lead-status {
        margin: 0;
        padding: 0.32rem 0.6rem;
        font-size: 0.76rem;
        line-height: 1.25;
    }

    .bm-overlay--financement .bm-booking-body {
        flex: 1 1 0;
        min-height: 0;
        height: auto;
        overflow: hidden;
    }

    .bm-overlay--financement .bm-google-embed {
        display: flex;
        flex: 1 1 0;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: hidden;
        border-radius: 0;
    }

    .bm-overlay--financement #bm-google-booking-frame {
        flex: 1 1 0;
        width: 100%;
        height: auto;
        min-height: 0;
        border: 0;
    }

    .bm-overlay--financement .bm-done-zone {
        justify-content: stretch;
        margin: 0;
        padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
    }

    .bm-overlay--financement .bm-done-btn {
        width: 100%;
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        font-size: 0.86rem;
    }
}
