/* Conteneur principal */
.calendar-container {
    max-width: 1600px;
    margin: 20px auto;
    padding: 20px;
    font-family: \'Segoe UI\', Arial, sans-serif;
    color: #333;
}

.calendar-container h2 {
    margin-bottom: 25px;
    font-size: 28px;
    color: #2c3e50;
    text-align: center;
}

/* Navigation et contrôles */
.calendar-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    gap: 20px;
}

.month-navigation, .week-navigation {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.month-navigation h2 {
    margin: 0 15px;
    font-size: 22px;
    color: #2c3e50;
}

.view-switch {
    margin-bottom:30px;
}

.nav-btn {
    padding: 8px 15px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-decoration: none;
    color: #555;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.nav-btn:hover {
    background-color: #e9ecef;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Structure du calendrier */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 30px;
    margin-bottom: 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.calendar-row-break {
    grid-column: 1 / -1;
    height: 0;
}

/* === HEADER STYLE FULLCALENDAR === */
.calendar-header {
    display: flex;
    justify-content: space-between; /* gauche / droite */
    align-items: center;     /* centre verticalement */
    flex-wrap: wrap;         /* permet de passer sur plusieurs lignes si écran petit */
    gap: 20px;               /* espace entre nav-left et nav-right */
    padding: 15px 20px;
    background: #fff;
    position: relative;
    font-size: 18px;
}

/* Bloc gauche (flèches + titre) centré par rapport au parent */
.calendar-nav-left {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Bloc droit (vues) reste à l'extrémité droite */
.calendar-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto; /* pousse le bloc à droite */
}

.calendar-title {
    font-size: 26px;
    font-weight: 600;
    color: #2c3e50;
    min-width: 180px;
    text-align: center;
}

/* === BOUTONS VUE === */
.view-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    text-decoration: none;
    color: #555;
    border-radius: 4px;
    font-size: 18px;
}

.view-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

/* === FILTRES === */
.calendar-filters {
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
    padding: 10px 20px;
}

/* Bouton catégorie homogène avec nav-btn / view-btn */
.category-legend {
    margin: 0;
    padding: 0;
    background: none;
}

.category-toggle {
    padding: 8px 15px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #555;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: inline-flex;
    align-items: center;
    gap: 5px; /* espace entre texte et flèche */
}

.category-toggle:hover {
    background-color: #e9ecef;
    color: #333;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
}

/* Rotation flèche quand ouvert */
.category-toggle.open .toggle-arrow {
    transform: rotate(180deg);
}

.calendar-day {
    height: 300px;
    border: 1px solid #ddd;
    padding: 8px;
    position: relative;
    background-color: #fff;
    transition: all 0.2s ease;
}

.calendar-day:hover {
    background-color: #f8f9fa;
}

.calendar-day.empty {
    background-color: #f9f9f9;
}

.calendar-day.today {
    border-color: #3498db;
    box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.3);
    background-color: #ebf5fb;
}

