/* =============================================================================
 *  CALENDRIER DES FORMATIONS - RESEAU AMYNCO
 *  Styles de la section "Calendrier des formations" affichee sur index.html.
 *
 *  Charte : bleu fonce #003b5e (principal), orange #f57328 (accent / CTA),
 *           police Roboto (deja chargee par le site).
 *
 *  Toutes les classes sont prefixees par "cal-" afin de ne pas entrer en
 *  conflit avec le CSS existant du site (WebAcappella / Bootstrap).
 * ========================================================================== */

/* ---- Variables de charte ------------------------------------------------- */
.cal-section {
    --cal-bleu: #003b5e;
    --cal-bleu-clair: #0a5a86;
    --cal-orange: #f57328;
    --cal-orange-clair: #fff1e6;
    --cal-gris-fond: #f4f8fb;
    --cal-gris-bord: #e3ebf2;
    --cal-texte: #2d3a45;
    --cal-texte-doux: #6b7c89;
    --cal-radius: 16px;
    --cal-ombre: 0 6px 24px rgba(0, 59, 94, 0.08);
    --cal-ombre-hover: 0 14px 38px rgba(0, 59, 94, 0.16);

    font-family: Roboto, Arial, Helvetica, 'Liberation Sans', FreeSans, sans-serif;
    background: linear-gradient(180deg, #ffffff 0%, var(--cal-gris-fond) 100%);
    padding: 56px 0 64px;
    color: var(--cal-texte);
}

/* Conteneur centre responsive. */
.cal-section .cal-container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 18px;
    box-sizing: border-box;
}

/* ---- En-tete de section -------------------------------------------------- */
.cal-header {
    text-align: center;
    margin-bottom: 34px;
}

.cal-header__eyebrow {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--cal-orange);
    margin-bottom: 10px;
}

.cal-header__title {
    font-size: clamp(26px, 4vw, 38px);
    font-weight: 800;
    color: var(--cal-bleu);
    margin: 0 0 12px;
    line-height: 1.15;
}

.cal-header__subtitle {
    font-size: 17px;
    color: var(--cal-texte-doux);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.5;
}

.cal-header__updated {
    display: inline-block;
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--cal-texte-doux);
    background: #fff;
    border: 1px solid var(--cal-gris-bord);
    border-radius: 999px;
    padding: 5px 14px;
}
.cal-header__updated b { color: var(--cal-bleu); font-weight: 700; }

/* ---- Onglets (Tous / CACES / AIPR) --------------------------------------- */
.cal-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 34px;
    border-bottom: 2px solid var(--cal-gris-bord);
}
.cal-tab {
    border: none;
    background: transparent;
    color: var(--cal-texte-doux);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 28px;
    cursor: pointer;
    margin-bottom: -2px;
    border-bottom: 3px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.cal-tab:hover { color: var(--cal-bleu); }
.cal-tab__count {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    font-weight: 700;
    background: var(--cal-gris-fond);
    color: var(--cal-texte-doux);
    border-radius: 999px;
    padding: 2px 9px;
    vertical-align: middle;
    transition: background 0.2s ease, color 0.2s ease;
}
.cal-tab.is-active {
    color: var(--cal-bleu);
    border-bottom-color: var(--cal-orange);
}
.cal-tab.is-active .cal-tab__count {
    background: var(--cal-orange);
    color: #fff;
}

/* ---- Liste des cartes ---------------------------------------------------- */
.cal-list {
    display: grid;
    gap: 22px;
    min-height: 240px; /* reserve d'espace pour limiter le layout shift au chargement */
}

/* ---- Carte formation ----------------------------------------------------- */
.cal-card {
    position: relative;
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 0;
    background: #fff;
    border: 1px solid var(--cal-gris-bord);
    border-radius: var(--cal-radius);
    overflow: hidden;
    box-shadow: var(--cal-ombre);
    transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
    /* Animation d'apparition (declenchee par .is-visible). */
    opacity: 0;
    transform: translateY(18px);
}
.cal-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.cal-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--cal-ombre-hover);
    border-color: var(--cal-orange);
}

/* Colonne gauche : image + titre + badges + actions. */
.cal-card__left {
    padding: 22px 22px 22px 24px;
    display: flex;
    flex-direction: column;
}
.cal-card__head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.cal-card__media {
    flex: 0 0 84px;
    width: 84px;
    height: 84px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--cal-gris-fond);
    border: 1px solid var(--cal-gris-bord);
}
.cal-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cal-card__title {
    font-size: 18px;
    font-weight: 800;
    color: var(--cal-bleu);
    margin: 2px 0 0;
    line-height: 1.25;
}

