/* MEC Year Calendar Styles - Version renforcée avec filtrage */
.mec-year-calendar {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    clear: both;
}

/* Réinitialisation pour éviter les conflits de thème */
.mec-year-calendar * {
    box-sizing: border-box;
}

/* Header avec filtrage */
.calendar-header {
    /*display: flex;*/
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.calendar-header h2 {
    margin: 0;
    color: #333;
    font-size: 2rem;
    flex: 1;
}

.calendar-title {
    text-align: left;
    margin: 0 !important;
}

/* Conteneur de filtrage */
.filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #ddd;
    min-width: 250px;
}

.filter-label {
    font-weight: 500;
    color: #555;
    margin: 0;
    white-space: nowrap;
    font-size: 0.9rem;
}

.tag-filter {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.9rem;
    background: white;
    min-width: 150px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tag-filter:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.tag-filter:hover {
    border-color: #999;
}

/* Responsive pour le header */
@media (max-width: 768px) {
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .calendar-title {
        text-align: center;
        margin-bottom: 0;
    }
    
    .filter-container {
        justify-content: center;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .filter-container {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    .label-filter {
        width: 100%;
        min-width: auto;
    }
}

.mec-year-calendar .calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.5rem !important;
    margin-bottom: 2rem;
    width: 100% !important;
    float: none !important;
    flex-direction: row !important;
}

.mec-year-calendar .calendar-grid::before,
.mec-year-calendar .calendar-grid::after {
    display: none !important;
}

/* Forcer les conteneurs de mois à respecter la grille */
.mec-year-calendar .month-container {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: none !important;
    float: none !important;
    display: block !important;
    margin: 0 !important;
}

/* Grid Layout */
.calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.5rem !important;
    margin-bottom: 2rem;
    width: 100%;
}

/* Force la grille même si le thème interfère */
.mec-year-calendar .calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
}

/* Assurer que les conteneurs de mois prennent la bonne taille */
.calendar-grid .month-container {
    width: 100%;
    max-width: none;
    flex: none !important;
}

@media (max-width: 768px) {
    .calendar-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .calendar-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Month Container */
.month-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.month-header {
    background: #f8f9fa;
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid #ddd;
}

.month-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
    text-transform: capitalize;
}

/* Calendar Grid */
.month-calendar {
    padding: 0.5rem;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 0.5rem;
}

.weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: #666;
    padding: 0.25rem;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

/* Day Styles */
.day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    border-radius: 50%;
    min-height: 32px;
    font-size: 0.8rem;
    font-weight: 500;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
}

.day.empty {
    cursor: default;
    pointer-events: none;
    background: none;
    border: none;
}

/* Style pour les jours sans événements */
.day:not(.has-events):not(.empty) {
    cursor: default !important;
    opacity: 0.6;
}

.day.has-events {
    cursor: pointer;
}

.day.has-events:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.day.square {
    border-radius: 4px;
}

.day-number {
    color: #333;
    position: relative;
    z-index: 1;
}

/* Event colors will be applied via inline styles */
.day:not(.empty) {
    background-color: #FFF;
    border: 1px solid #FFF;
}

/* Sidebar */
.events-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.events-sidebar.open {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
}

.sidebar-header h3 {
    margin: 0;
    color: #333;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-sidebar:hover {
    background-color: #ddd;
}

.sidebar-content {
    padding: 1.5rem;
}

/* Day Events */
.day-events h4 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.2rem;
    text-transform: capitalize;
}

.no-events {
    color: #666;
    font-style: italic;
    margin: 2rem 0;
    text-align: center;
}

.events-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.event-item {
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 1rem;
    background: #fafafa;
    transition: box-shadow 0.2s ease;
}

.event-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.event-header {
    margin-bottom: 0.75rem;
}

.event-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 1rem;
}

.event-title a {
    color: #0073aa;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.event-title a:hover {
    color: #005a87;
    text-decoration: underline;
}

.external-link {
    font-size: 0.8rem;
    opacity: 0.7;
}

.event-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
    margin-top: 0.25rem;
}

.time-icon {
    font-size: 0.8rem;
}

