/* =============================================
   Calendrier
   ============================================= */

.calendar {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    max-width: min(100%, 800px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

/* Calendrier en split view : hauteur naturelle basée sur le contenu */
main.split-view-tab .calendar {
    max-width: 100%;
    margin: 0;
    min-height: 400px; /* Hauteur min confortable */
    overflow: hidden; /* Empêche les cases de déborder */
}

/* Calendrier large pour le planning (beaucoup de contenu) */
.calendar-large {
    max-width: 100%;
    max-height: none;
    min-height: 500px;
}

.calendar-large .calendar-grid {
    gap: 8px;
}

.calendar-large .calendar-day {
    aspect-ratio: auto;
    min-height: 150px;
    max-height: 250px;
    padding: var(--spacing-sm);
    overflow: auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-md);
}

.calendar-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    flex: 1;
}

/* Boutons de navigation du calendrier */
.calendar-nav {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.calendar-nav button,
.calendar-header button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all var(--transition-normal);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
}

.calendar-nav button .btn-icon-emoji,
.calendar-header button .btn-icon-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 14px;
    flex-shrink: 0;
}

.calendar-nav button:hover,
.calendar-header button:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.calendar-nav button:disabled,
.calendar-header button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Grille du calendrier */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-top: var(--spacing-md);
}

.calendar-day-header {
    text-align: center;
    padding: var(--spacing-sm);
    font-weight: 700;
    color: var(--primary-color);
    background: rgba(46, 204, 113, 0.1);
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    text-transform: uppercase;
}

.calendar-day {
    min-height: 110px;
    max-height: 180px;
    padding: var(--spacing-xs);
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

.calendar-day:hover {
    background: rgba(46, 204, 113, 0.05);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.15);
}

.calendar-day.today {
    background: #FFF9E6;
    border: 2px solid var(--primary-dark);
}

.calendar-day.ferie {
    background: #FFE4E1;
    opacity: 0.7;
}

.calendar-day.vacances {
    background: #FFF9E6;
    opacity: 0.8;
}

.calendar-day.weekend,
.calendar-day.mercredi {
    background: #F0F0F0;
    opacity: 0.8;
}

.calendar-day.disabled,
.calendar-day.weekend,
.calendar-day.mercredi {
    background: #F5F5F5;
    opacity: 0.5;
    cursor: not-allowed;
}

.calendar-badge-ferie {
    font-size: 10px;
    color: #E74C3C;
    font-weight: bold;
}

.calendar-badge-vacances {
    font-size: 10px;
    color: #F39C12;
    font-weight: bold;
}

.calendar-day.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.calendar-day.disabled {
    background: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
}

.calendar-day.disabled:hover {
    transform: none;
    border-color: #e0e0e0;
}

/* Éléments du jour */
.calendar-day-number {
    font-weight: bold;
    margin-bottom: 5px;
}

.calendar-badge-ferie {
    font-size: 10px;
    color: #E74C3C;
    font-weight: bold;
}

.calendar-badge-vacances {
    font-size: 10px;
    color: #F39C12;
    font-weight: bold;
}

/* Checkboxes de sélection */
.calendar-checkboxes {
    margin-top: 8px;
}

.calendar-checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 3px;
}

.calendar-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Indicateurs de présences */
.calendar-presences {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
}

.calendar-presence-midi {
    color: #FF9800;
    font-weight: bold;
    white-space: nowrap;
}

.calendar-presence-soir {
    color: #3F51B5;
    font-weight: bold;
    white-space: nowrap;
}

.calendar-departs {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 4px;
}

/* Indicateurs de volontaires */
.calendar-volontaires {
    margin-top: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: #4CAF50;
    font-weight: bold;
}

.calendar-volontaire-item {
    white-space: nowrap;
}

/* Indicateurs de capacité */
.calendar-capacite {
    margin-top: 4px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
}

.calendar-capacite-item {
    white-space: nowrap;
}
}