/* Badges */
.cal-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 16px;
}
.cal-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 11px;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
}
.cal-badge--mode    { background: #ede9fe; color: #6d28d9; }   /* En centre / A distance */
.cal-badge--recy    { background: #e0f2fe; color: #0369a1; }   /* Recyclage */
.cal-badge--init    { background: #dbeafe; color: #1d4ed8; }   /* Initial */
.cal-badge--cpf-ok  { background: #dcfce7; color: #15803d; }   /* Eligible CPF */
.cal-badge--cpf-no  { background: var(--cal-orange-clair); color: var(--cal-orange); } /* Non eligible CPF */

/* Actions (boutons) */
.cal-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
    padding-top: 20px;
}
.cal-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    padding: 11px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    border: none;
}
.cal-btn svg { width: 16px; height: 16px; flex: 0 0 16px; fill: currentColor; }
.cal-btn--ghost {
    background: var(--cal-bleu);
    color: #fff;
}
.cal-btn--ghost:hover {
    background: var(--cal-bleu-clair);
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 59, 94, 0.25);
}
.cal-btn--cta {
    background: var(--cal-orange);
    color: #fff;
}
.cal-btn--cta:hover {
    background: #e0631c;
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(245, 115, 40, 0.35);
}

/* Colonne droite : infos pratiques + sessions. */
.cal-card__right {
    padding: 22px 24px 22px 22px;
    background: var(--cal-gris-fond);
    border-left: 1px solid var(--cal-gris-bord);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.cal-card__infos {
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.cal-info {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14.5px;
    color: var(--cal-texte);
}
.cal-info svg { width: 16px; height: 16px; flex: 0 0 16px; fill: var(--cal-bleu); }
.cal-info b { font-weight: 700; }
.cal-info--places { color: var(--cal-orange); font-weight: 600; }
.cal-info--places svg { fill: var(--cal-orange); }

/* Encadre sessions */
.cal-sessions {
    border: 1.5px solid var(--cal-gris-bord);
    border-radius: 12px;
    background: #fff;
    padding: 13px 14px;
}
.cal-sessions__title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--cal-bleu);
    margin-bottom: 10px;
}
.cal-sessions__dates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cal-date {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--cal-bleu);
    background: #fff;
    text-decoration: none;
    border: 1.5px solid var(--cal-gris-bord);
    border-radius: 8px;
    padding: 6px 11px;
    cursor: pointer;
    transition: all 0.18s ease;
}
.cal-date:hover {
    background: var(--cal-orange);
    border-color: var(--cal-orange);
    color: #fff;
    transform: translateY(-1px);
}
.cal-date--more {
    border-style: dashed;
    color: var(--cal-texte-doux);
}

/* Encart "Sessions sur demande" (formations sans date programmee) */
.cal-ondemand {
    display: flex;
    align-items: center;
    gap: 13px;
    height: 100%;
    min-height: 92px;
    padding: 6px 4px;
}
.cal-ondemand svg {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    fill: var(--cal-orange);
}
.cal-ondemand__title {
    font-size: 15px;
    font-weight: 800;
    color: var(--cal-bleu);
    margin-bottom: 3px;
}
.cal-ondemand__text {
    font-size: 13.5px;
    color: var(--cal-texte-doux);
    line-height: 1.45;
}

/* ---- Bouton "Voir plus" -------------------------------------------------- */
.cal-more {
    text-align: center;
    margin-top: 34px;
}
.cal-more__btn {
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: var(--cal-bleu);
    background: #fff;
    border: 2px solid var(--cal-bleu);
    border-radius: 999px;
    padding: 12px 34px;
    cursor: pointer;
    transition: all 0.22s ease;
}
.cal-more__btn:hover {
    background: var(--cal-bleu);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0, 59, 94, 0.22);
}

/* ---- Etats (chargement / erreur / vide) ---------------------------------- */
.cal-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--cal-texte-doux);
    font-size: 15px;
}
.cal-state__spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 16px;
    border: 4px solid var(--cal-gris-bord);
    border-top-color: var(--cal-orange);
    border-radius: 50%;
    animation: cal-spin 0.8s linear infinite;
}
@keyframes cal-spin { to { transform: rotate(360deg); } }

/* Skeleton de chargement (limite le layout shift). */
.cal-skeleton {
    height: 188px;
    border-radius: var(--cal-radius);
    background: linear-gradient(100deg, #eef3f7 30%, #f7fafc 50%, #eef3f7 70%);
    background-size: 200% 100%;
    animation: cal-shimmer 1.3s ease-in-out infinite;
}
@keyframes cal-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
    .cal-card {
        grid-template-columns: 1fr;
    }
    .cal-card__right {
        border-left: none;
        border-top: 1px solid var(--cal-gris-bord);
    }
}
@media (max-width: 520px) {
    .cal-section { padding: 40px 0 48px; }
    .cal-card__head { flex-direction: row; }
    .cal-card__media { flex-basis: 64px; width: 64px; height: 64px; }
    .cal-card__title { font-size: 16px; }
    .cal-card__actions .cal-btn { flex: 1 1 auto; justify-content: center; }
}