.event-tags {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tags-title {
    font-size: 0.8rem;
    color: #666;
    font-weight: 500;
}

.tag-badge {
    padding: 0.2rem 0.6rem;
    border: 1px solid #0640e6;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #0640e6;
}

.event-category {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #333;
    display: inline-block;
}

/* Overlay */
.calendar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.calendar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* États de chargement */
.calendar-content.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.calendar-content.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 100;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 101;
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.loading-spinner p {
    margin: 0;
    color: #666;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading State pour la sidebar */
.sidebar-content.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.sidebar-content.loading::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Messages d'erreur */
.error-message {
    color: #d32f2f;
    text-align: center;
    padding: 1rem;
    background: #ffebee;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    margin: 1rem 0;
}

.filter-error {
    background: #ffebee;
    border: 1px solid #ffcdd2;
    padding: 0.75rem;
    border-radius: 4px;
    margin: 1rem 0;
    text-align: center;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .events-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .day {
        min-height: 28px;
        font-size: 0.7rem;
    }
    
    .month-header h3 {
        font-size: 1rem;
    }
    
    .filter-container {
        padding: 0.5rem;
        min-width: auto;
    }
    
    .label-filter {
        font-size: 0.8rem;
        padding: 0.4rem;
    }
}

/* Style pour les événements toute la journée */
.event-time.all-day {
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.event-time.all-day .all-day-label {
    font-weight: 500;
    font-style: italic;
}

/* Différenciation visuelle entre événements avec heure et toute la journée */
.event-time:not(.all-day) {
    border-radius: 8px;
    padding: 3px 6px;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Amélioration de l'affichage des heures */
.event-time .time-icon {
    font-size: 0.9em;
}

/* Style pour les événements dans la sidebar */
.events-list .event-item {
    border-left: 3px solid #ddd;
    padding-left: 12px;
    margin-bottom: 16px;
    position: relative;
}

.events-list .event-item:hover {
    border-left-color: #4a90e2;
}

.event-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.event-title a {
    font-weight: 600;
    color: #2d3748;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.event-title a:hover {
    color: #4a90e2;
    text-decoration: underline;
}

.external-link {
    font-size: 0.8em;
    opacity: 0.7;
}

/* Responsive pour mobile */
@media (max-width: 480px) {
    .event-time {
        font-size: 0.8em;
        padding: 2px 4px;
    }
    
    .event-time.all-day {
        font-size: 0.75em;
        padding: 3px 6px;
    }
    
    .event-header {
        gap: 4px;
    }
}

/* Styles pour le badge des événements multiples */
.day {
    position: relative;
}

.events-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #00206A;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    line-height: 1;
}

/* Assurer que le badge reste visible sur hover */
.day:hover .events-badge {
    transform: scale(1.1);
    z-index: 11;
}

/* Responsive pour mobile */
@media (max-width: 480px) {
    .events-badge {
        width: 16px;
        height: 16px;
        font-size: 0.6rem;
        top: -4px;
        right: -4px;
    }
}

/* Animation du badge */
@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.events-badge {
    animation: badge-pulse 0.3s ease-in-out;
}

/* Amélioration de l'affichage des heures en format français */
.event-time {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Style spécial pour les heures masquées */
.event-time.hidden {
    display: none;
}

/* Amélioration du contraste pour les badges de catégorie */
.category-badge {
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Styles spécifiques pour le filtrage */
.filter-active {
    background-color: #e3f2fd !important;
    border-color: #2196f3 !important;
}

/* Indicateur de filtre actif */
.filter-container.active::before {
    content: "🔍";
    margin-right: 0.5rem;
}

/* Animation pour les changements de filtre */
.calendar-grid {
    transition: opacity 0.3s ease;
}

.calendar-content.loading .calendar-grid {
    opacity: 0.3;
}

/* Amélioration de l'accessibilité */
.tag-filter:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Styles pour les tooltips améliorés */
.day-tooltip {
    font-size: 12px !important;
    background: #333 !important;
    color: white !important;
    padding: 5px 10px !important;
    border-radius: 4px !important;
    position: absolute !important;
    z-index: 1000 !important;
    pointer-events: none !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}