/**
 * Catalogue Formation Pro — Planning Calendar CSS
 *
 * Structure HTML :
 *   .cfp-planning-container
 *     .cfp-planning-header          → nav + titre + vue
 *     .cfp-planning-filters         → filtres interactifs
 *     .cfp-planning-grid            → contenu dynamique (mois/sem/jour)
 *       VUE MOIS : .cfp-week-header + .cfp-month-body > .cfp-month-row > .cfp-day-cell
 *       VUE SEMAINE : .cfp-week-view-header + .cfp-week-view-body > .cfp-time-row
 *       VUE JOUR : .cfp-day-view > .cfp-day-list > .cfp-day-event-card
 *     .cfp-planning-legend          → légende couleurs
 *     .cfp-popup-overlay            → modale détails
 *
 * Couleurs fallback (Elementor override via {{WRAPPER}}) :
 *   - Purple : #5D2A61
 *   - Orange : #E36B24
 *   - Pas de !important
 */

/* ═══════════════════════════════════════════
   CONTENEUR GLOBAL
   ═══════════════════════════════════════════ */
.cfp-planning-container {
    font-family: inherit;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* ═══════════════════════════════════════════
   EN-TÊTE & NAVIGATION
   ═══════════════════════════════════════════ */
.cfp-planning-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background-color: #5D2A61;
    color: #ffffff;
    flex-wrap: wrap;
    gap: 10px;
}

.cfp-planning-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cfp-planning-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 6px 10px;
    transition: background-color 0.2s;
    font-weight: 600;
}

.cfp-planning-nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
}

.cfp-today-btn {
    font-size: 13px;
    padding: 6px 14px;
    letter-spacing: 0.3px;
}

.cfp-planning-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: #ffffff;
    text-align: center;
    flex: 1;
    min-width: 180px;
}

/* Sélecteur de vue */
.cfp-planning-views {
    display: flex;
    gap: 4px;
    border-radius: 5px;
    overflow: hidden;
}

.cfp-view-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.cfp-view-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.cfp-view-btn.active {
    background-color: #E36B24;
}

/* ═══════════════════════════════════════════
   FILTRES
   ═══════════════════════════════════════════ */
.cfp-planning-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e8e8e8;
    align-items: flex-end;
}

.cfp-filter-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 160px;
    flex: 1;
}

.cfp-filter-item label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}

.cfp-filter-select {
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background-color: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: auto;
}

.cfp-filter-select:focus {
    border-color: #5D2A61;
    outline: none;
    box-shadow: 0 0 0 2px rgba(93, 42, 97, 0.15);
}

.cfp-filter-counter {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #888;
    padding-bottom: 7px;
    white-space: nowrap;
}

.cfp-session-count {
    font-weight: 700;
    color: #5D2A61;
    margin-right: 4px;
    font-size: 15px;
}

/* ═══════════════════════════════════════════
   GRILLE CALENDRIER (zone dynamique)
   ═══════════════════════════════════════════ */
.cfp-planning-grid {
    background-color: #ffffff;
    min-height: 300px;
    position: relative;
}

/* Loading */
.cfp-planning-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    color: #999;
    font-size: 14px;
}

.cfp-loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e0e0e0;
    border-top-color: #5D2A61;
    border-radius: 50%;
    animation: cfpSpin 0.7s linear infinite;
}

@keyframes cfpSpin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   VUE MOIS
   ═══════════════════════════════════════════ */

/* En-tête jours (Lun, Mar, ...) */
.cfp-week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background-color: #f5f0f6;
}

.cfp-week-header-cell {
    padding: 8px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5D2A61;
    border-bottom: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
}

.cfp-week-header-cell:last-child {
    border-right: none;
}

/* Lignes du mois */
.cfp-month-body {
    display: flex;
    flex-direction: column;
}

.cfp-month-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

/* Cellule jour */
.cfp-day-cell {
    min-height: 110px;
    padding: 4px 6px;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    transition: background-color 0.15s;
    overflow: hidden;
}

.cfp-day-cell:last-child {
    border-right: none;
}

.cfp-day-cell:hover {
    background-color: #fafafe;
}

.cfp-day-cell.is-today {
    background-color: #fff8f0;
}

.cfp-day-cell.is-weekend {
    background-color: #fafafa;
}

.cfp-day-cell.outside-month {
    opacity: 0.35;
}