.calendar-day-number {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.calendar-day-indicator {
    font-size: 9px;
    margin-top: auto;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Checkboxes dans le calendrier */
.calendar-checkboxes {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: 4px;
}

.calendar-checkboxes label {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .calendar {
        max-width: 100%;
        padding: var(--spacing-md);
        min-height: 300px;
    }

    .calendar-header {
        flex-direction: row;
        gap: var(--spacing-sm);
    }

    .calendar-header .calendar-title {
        flex: 1;
        text-align: center;
        font-size: 1rem;
    }

    .calendar-nav button,
    .calendar-header button {
        padding: 8px 12px;
        font-size: 16px;
        min-width: 40px;
    }

    /* ========================================
       MASQUER SAMEDI ET DIMANCHE EN MOBILE
       ======================================== */

    /* Masquer les en-têtes samedi (6ème) et dimanche (7ème) */
    .calendar-weekdays-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    .calendar-weekdays-grid > div:nth-child(6),
    .calendar-weekdays-grid > div:nth-child(7),
    .calendar-weekday-cell:nth-child(6),
    .calendar-weekday-cell:nth-child(7) {
        display: none !important;
    }

    /* Masquer tous les jours de weekend dans la grille */
    .calendar-days-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    /* Masquer les jours avec classe weekend (samedi et dimanche) */
    .calendar-day.weekend,
    div.weekend.calendar-day,
    .calendar-days-grid .weekend {
        display: none !important;
    }

    /* Griser les mercredis en mobile (jour non travaillé) */
    .calendar-day.mercredi {
        background: #F5F5F5 !important;
        opacity: 0.5 !important;
        cursor: not-allowed !important;
    }

    /* Masquer les cases vides qui tombent sur weekend
       En sachant que la semaine commence lundi (index 0),
       samedi = index 5 = position 6, 13, 20, 27, 34 = 7n+6
       dimanche = index 6 = position 7, 14, 21, 28, 35 = 7n ou 7n+7 */
    .calendar-days-grid > .calendar-empty-day:nth-child(7n+6),
    .calendar-days-grid > .calendar-empty-day:nth-child(7n+7),
    .calendar-days-grid > .calendar-empty-day:nth-child(7n) {
        display: none !important;
    }

    /* Pour l'ancienne structure avec calendar-grid */
    .calendar-grid {
        grid-template-columns: repeat(5, 1fr) !important;
    }

    .calendar-grid > .calendar-day.weekend,
    .calendar-grid > div.weekend {
        display: none !important;
    }

    .calendar-day {
        font-size: 10px;
        padding: 1px;
        min-height: 50px;
        /* max-height: 70px;
        overflow: hidden !important; */
    }

    .calendar-day-number {
        font-size: 11px;
        margin-bottom: 1px;
    }

    .calendar-day-indicator {
        font-size: 7px;
    }

    .calendar-checkboxes {
        flex-direction: column;
        gap: 1px;
    }

    /* Compacter les colonnes MIDI/SOIR en mobile */
    .calendar-unified-split {
        margin-top: 4px;
        gap: 2px;
    }

    .calendar-unified-column {
        padding: 2px;
        font-size: 9px;
    }

    /* Réduire taille des compteurs et badges */
    .calendar-counter {
        font-size: 9px !important;
    }

    .calendar-badge-ferie,
    .calendar-badge-vacances {
        font-size: 8px;
    }

    /* Limiter hauteur des zones de compteurs */
    .calendar-presences-left,
    .calendar-presences-right,
    .calendar-volunteers-left,
    .calendar-volunteers-right,
    .calendar-capacity-left,
    .calendar-capacity-right {
        font-size: 9px;
        gap: 2px;
    }
}

/* =============================================
   Calendar Tooltips
   ============================================= */

.calendar-tooltip {
    position: absolute;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 250px;
    max-width: 400px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.9rem;
    line-height: 1.5;
}

.calendar-tooltip.show {
    opacity: 1;
}

.calendar-tooltip strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 8px;
}

.calendar-tooltip ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.calendar-tooltip li {
    padding: 4px 0;
    color: var(--text-dark);
}

.calendar-tooltip .tooltip-section {
    margin-bottom: 10px;
}

.calendar-tooltip .tooltip-section:last-child {
    margin-bottom: 0;
}

/* Responsive tooltips */
@media (max-width: 768px) {
    .calendar-tooltip {
        min-width: 200px;
        max-width: 90vw;
        font-size: 0.85rem;
        padding: var(--spacing-sm);
    }
}

/* =============================================
   Additional Calendar Classes (No Inline Styles)
   ============================================= */

/* Empty day cells */
.calendar-empty-day {
    background: #F5F5F5;
    border-radius: 8px;
}

/* Week days header */
.calendar-weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    padding: 10px;
    background: #E3F2FD;
}

