/* Activities Calendar Section Styles */
.activities-calendar-section {
    padding: 80px 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-top: 1px solid #e9ecef;
}

.calendar-header {
    text-align: center;
    margin-bottom: 50px;
}
/* .calendar-header .section-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 15px;
    position: relative;
} */

/* .calendar-header .section-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--primary-red, #C41E32);
    margin: 15px auto 0;
    border-radius: 2px;
} */

.calendar-description {
    font-size: 1.1rem;
    color: #7f8c8d;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.calendar-wrapper {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 1200px;
    margin: 0 auto;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.calendar-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

/* FullCalendar Custom Styles */
#activities-calendar {
    font-family: 'Inter', sans-serif;
    direction: ltr; /* Default LTR */
}

/* RTL Support for Arabic */
[dir="rtl"] #activities-calendar {
    font-family: 'Cairo', sans-serif;
    direction: rtl;
}

/* RTL Mobile specific fixes */
[dir="rtl"] .fc-event-main-frame {
    text-align: right !important;
}

[dir="rtl"] .fc-event-time {
    margin-left: 2px !important;
    margin-right: 0 !important;
}

[dir="rtl"] .fc-event-title {
    margin-right: 2px !important;
    margin-left: 0 !important;
}

.fc {
    font-size: 14px;
}

.fc-toolbar {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f8f9fa;
}

.fc-toolbar-title {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #2c3e50 !important;
    text-transform: capitalize;
}