/* Numéro du jour */
.cfp-day-number {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    display: inline-block;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    border-radius: 50%;
    margin-bottom: 2px;
    transition: background-color 0.15s, color 0.15s;
}

.cfp-day-number:hover {
    background-color: #5D2A61;
    color: #fff;
}

.cfp-day-cell.is-today .cfp-day-number {
    background-color: #E36B24;
    color: #fff;
    font-weight: 700;
}

/* Événements dans la cellule */
.cfp-day-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ─── Pill (vue mois) ─── */
.cfp-event {
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.cfp-event:hover {
    opacity: 0.85;
    transform: scale(1.02);
}

.cfp-event-pill {
    display: block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cfp-more-events {
    font-size: 11px;
    color: #5D2A61;
    font-weight: 600;
    padding: 1px 4px;
    cursor: pointer;
}

.cfp-more-events:hover {
    text-decoration: underline;
}

/* ═══════════════════════════════════════════
   VUE SEMAINE
   ═══════════════════════════════════════════ */
.cfp-week-view-header {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    background-color: #f5f0f6;
    position: sticky;
    top: 0;
    z-index: 2;
}

.cfp-time-gutter-header {
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.cfp-week-col-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    gap: 2px;
}

.cfp-week-col-header:last-child {
    border-right: none;
}

.cfp-week-col-header.is-today {
    background-color: #fff3e8;
}

.cfp-week-day-name {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #5D2A61;
}

.cfp-week-day-num {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
}

.cfp-week-col-header.is-today .cfp-week-day-num {
    background-color: #E36B24;
    color: #fff;
}

/* Corps semaine */
.cfp-week-view-body {
    max-height: 500px;
    overflow-y: auto;
}

.cfp-time-row {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    min-height: 48px;
    border-bottom: 1px solid #f0f0f0;
}

.cfp-time-gutter {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #999;
    border-right: 1px solid #e0e0e0;
    background-color: #fafafa;
}

.cfp-time-slot {
    border-right: 1px solid #f0f0f0;
    padding: 2px 3px;
    position: relative;
    min-height: 48px;
}

.cfp-time-slot:last-child {
    border-right: none;
}

.cfp-time-slot.is-today {
    background-color: #fffcf8;
}

/* ─── Block (vue semaine) ─── */
.cfp-event-block {
    display: block;
    padding: 4px 6px;
    border-radius: 3px;
    font-size: 11px;
    color: #ffffff;
    margin-bottom: 3px;
    line-height: 1.3;
}

.cfp-event-block strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cfp-event-block small {
    opacity: 0.85;
    font-size: 10px;
}

/* ═══════════════════════════════════════════
   VUE JOUR
   ═══════════════════════════════════════════ */
.cfp-day-view {
    padding: 20px;
}

.cfp-day-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cfp-day-event-card {
    background-color: #ffffff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 16px 20px;
    transition: box-shadow 0.2s, transform 0.15s;
    cursor: pointer;
}

.cfp-day-event-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.cfp-day-event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.cfp-day-event-title {
    font-size: 16px;
    font-weight: 700;
    color: #222;
    margin: 0;
    line-height: 1.3;
}

.cfp-day-event-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

.cfp-day-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    font-size: 13px;
    color: #555;
}

.cfp-day-event-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cfp-day-event-cat {
    display: inline-block;
    margin-top: 10px;
    padding: 3px 10px;
    background-color: #f0ecf1;
    color: #5D2A61;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* État vide */
.cfp-day-empty {
    text-align: center;
    padding: 50px 20px;
    color: #999;
}

.cfp-day-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.cfp-day-empty p {
    font-size: 15px;
    margin: 0;
}

/* ═══════════════════════════════════════════
   LÉGENDE
   ═══════════════════════════════════════════ */
.cfp-planning-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 20px;
    border-top: 1px solid #eee;
    justify-content: center;
}

.cfp-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #666;
}

.cfp-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--cfp-legend-color, #5D2A61);
}

/* ═══════════════════════════════════════════
   POPUP MODALE
   ═══════════════════════════════════════════ */
.cfp-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cfp-popup-content {
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: cfpPopupIn 0.25s ease-out;
}

@keyframes cfpPopupIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cfp-popup-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    z-index: 1;
    transition: color 0.2s;
}