.calendar-weekday-cell {
    text-align: center;
    font-weight: bold;
    font-size: 14px;
}

/* Days grid */
.calendar-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    padding: 10px;
}

/* Presences container - split left/right */
.calendar-presences-split {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    font-size: 12px;
}

.calendar-presences-left,
.calendar-presences-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.calendar-presences-left {
    justify-content: flex-start;
}

.calendar-presences-right {
    justify-content: flex-end;
}

.calendar-split-header {
    font-size: 14px;
    opacity: 0.7;
    margin-right: 4px;
}

.calendar-presence-midi-badge {
    color: #FF9800;
    font-weight: bold;
    white-space: nowrap;
}

.calendar-presence-soir-badge {
    color: #3F51B5;
    font-weight: bold;
    white-space: nowrap;
}

.calendar-departures {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 4px;
}

/* Checkboxes planification */
.calendar-planif-container {
    margin-top: 8px;
}

.calendar-planif-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 3px;
}

.calendar-planif-label:last-child {
    margin-bottom: 0;
}

.calendar-planif-checkbox {
    width: 16px;
    height: 16px;
}

/* Volunteers - split left/right */
.calendar-volunteers-split {
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    font-size: 11px;
    color: #4CAF50;
    font-weight: bold;
}

.calendar-volunteers-left,
.calendar-volunteers-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.calendar-volunteers-left {
    justify-content: flex-start;
}

.calendar-volunteers-right {
    justify-content: flex-end;
}

.calendar-volunteer-badge {
    white-space: nowrap;
}

/* Capacity - split left/right */
.calendar-capacity-split {
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    font-size: 11px;
}

.calendar-capacity-left,
.calendar-capacity-right {
    flex: 1;
    display: flex;
    align-items: center;
}

.calendar-capacity-left {
    justify-content: flex-start;
}

.calendar-capacity-right {
    justify-content: flex-end;
}

.calendar-capacity-badge {
    white-space: nowrap;
}

.calendar-capacity-badge.high-capacity {
    color: #4CAF50;
}

.calendar-capacity-badge.low-capacity {
    color: #F44336;
}

/* Tooltip formatting */
.calendar-tooltip-title {
    font-size: 1.1em;
    font-weight: bold;
}

.calendar-tooltip-time {
    color: #4CAF50;
}

/* ============================================
   COLONNES UNIFIÉES MIDI | SOIR (Générique)
   ============================================ */

.calendar-unified-split {
    margin-top: 8px;
    display: flex;
    gap: 4px;
    font-size: 11px;
}

.calendar-column-left,
.calendar-column-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 2px;
    min-width: 0; /* Pour le responsive */
}

.calendar-split-header {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 2px;
    line-height: 1;
}

.calendar-counter {
    white-space: nowrap;
    font-weight: 600;
    font-size: 11px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.calendar-capacity-ratio {
    margin-top: 2px;
    font-size: 10px;
    font-weight: bold;
    color: #4CAF50;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 2px;
    width: 100%;
    text-align: center;
}

/* Responsive - colonnes plus étroites sur mobile */
@media (max-width: 768px) {
    .calendar-counter {
        font-size: 10px;
    }

    .calendar-split-header {
        font-size: 12px;
    }

    .calendar-capacity-ratio {
        font-size: 9px;
    }

    /* Les règles de masquage weekend sont déjà définies plus haut dans le @media */
}

.calendar-tooltip-arrival {
    color: #4CAF50;
}

.calendar-tooltip-departure {
    color: #FF9800;
}

/* =============================================
   Barres de vacances scolaires
   ============================================= */

.vacances-container {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.vacances-title {
    margin-bottom: 12px;
    color: #F39C12;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vacances-title-icon {
    font-size: 20px;
}

.vacances-item {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.vacances-label {
    min-width: 200px;
    font-size: 13px;
    font-weight: 600;
    color: #E67E22;
}

.vacances-bar {
    flex: 1;
    height: 26px;
    background: linear-gradient(90deg, #FFE4B5 0%, #FFD700 100%);
    border-radius: 13px;
    position: relative;
    box-shadow: 0 3px 8px rgba(243, 156, 18, 0.4);
    border: 2px solid #FFA500;
}

.vacances-dates {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #333;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