.fc-button-group {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fc-button {
    background: var(--primary-red, #C41E32) !important;
    border: none !important;
    color: white !important;
    font-weight: 600 !important;
    padding: 12px 20px !important;
    border-radius: 0 !important;
    transition: all 0.3s ease !important;
}

.fc-button i {
    font-size: 14px !important;
    color: white !important;
    display: inline-block !important;
    visibility: visible !important;
    margin-right: 5px !important;
}

.fc-button:hover {
    background: rgba(196, 30, 50, 0.9) !important;
    transform: translateY(-2px);
}

.fc-button:focus {
    box-shadow: 0 0 0 3px rgba(196, 30, 50, 0.3) !important;
}

.fc-button-active {
    background: rgba(196, 30, 50, 0.9) !important;
}

.fc-prev-button,
.fc-next-button {
    background: var(--primary-red, #C41E32) !important;
    border-radius: 50% !important;
    width: 35px !important;
    height: 35px !important;
    padding: 0 !important;
    margin: 0 10px !important;
}

.fc-prev-button i,
.fc-next-button i {
    font-size: 14px !important;
    color: white !important;
    display: inline-block !important;
    visibility: visible !important;
}

.fc-prev-button:hover,
.fc-next-button:hover {
    background: rgba(196, 30, 50, 0.9) !important;
    transform: scale(1.1);
}

/* Calendar Grid Styles */
.fc-daygrid-day {
    border: 1px solid #e9ecef !important;
    transition: all 0.3s ease;
}

.fc-daygrid-day:hover {
    background: #f8f9fa !important;
}

.fc-daygrid-day-number {
    font-weight: 600 !important;
    color: #2c3e50 !important;
    padding: 8px !important;
}

.fc-day-today {
    background: linear-gradient(135deg, rgba(196, 30, 50, 0.1) 0%, rgba(196, 30, 50, 0.05) 100%) !important;
}

.fc-day-today .fc-daygrid-day-number {
    background: var(--primary-red, #C41E32) !important;
    color: white !important;
    border-radius: 50%;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 4px !important;
}

/* Selected day styling */
.fc-day-selected {
    background: var(--primary-red, #C41E32) !important;
    border-radius: 8px !important;
}

.fc-day-selected .fc-daygrid-day-number {
    background: var(--primary-red, #C41E32) !important;
    color: white !important;
    border-radius: 50%;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 4px !important;
    font-weight: 700 !important;
}

/* Activity count styling for selected days */
.fc-day-selected .activity-count {
    color: white !important;
    font-weight: 700 !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5) !important;
}

.fc-day-selected .fc-event {
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--primary-red, #C41E32) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

.fc-day-selected .fc-event .fc-event-time {
    color: var(--primary-red, #C41E32) !important;
    font-weight: 700 !important;
}

.fc-day-selected .fc-event .fc-event-title {
    color: var(--primary-red, #C41E32) !important;
    font-weight: 600 !important;
}

/* Event Styles */
.fc-event {
    border: none !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    min-height: 20px !important;
}

.fc-event:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
}

.fc-event-title {
    font-weight: 600 !important;
}

/* Time display in events - now on separate line */
.fc-event .fc-event-time {
    font-weight: 700 !important;
    color: #ffffff !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    margin-bottom: 2px !important;
    display: block !important;
}

[dir="rtl"] .fc-event .fc-event-time {
    text-align: right !important;
}

[dir="ltr"] .fc-event .fc-event-time {
    text-align: left !important;
}

/* Event content styling - updated for vertical layout */
.fc-event-main-frame {
    display: block !important;
    padding: 2px 4px !important;
}

.fc-event-title-container {
    width: 100% !important;
    overflow: hidden !important;
}

.fc-event-title {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
    margin-top: 1px !important;
    display: block !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .activities-calendar-section {
        padding: 40px 0;
    }
    
    /* .calendar-header .section-title {
        font-size: 1.8rem;
    } */
    
    .calendar-wrapper {
        padding: 15px;
        margin: 0 10px;
        border-radius: 12px;
    }
    
    .fc-toolbar {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 20px;
        align-items: center;
        justify-content: center;
    }
    
    /* Specific fix for fc-header-toolbar fc-toolbar fc-toolbar-ltr on mobile */
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        margin-bottom: 20px !important;
        padding: 10px !important;
        background: rgba(248, 249, 250, 0.8) !important;
        border-radius: 8px !important;
        border: 1px solid #e9ecef !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Toolbar chunks within fc-header-toolbar fc-toolbar fc-toolbar-ltr */
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-toolbar-chunk {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        flex: 0 0 auto !important;
    }
    
    /* First line - Month title only */
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-toolbar-title {
        width: 100% !important;
        text-align: center !important;
        font-size: 1.1rem !important;
        margin: 0 !important;
        font-weight: 700 !important;
        color: #2c3e50 !important;
        white-space: nowrap !important;
        order: 1 !important;
    }
    
    /* Second line - All buttons */
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-toolbar-chunk:first-child {
        order: 2 !important;
    }
    
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-toolbar-chunk:last-child {
        order: 2 !important;
    }
    
    /* Buttons within fc-header-toolbar fc-toolbar fc-toolbar-ltr */
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-button {
        padding: 8px 12px !important;
        font-size: 11px !important;
        margin: 2px !important;
        align-items: center !important;
        gap: 4px !important;
        box-shadow: 0 2px 6px rgba(196, 30, 50, 0.2) !important;
        transition: all 0.3s ease !important;
        flex: 0 0 auto !important;
        min-width: 60px !important;
        border-radius: 6px !important;
    }
    
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-button:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 10px rgba(196, 30, 50, 0.3) !important;
    }
    
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-prev-button,
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-next-button {
        width: 24px !important;
        height: 40px !important;
        margin: 0 2px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 8px rgba(196, 30, 50, 0.3) !important;
        transition: all 0.3s ease !important;
    }
    
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-prev-button:hover,
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr .fc-next-button:hover {
        transform: scale(1.1) !important;
        box-shadow: 0 4px 12px rgba(196, 30, 50, 0.4) !important;
    }
    
    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: nowrap;
        gap: 6px;
        flex: 0 0 auto;
    }
    
    /* First line - Month title only */
    .fc-toolbar-title {
        font-size: 1.1rem !important;
        text-align: center;
        margin: 0;
        font-weight: 700 !important;
        color: #2c3e50 !important;
        width: 100%;
        order: 1;
    }
    
    /* Second line - All buttons */
    .fc-toolbar-chunk:first-child {
        order: 2;
        gap: 8px;
    }
    
    .fc-toolbar-chunk:last-child {
        order: 2;
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    .fc-button {
        padding: 6px 8px !important;
        font-size: 10px !important;
        margin: 1px !important;
        align-items: center !important;
        gap: 3px !important;
        box-shadow: 0 2px 6px rgba(196, 30, 50, 0.2) !important;
        transition: all 0.3s ease !important;
        flex: 0 0 auto !important;
        min-width: 45px !important;
        max-width: 60px !important;
    }
    
    .fc-button:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 10px rgba(196, 30, 50, 0.3) !important;
    }
    
    .fc-button i {
        font-size: 10px !important;
        color: white !important;
    }
    
    /* Fix day headers overflow */
    .fc-col-header-cell {
        padding: 8px 2px !important;
        font-size: 11px !important;
        text-align: center !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
    }
    
    .fc-daygrid-day-number {
        font-size: 11px !important;
        padding: 4px !important;
        text-align: center !important;
    }
    
    /* Fix event overflow issues */
    .fc-daygrid-day {
        min-height: 60px !important;
        position: relative !important;
        overflow: hidden !important;
    }
    
    .fc-daygrid-day-events {
        margin: 2px !important;
        max-height: 50px !important;
        overflow: hidden !important;
    }
    
    .fc-event {
        font-size: 9px !important;
        padding: 1px 3px !important;
        margin: 1px 0 !important;
        min-height: 16px !important;
        max-height: 16px !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        border-radius: 3px !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    }
    
    .fc-event .fc-event-time {
        font-size: 8px !important;
        font-weight: 700 !important;
        line-height: 1 !important;
        margin: 0 !important;
        display: inline !important;
    }
    
    .fc-event-title {
        font-size: 8px !important;
        line-height: 1 !important;
        margin: 0 !important;
        display: inline !important;
        margin-left: 2px !important;
    }
    
    /* Event content container fixes */
    .fc-event-main-frame {
        padding: 1px 2px !important;
        overflow: hidden !important;
        white-space: nowrap !important;
    }
    
    .fc-event-title-container {
        overflow: hidden !important;
        white-space: nowrap !important;
    }
    
    /* Navigation buttons */
    .fc-prev-button,
    .fc-next-button {
        width: 24px !important;
        height: 24px !important;
        margin: 0 2px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 8px rgba(196, 30, 50, 0.3) !important;
        transition: all 0.3s ease !important;
    }
    
    .fc-prev-button:hover,
    .fc-next-button:hover {
        transform: scale(1.1) !important;
        box-shadow: 0 4px 12px rgba(196, 30, 50, 0.4) !important;
    }
    
    .fc-prev-button i,
    .fc-next-button i {
        font-size: 12px !important;
        color: white !important;
    }
    
    /* Today button mobile styling */
    .fc-today-button {
        padding: 6px 8px !important;
        font-size: 10px !important;
        margin: 0 2px !important;
        box-shadow: 0 2px 6px rgba(196, 30, 50, 0.3) !important;
        transition: all 0.3s ease !important;
        display: flex !important;
        align-items: center !important;
        gap: 3px !important;
        flex: 0 0 auto !important;
        min-width: 45px !important;
        max-width: 60px !important;
    }
    
    .fc-today-button:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 12px rgba(196, 30, 50, 0.4) !important;
    }
    
    .fc-today-button i {
        font-size: 12px !important;
        color: white !important;
    }
    
    /* Mobile selected day styling */
    .fc-day-selected {
        background: var(--primary-red, #C41E32) !important;
        border-radius: 6px !important;
    }
    
    .fc-day-selected .fc-daygrid-day-number {
        background: var(--primary-red, #C41E32) !important;
        color: white !important;
        border-radius: 50%;
        width: 24px !important;
        height: 24px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 2px !important;
        font-weight: 700 !important;
        font-size: 10px !important;
    }
    
    .fc-day-selected .activity-count {
        color: white !important;
        font-weight: 700 !important;
        font-size: 8px !important;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5) !important;
    }
}

@media (max-width: 480px) {
    .calendar-wrapper {
        padding: 10px;
        margin: 0 5px;
    }
    
    .fc-toolbar-title {
        font-size: 0.9rem !important;
        margin: 0 3px;
    }
    
    /* Enhanced mobile styling for fc-header-toolbar fc-toolbar fc-toolbar-ltr on small screens */
    .fc-header-toolbar.fc-toolbar.fc-toolbar-ltr {
        padding: 6px !important;
        gap: 6px !important;
        margin-bottom: 15px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        border-radius: 6px !important;
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15) !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .fc-button-group {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        max-width: 100%;
    }
    
    /* Ensure buttons don't overflow on very small screens */
    .fc-toolbar-chunk {
        max-width: 100%;
        overflow: hidden;
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 4px;
        flex-wrap: nowrap;
    }
    
    .fc-button {
        margin: 1px !important;
        flex: 0 0 auto !important;
        min-width: 40px !important;
        max-width: 50px !important;
        padding: 5px 6px !important;
        font-size: 9px !important;
    }
    
    /* Extra small mobile fixes */
    .fc-col-header-cell {
        padding: 6px 1px !important;
        font-size: 10px !important;
    }
    
    .fc-daygrid-day {
        min-height: 50px !important;
    }
    
    .fc-daygrid-day-events {
        max-height: 40px !important;
    }
    
    .fc-event {
        font-size: 8px !important;
        padding: 1px 2px !important;
        min-height: 14px !important;
        max-height: 14px !important;
    }
    
    .fc-event .fc-event-time {
        font-size: 7px !important;
    }
    
    .fc-event-title {
        font-size: 7px !important;
    }
    
    .fc-daygrid-day-number {
        font-size: 10px !important;
        padding: 3px !important;
    }
    
    .fc-prev-button,
    .fc-next-button {
        width: 20px !important;
        height: 20px !important;
        margin: 0 2px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 6px rgba(196, 30, 50, 0.3) !important;
    }
    
    .fc-prev-button:hover,
    .fc-next-button:hover {
        transform: scale(1.05) !important;
    }
    
    .fc-prev-button i,
    .fc-next-button i {
        font-size: 10px !important;
        color: white !important;
    }
    
    /* Today button for extra small screens */
    .fc-today-button {
        padding: 5px 6px !important;
        font-size: 9px !important;
        margin: 0 1px !important;
        gap: 2px !important;
        min-width: 40px !important;
        max-width: 50px !important;
    }
    
    .fc-today-button i {
        font-size: 10px !important;
    }
    
    /* Extra small mobile selected day styling */
    .fc-day-selected {
        background: var(--primary-red, #C41E32) !important;
        border-radius: 4px !important;
    }
    
    .fc-day-selected .fc-daygrid-day-number {
        background: var(--primary-red, #C41E32) !important;
        color: white !important;
        border-radius: 50%;
        width: 20px !important;
        height: 20px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 1px !important;
        font-weight: 700 !important;
        font-size: 9px !important;
    }
    
    .fc-day-selected .activity-count {
        color: white !important;
        font-weight: 700 !important;
        font-size: 7px !important;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5) !important;
    }
}

/* Loading Animation */
.calendar-loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 400px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    margin: 20px 0;
}

.calendar-loading p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.calendar-loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-red, #C41E32);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .activities-calendar-section {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .calendar-wrapper {
        background: #34495e;
        border-color: #4a5f7a;
    }
    
    .fc-toolbar-title {
        color: #ecf0f1 !important;
    }
    
    .fc-daygrid-day {
        border-color: #4a5f7a !important;
    }
    
    .fc-daygrid-day-number {
        color: #ecf0f1 !important;
    }
}

.calendar-day.selected .activity-count {
    color: #fff !important;
}