.cfp-popup-close:hover {
    color: #333;
}

.cfp-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px 12px;
}

.cfp-popup-status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cfp-popup-title {
    font-size: 18px;
    font-weight: 700;
    color: #5D2A61;
    margin: 0;
    line-height: 1.3;
}

.cfp-popup-body {
    padding: 0 24px 16px;
    color: #333;
    font-size: 14px;
}

.cfp-popup-table {
    width: 100%;
    border-collapse: collapse;
}

.cfp-popup-table td {
    padding: 6px 0;
    vertical-align: top;
}

.cfp-popup-table td:first-child {
    width: 100px;
    color: #888;
    font-size: 13px;
    padding-right: 10px;
}

.cfp-popup-table td:first-child strong {
    color: #888;
    font-weight: 600;
}

.cfp-popup-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.cfp-popup-closed {
    color: #dc3232;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
}

.cfp-popup-footer {
    padding: 0 24px 20px;
}

.cfp-popup-cta {
    display: block;
    text-align: center;
    background-color: #E36B24;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.15s;
}

.cfp-popup-cta:hover {
    background-color: #c85a1d;
    transform: translateY(-1px);
    color: #ffffff;
}

.cfp-popup-cta.cfp-cta-disabled {
    background-color: #999;
    cursor: default;
    opacity: 0.7;
}

.cfp-popup-cta.cfp-cta-disabled:hover {
    background-color: #999;
    transform: none;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Header */
    .cfp-planning-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 14px;
    }

    .cfp-planning-title {
        font-size: 16px;
        order: -1;
    }

    .cfp-planning-nav,
    .cfp-planning-views {
        width: 100%;
        justify-content: center;
    }

    /* Filtres */
    .cfp-planning-filters {
        flex-direction: column;
        padding: 10px 14px;
        gap: 8px;
    }

    .cfp-filter-item {
        min-width: 100%;
    }

    /* Cellules mois */
    .cfp-day-cell {
        min-height: 70px;
        padding: 2px 3px;
    }

    .cfp-day-number {
        font-size: 11px;
        width: 22px;
        height: 22px;
        line-height: 22px;
    }

    .cfp-event-pill {
        font-size: 9px;
        padding: 1px 4px;
    }

    .cfp-week-header-cell {
        font-size: 10px;
        padding: 6px 2px;
    }

    /* Vue semaine : scroll horizontal */
    .cfp-week-view-header,
    .cfp-time-row {
        grid-template-columns: 44px repeat(7, minmax(80px, 1fr));
    }

    .cfp-week-view-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cfp-time-gutter {
        font-size: 10px;
    }

    /* Vue jour */
    .cfp-day-view {
        padding: 14px;
    }

    .cfp-day-event-header {
        flex-direction: column;
        gap: 6px;
    }

    .cfp-day-event-meta {
        gap: 8px 12px;
        font-size: 12px;
    }

    /* Popup */
    .cfp-popup-content {
        max-width: 100%;
        margin: 10px;
        border-radius: 8px;
    }

    .cfp-popup-header {
        padding: 16px 18px 10px;
    }

    .cfp-popup-body {
        padding: 0 18px 14px;
    }

    .cfp-popup-footer {
        padding: 0 18px 16px;
    }
}

@media (max-width: 480px) {
    .cfp-week-header-cell {
        font-size: 9px;
    }

    .cfp-day-cell {
        min-height: 56px;
    }

    .cfp-event-pill {
        font-size: 8px;
    }

    .cfp-planning-title {
        font-size: 14px;
    }

    .cfp-view-btn {
        font-size: 11px;
        padding: 5px 10px;
    }
}


.cfp-planning-nav-btn:focus-visible,
.cfp-view-btn:focus-visible,
.cfp-filter-select:focus-visible,
.cfp-event:focus-visible,
.cfp-day-event-card:focus-visible,
.cfp-popup-close:focus-visible,
.cfp-popup-cta:focus-visible {
    outline: 3px solid rgba(93, 42, 97, 0.28);
    outline-offset: 2px;
}

.cfp-event-pill,
.cfp-event-block {
    border: none;
}

.cfp-popup-overlay[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .cfp-loading-spinner,
    .cfp-popup-content,
    .cfp-event,
    .cfp-day-event-card,
    .cfp-popup-cta {
        animation: none;
        transition: none;
    }
}