/* Hauteur des jours selon la vue */
.calendar-grid.calendar-day {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

/* Conteneur de la semaine */
.calendar-grid.week-view {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr); /* 60px pour la colonne des heures */
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

/* Ligne de jour (en-têtes) */
.calendar-row {
    display: contents; /* pour que chaque "div" enfant occupe sa place dans la grille */
}

/* Cellules des heures */
.hour-column {
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    border-right: 1px solid #ddd;
    padding: 4px;
    text-align: right;
    font-size: 12px;
    font-weight: bold;
}

/* Cellules des jours */
.day-column {
    border-bottom: 1px solid #ddd;
    border-right: 1px solid #ddd;
    position: relative;
    min-height: 40px; /* hauteur d'une ligne horaire */
}

/* En-têtes de jour */
.calendar-header.day-column {
    background-color: #3498db;
    color: #fff;
    text-align: center;
    font-weight: bold;
    padding: 5px 2px;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

/* Les étiquettes horaires (colonne de gauche) */
.calendar-hour-label.hour-column {
    font-size: 11px;
    color: #555;
    padding-right: 5px;
}

.hour-cell {
    border: 1px solid #ddd;
    min-height: 40px;
    position: relative;
}

.hour-label {
    font-size: 10px;
    color: #666;
}

.calendar-grid.month-view .calendar-day {
    height: 160px;
}

.calendar-hour-label {
    border: 1px solid #ddd;
    min-height: 40px;
    text-align: right;
    padding-right: 5px;
    font-size: 11px;
    color: #666;
}

.calendar-hour {
    border: 1px solid #ddd;
    min-height: 40px;
    position: relative;
}

/* Container de la vue jour */
.day-view {
    display: grid;
    grid-template-columns: 80px 1fr; /* 80px pour la colonne des heures, le reste pour les événements */
    margin: 20px 0; /* margin top et bottom */
}

/* Ligne d'heure */
.day-view .calendar-row {
    display: contents; /* pour que les colonnes se placent correctement dans le grid */
}

/* Colonne heure */
.day-view .calendar-hour-label {
    grid-column: 1;
    text-align: right;
    padding-right: 10px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
}

/* Colonne des événements */
.day-view .calendar-hour.day-column {
    grid-column: 2;
    border-bottom: 1px solid #eee;
    position: relative;
    min-height: 40px; /* hauteur par ligne d'heure */
}

/* Events */
.day-view .event {
    position: absolute;
    top: 0;
    height: 100%;
    padding: 2px 4px;
    box-sizing: border-box;
    border-radius: 4px;
    background-color: var(--event-color, #999);
    color: #fff;
    overflow: hidden;
}

.day-number {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 8px;
    color: #555;
}

.today .day-number {
    color: #3498db;
    font-weight: 700;
}

/* Styles des événements */
.day-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.event-group {
    position: relative;
    height: 50px;
    margin-bottom: 4px;
}

.event {
    position: absolute;
    top: 0;
    height: 100%;
    background-color: var(--event-color);
    color: white;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 4px;
    overflow: hidden;
    box-sizing: border-box;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.event:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
    z-index: 10;
}

.event-time {
    font-weight: bold;
    white-space: nowrap;
    opacity: 0.9;
}

.event-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.event-categories {
    display: flex;
    gap: 3px;
    margin-top: 3px;
}

.category-badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--category-color);
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.event-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.calendar-list-view {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ligne complète */
.list-event-row {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 1rem 0;
}

/* Date à gauche */
.list-event-date {
    width: 90px;
    text-align: center;
    color: #aaa;
    flex-shrink: 0;
}

.date-day {
    font-size: 2.5rem;
    font-weight: 300;
}

.date-month {
    font-size: 1rem;
    text-transform: capitalize;
}

/* Contenu principal */
.list-event-content {
    display: flex;
    flex: 1;
}

/* Barre couleur */
.list-event-color {
    width: 4px;
    margin-right: 1rem;
}

/* Détails */
.list-event-details {
    flex: 1;
}

.list-event-title {
    margin: 0 0 0.4rem 0;
}

.list-event-title a {
    color: #222;
    text-decoration: none;
    font-weight: 600;
}

.list-event-title a:hover {
    text-decoration: underline;
}

/* Meta infos */
.list-event-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: #666;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

.list-month-title {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eee;
    text-transform: capitalize;
    color: #333;
}

/* Bouton */
.event-more {
    display: inline-block;
    padding: 0.4rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    color: #444;
    transition: background 0.2s;
}

.event-more:hover {
    background: #f5f5f5;
}


.event-button {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    background: #eee;
    color: #333;
    font-size: 0.8rem;
    text-decoration: none;
    border-radius: 3px;
    margin-top: 0.3rem;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.legend-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reset-filter {
    font-size: 14px;
    color: #3498db;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #eaf2f8;
    transition: all 0.2s ease;
}

.reset-filter:hover {
    background-color: #d4e6f1;
    color: #2874a6;
}

.legend-tree {
    flex-wrap: wrap;
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 20px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.legend-tree.collapsed {
    max-height: 0;
}

.calendar-container.list-view .legend-tree {
    margin: 0;
}

.toggle-filter {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: #f0f0f0;
    transition: all 0.2s ease;
}

.toggle-filter:hover {
    background-color: #e0e0e0;
}

.toggle-filter .toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-filter.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.legend-item {
    flex: 0 0 auto;
    min-width: 150px;
    margin-bottom: 5px;
    border-radius: 6px;
    background-color: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.legend-item.selected {
    background-color: #e8f4fc;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.legend-item.selected .legend-item-link {
    font-weight: 500;
}

.legend-item.selected .color-indicator {
    transform: scale(1.2);
}

.legend-item-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
    padding: 8px 12px;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.legend-item-link:hover {
    transform: translateX(3px);
}

.legend-item-link:hover .legend-label {
    color: #3498db;
    font-weight: 500;
}

.legend-item-link:hover .color-indicator {
    transform: scale(1.2);
}

.color-indicator {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background-color: var(--category-color);
    margin-right: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}

.legend-label {
    font-size: 18px;
    color: #333;
    transition: color 0.2s ease;
}

/* Filtres de catégories */
.category-filter {
    margin-bottom: 20px;
    width: 100%;
    border-radius: 8px;
    padding: 15px;
    background-color: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.category-filter select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: white;
    font-size: 16px;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 24 24\' fill=\'none\' stroke=\'currentColor\' stroke-width=\'2\' stroke-linecap=\'round\' stroke-linejoin=\'round\'%3e%3cpolyline points=\'6 9 12 15 18 9\'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1em;
}

.category-filter select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.filter-header {
    margin-bottom: 12px;
}

.filter-header label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

.category-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category-checkbox {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 6px;
    background-color: white;
    border-left: 4px solid var(--category-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.category-checkbox:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.category-checkbox input {
    margin-right: 8px;
}

.category-checkbox label {
    cursor: pointer;
}

.calendar-tutorial {
    margin: 30px 15%;
    padding: 20px;
    border-radius: 8px;
    background-color: #ebf7ff;
    border: 1px solid #b3e0ff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.tutorial-title {
    color: #0078d7;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
}

.tutorial-title svg {
    margin-right: 10px;
}

.tutorial-steps {
    list-style: none;
    padding-left: 15px;
    margin-bottom: 15px;
}

.tutorial-steps li {
    margin-bottom: 10px;
    position: relative;
    padding-left: 20px;
}

.tutorial-steps li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #0078d7;
}

.export-button {
    display: inline-flex;
    align-items: center;
    background-color: #0078d7;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.export-button:hover {
    background-color: #0056a3;
}

.export-button svg {
    margin-right: 8px;
}

.month-pagination {
    margin-top: 30px;
    text-align: center;
}

.month-pagination a {
    display: inline-block;
    padding: 6px 10px;
    margin: 0 4px;
    border: 1px solid #ccc;
    text-decoration: none;
    color: #333;
}

.month-pagination a.active {
    background: #1f3b6d;
    color: #fff;
    font-weight: bold;
}

/* Nettoyage du header pour éviter le chevauchement */
.calendar-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important; /* On enlève le absolute s'il y en avait */
    padding: 15px 20px !important;
    background: #fff !important;
    transform: none !important;
    left: 0 !important;
}

/* On force le groupe de gauche à rester groupé */
.calendar-nav-left {
    position: static !important;
    transform: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 15px !important;
}

.nav-arrows {
    display: flex;
    gap: 5px;
}

/* Style des boutons type Google */
.nav-btn.today-btn {
    padding: 8px 18px !important;
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    color: #374151 !important;
    font-size: 16px !important;
}

/*.nav-btn.arrow {*/
/*    padding: 5px 10px !important;*/
/*    border-radius: 50% !important;*/
/*}*/

/* Les flèches ❮ ❯ */
.nav-btn.arrow {
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
    color: #4b5563 !important;
    width: 30px !important;
    height: 30px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important; /* Rond parfait */
    transition: all 0.2s ease;
    font-size: 14px !important;
}

.nav-btn.arrow:hover {
    background: #f3f4f6 !important;
    border-color: #9ca3af !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.calendar-title {
    font-size: 28px !important; /* Plus grand */
    font-weight: 700 !important; /* Plus gras pour l'impact */
    color: #1f2937; /* Un gris-noir très profond, plus pro que le noir pur */
    letter-spacing: -0.5px; /* Un peu plus serré pour le look "Design" */
    margin-left: 15px !important;
    text-transform: capitalize; /* Force la majuscule sur le mois */
    margin: 0 !important;
    min-width: auto !important;
    text-align: left !important;
}

/* Optionnel : On peut ajouter un petit effet sur l'année */
.calendar-title::after {
    color: #9ca3af; /* L'année en gris plus clair */
    font-weight: 400;
    margin-left: 8px;
}

/* Groupe de boutons de vue collés */
.calendar-nav-right {
    display: flex !important;
    overflow: hidden;
}

.calendar-nav-right .view-btn {
    margin: 0 !important;
    border: none !important;
    border-right: 1px solid #dadce0 !important;
    border-radius: 5px !important;
}

.calendar-nav-right .view-btn:last-child {
    border-right: none !important;
}

.calendar-nav-right .view-btn.active {
    background: #e8f0fe !important;
    color: #1a73e8 !important;
}

/* Responsive */
@media (max-width: 768px) {
    .month-navigation {
        flex-direction: column;
        align-items: center;
    }

    .month-navigation h2 {
        margin: 10px 0;
    }

    .calendar-grid {
        gap: 4px;
    }

    .calendar-day {
        min-height: 100px;
        padding: 5px;
    }

    .event {
        font-size: 10px;
        padding: 2px 4px;
    }
}

@media (max-width: 768px) {
    /* --- 1. Container Global --- */
    .calendar-container {
        width: 95% !important;
        padding: 10px 5px !important;
        margin: 10px auto !important;
    }

    /* --- 2. Header & Navigation --- */
    .calendar-header {
        flex-direction: column !important; /* Empile nav et vues */
        align-items: center !important;
        gap: 15px !important;
        padding: 2px !important;
        position: relative !important;
    }

    .calendar-nav-left {
        position: static !important; /* On annule le centrage absolu du PC */
        transform: none !important;
        width: 100%;
        justify-content: space-between;
    }

    .calendar-title {
        font-size: 1.2rem !important;
        min-width: auto !important;
    }

    .calendar-nav-right {
        width: 100%;
        justify-content: center;
        gap: 5px !important;
        margin-bottom: 5px;
    }

    .view-btn {
        flex: 1; /* Les boutons prennent toute la largeur à parts égales */
        text-align: center;
        padding: 8px 4px !important;
        font-size: 14px !important;
    }

    .nav-btn.arrow {
        width: 15px !important;
        height: 15px !important;
    }
    /* --- 3. Filtres & Légendes --- */
    .category-checkboxes {
        flex-direction: column !important;
    }

    .category-checkbox {
        width: 100% !important;
        box-sizing: border-box;
    }

    /* --- 4. La Grille du Mois (Le plus important) --- */
    .calendar-grid.month-view {
        display: flex !important; /* On passe de GRID à FLEX pour empiler */
        flex-direction: column;
        gap: 10px;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* On cache les en-têtes Lun, Mar, Mer... qui ne servent plus en mode liste */
    .calendar-grid.month-view .calendar-header:not(.day-column) {
        display: none !important;
    }

    /* Transformation des jours en cartes */
    .calendar-day {
        height: auto !important;
        min-height: auto !important;
        border-radius: 8px !important;
        border: 1px solid #eee !important;
        margin-bottom: 5px;
        display: flex;
        flex-direction: row; /* Numéro à gauche, événements à droite */
        align-items: flex-start;
        gap: 15px;
        padding: 12px !important;
    }

    /* On ne cache les jours vides que si tu veux une vue compacte */
    .calendar-day.empty {
        display: none !important;
    }

    .day-number {
        font-size: 20px !important;
        min-width: 30px;
        border-right: 2px solid #3498db;
        margin: 0 !important;
    }

    /* --- 5. Vue Semaine / Jour --- */
    .calendar-grid.week-view, .day-view {
        grid-template-columns: 50px 1fr !important; /* Heures plus petites */
        font-size: 12px;
    }

    .event {
        position: relative !important; /* On annule l'absolute pour éviter les chevauchements illisibles */
        width: 100% !important;
        left: 0 !important;
        margin-bottom: 3px;
        height: auto !important;
        min-height: 30px;
    }

    .event-group {
        height: auto !important;
    }

    /* --- 6. Vue Liste --- */
    .list-event-row {
        flex-direction: column !important;
    }
    .list-event-date {
        width: 100% !important;
        text-align: left !important;
        margin-bottom: 10px;
        border-bottom: 1px dashed #eee;
    }

    .calendar-tutorial {
        animation: slideDown 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
        /* On s'assure que l'élément est bien géré pendant l'animation */
        backface-visibility: hidden;
    }

    @keyframes slideDown {
        0% {
            opacity: 0;
            transform: translateY(-30px); /* On part de plus haut */
        }
        100% {
            opacity: 1;
            transform: translateY(0);
        }
    }
}