/* Accessibilite : respecte la preference "reduire les animations". */
@media (prefers-reduced-motion: reduce) {
    .cal-card,
    .cal-btn,
    .cal-date,
    .cal-tab,
    .cal-more__btn {
        transition: none;
    }
    .cal-card { opacity: 1; transform: none; }
    .cal-skeleton, .cal-state__spinner { animation: none; }
}

/* =============================================================================
 *  MODAL DE CONTACT / RESERVATION
 *  Fenetre epuree declenchee par les boutons des cartes et les dates de session.
 *  Affiche un resume court de la formation + un formulaire minimal.
 * ========================================================================== */
.cal-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: Roboto, Arial, Helvetica, 'Liberation Sans', FreeSans, sans-serif;
}
.cal-modal[hidden] { display: none; }

.cal-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 30, 48, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}
.cal-modal.is-open .cal-modal__overlay { animation: cal-modal-fade 0.25s ease; }

.cal-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #fff;
    border-radius: 18px;
    padding: 30px 28px 26px;
    box-shadow: 0 30px 70px rgba(0, 30, 48, 0.35);
}
.cal-modal.is-open .cal-modal__dialog { animation: cal-modal-pop 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }

.cal-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: none;
    background: #f4f8fb;
    color: #6b7c89;
    font-size: 22px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}
.cal-modal__close:hover { background: #ffe3d1; color: #f57328; }

.cal-modal__title {
    font-size: 22px;
    font-weight: 800;
    color: #003b5e;
    margin: 0 38px 6px 0;
    line-height: 1.2;
}
.cal-modal__intro {
    font-size: 14px;
    color: #6b7c89;
    margin: 0 0 16px;
    line-height: 1.45;
}

/* Resume compact de la formation choisie */
.cal-modal__resume {
    background: #f4f8fb;
    border-left: 3px solid #f57328;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 18px;
}
.cal-modal__resume-title {
    font-size: 15px;
    font-weight: 800;
    color: #003b5e;
    margin-bottom: 4px;
}
.cal-modal__resume-meta {
    font-size: 13px;
    color: #5a6b78;
    line-height: 1.5;
}
.cal-modal__resume-date {
    display: inline-block;
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: #fff;
    background: #f57328;
    border-radius: 999px;
    padding: 3px 12px;
}

/* Formulaire */
.cal-modal__form { display: flex; flex-direction: column; gap: 14px; }
.cal-modal__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.cal-modal__field { display: flex; flex-direction: column; gap: 5px; }
.cal-modal__field label {
    font-size: 12.5px;
    font-weight: 700;
    color: #003b5e;
}
.cal-modal__opt { font-weight: 500; color: #9aa8b3; }
.cal-modal__field input,
.cal-modal__field textarea {
    font-family: inherit;
    font-size: 14.5px;
    color: #2d3a45;
    background: #fff;
    border: 1.5px solid #e3ebf2;
    border-radius: 9px;
    padding: 10px 12px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.cal-modal__field textarea { resize: vertical; min-height: 44px; }
.cal-modal__field input:focus,
.cal-modal__field textarea:focus {
    outline: none;
    border-color: #f57328;
    box-shadow: 0 0 0 3px rgba(245, 115, 40, 0.14);
}
.cal-modal__field input.is-invalid,
.cal-modal__field textarea.is-invalid {
    border-color: #e2453b;
    box-shadow: 0 0 0 3px rgba(226, 69, 59, 0.12);
}

/* Feedback (succes / erreur) */
.cal-modal__feedback {
    font-size: 13.5px;
    font-weight: 600;
    border-radius: 9px;
    padding: 10px 13px;
    line-height: 1.4;
}
.cal-modal__feedback--ok    { background: #dcfce7; color: #15803d; }
.cal-modal__feedback--error { background: #fde8e6; color: #c0392b; }

/* Bouton d'envoi */
.cal-modal__submit {
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: #f57328;
    border: none;
    border-radius: 10px;
    padding: 13px 18px;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.cal-modal__submit:hover:not(:disabled) {
    background: #e0631c;
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(245, 115, 40, 0.32);
}
.cal-modal__submit:disabled { opacity: 0.65; cursor: progress; }

@keyframes cal-modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cal-modal-pop {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 480px) {
    .cal-modal__row { grid-template-columns: 1fr; }
    .cal-modal__dialog { padding: 26px 20px 22px; }
}
@media (prefers-reduced-motion: reduce) {
    .cal-modal.is-open .cal-modal__overlay,
    .cal-modal.is-open .cal-modal__dialog { animation: none; }
    .cal-modal__close, .cal-modal__submit { transition: none; }
}
