/* Mobil first */
#calendar {
    padding: 1rem;
    margin: 0.5rem;
    min-height: 25rem;
}

/* TOOLBAR MOBILE — Month/Week/List buttons */
@media (max-width: 576px) {
    .fc-toolbar {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: center !important;
    }

    .fc-toolbar-chunk {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
    }

    .fc-button {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    .fc-toolbar-title {
        font-size: 0.95rem !important;
        text-align: center !important;
    }

    /* Event in the box — prevents overflow */
    .fc-event {
        padding: 2px 4px !important;
        margin: 1px 2px !important;
        font-size: 0.65rem !important;
        overflow: hidden !important;
    }

    .fc-event-title {
        font-size: 0.65rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Hide the image in mobile events */
    .fc-event-image {
        display: none !important;
    }

    /* Reduces the height of the squares */
    .fc-daygrid-day {
        min-height: 2.5rem !important;
    }

    .fc-daygrid-day-number {
        font-size: 0.7rem !important;
        padding: 0.2rem !important;
    }

    .fc-col-header-cell {
        font-size: 0.65rem !important;
        padding: 0.3rem 0 !important;
    }
}

@media (min-width: 576px) {
    .calendar-header {
        padding: 1rem;
    }

    .calendar-header h2 {
        font-size: 1.1rem;
    }

    .calendar-header p {
        font-size: 0.8rem;
    }

    #calendar {
        font-size: 0.85rem;
    }

    .fc-toolbar-title {
        font-size: 1rem !important;
    }

    .fc-col-header-cell {
        font-size: 0.7rem;
        padding: 0.5rem 0;
    }

    /* Default list view on very small screen */
    .fc-dayGridMonth-button {
        display: none;
    }
}

/* RESPONSIVE */
@media (min-width: 768px) {
    #calendar {
        min-height: 25rem;
        padding: 1rem;
        margin: 0.5rem;
    }

    .fc-toolbar {
        flex-direction: column;
        gap: 1rem;
    }

    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .fc-toolbar-title {
        font-size: 1.2rem !important;
        text-align: center;
        margin: 0.5rem 0;
    }

    .fc-button {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.85rem !important;
    }

    .fc-event-title {
        font-size: 0.75rem;
    }

    .fc-daygrid-day-number {
        font-size: 0.8rem;
    }

    /* Hide images on mobile */
    .fc-event-image {
        display: none;
    }
}

/* Main container */
#calendar-section {
    width: 100%;
    max-width: 1200px;
    background: linear-gradient(135deg, #1c0a76 0%, #ce9f41 100%);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    margin-bottom: 2rem;
    overflow-x: auto; /*Add a scrolling effect to the calendar*/
    margin-left: auto;
    margin-right: auto;
}

.calendar-header {
    padding: 1.5rem;
    color: white;
}

.calendar-header h2 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* Calendar area */
#calendar {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-height: 30rem;
    display: block;
}

/* TOOLBAR */
.fc-toolbar {
    padding: 1rem 0;
    margin-bottom: 1.5rem !important;
    border-bottom: 2px solid #f3f4f6;
}

.fc-toolbar-title {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    color: #1f2937;
}

/* Buttons */
.fc-button {
    background: white !important;
    border: 2px solid #e5e7eb !important;
    color: #374151 !important;
    font-weight: 600 !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0.5rem !important;
    transition: all 0.2s ease !important;
    text-transform: capitalize !important;
}

.fc-button:hover {
    background: #f9fafb !important;
    border-color: #667eea !important;
    color: #667eea !important;
    transform: translateY(-2px);
}

.fc-button-active {
    background: linear-gradient(135deg, #ce9f41 0%, #1c0a76 100%) !important;
    border-color: #667eea !important;
    color: white !important;
}

.fc-button-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* MONTH VIEW */
.fc-daygrid-day {
    transition: background-color 0.2s ease;
}

.fc-daygrid-day:hover {
    background-color: #f9fafb;
}

.fc-daygrid-day-number {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    padding: 0.5rem;
}

.fc-col-header-cell a {
    background: #f9fafb;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: #4b5563;
    padding: 0.75rem 0;
    border: none !important;
}

.fc-col-header-cell.fc-day a {
    color: #1c0a76 !important;
    text-decoration: none !important;
    font-weight: bold !important;
}

/* Today */
.fc-day-today {
    background-color: #fef3c7 !important;
}

.fc-day-today .fc-daygrid-day-number {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.25rem;
}

/* ÉVENTS */
.fc-event {
    border: none !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    margin: 2px 4px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fc-event:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.fc-event-main {
    padding: 0 !important;
}

.fc-event-title {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: normal !important;
    line-height: 1.3;
}

.fc-event-time {
    font-weight: 500;
    font-size: 0.75rem;
    margin-right: 4px;
}

/* Image in the event */
.fc-event-image {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 4px;
}

.fc-event-extra {
    font-size: 0.7rem;
    margin-top: 2px;
    opacity: 0.9;
}

/* Past events */
.event-past {
    opacity: 0.6;
    filter: grayscale(30%);
}

/* Categories */
.event-alsh {
    border-left: 4px solid #3b82f6 !important;
}

.event-collecte {
    border-left: 4px solid #10b981 !important;
}

.event-ape {
    border-left: 4px solid #f59e0b !important;
}

.event-autre {
    border-left: 4px solid #6366f1 !important;
}

/* LIST VIEW */
.fc-list-event {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.fc-list-event:hover {
    background-color: #f9fafb !important;
}

.fc-list-event-dot {
    width: 12px !important;
    height: 12px !important;
    border-radius: 50%;
}

.fc-list-event-title {
    font-weight: 600;
}

.fc-list-day-cushion {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
}

/* POPOVER */
.fc-popover {
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    border: none !important;
}

.fc-popover-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    font-weight: 600 !important;
    border-radius: 12px 12px 0 0 !important;
}

.event-img {
    width: 100%;
    height: 100%;
}

/* LOADING STATE */
#calendar.loading {
    opacity: 0.5;
    pointer-events: none;
}

#calendar.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* DARK MODE */
@media (prefers-color-scheme: dark) {
    #calendar {
        background: #1f2937;
        color: #f9fafb;
    }

    .fc-toolbar-title,
    .fc-daygrid-day-number {
        color: #f9fafb;
    }

    .fc-button {
        background: #374151 !important;
        border-color: #4b5563 !important;
        color: #f9fafb !important;
    }

    .fc-col-header-cell {
        background: #374151;
        color: #d1d5db;
    }

    .fc-daygrid-day:hover {
        background-color: #374151;
    }
}
