:root {
    --main-color: #2a599b;
    --accent-color: #f39c12; 
    --widget-bg: #f4f7f6;
    --text-primary: #333;
    --text-light: #fff;
    --sidebar-width: 380px; 
    
    --header-bg: var(--main-color);
    --event-bg: var(--main-color);
    --event-text: var(--text-light);
    --btn-bg: var(--main-color);
    --btn-text: var(--text-light);
    --date-badge-bg: #fff;
    --date-badge-text: #333;
}

.calendar-events {
    font-family: "Montserrat", "Open Sans", sans-serif;
    background-color: transparent;
    color: var(--text-primary);
    position: relative;
    width: 100%;
    height: auto;
}

/* Scrollbar */
.calendar-events ::-webkit-scrollbar { width: 6px; }
.calendar-events ::-webkit-scrollbar-track { background: transparent; }
.calendar-events ::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.calendar-events ::-webkit-scrollbar-thumb:hover { background: var(--main-color); }

/* Loader */
.ce-loading-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.95); z-index: 100;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    border-radius: 20px; transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}
.ce-loading-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.ce-spinner {
    width: 50px; height: 50px; border: 5px solid #f3f3f3;
    border-top: 5px solid var(--main-color); border-radius: 50%;
    animation: spin 1s linear infinite; margin-bottom: 15px;
}
.ce-loading-text { font-size: 14px; color: #666; font-weight: 600; letter-spacing: 0.5px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Toolbar - FIXED POSITIONING & Z-INDEX */
.fc-toolbar-title {
    color: var(--text-light);
    font-size: 1.5rem !important; font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* UPDATED: Matches Sidebar Header Height/Align exactly */
.fc .fc-toolbar.fc-header-toolbar {
    position: absolute; 
    padding: 0 20px; 
    margin: 0;
    left: 0; 
    top: 0; /* Align to top edge */
    height: 75px; /* Exact match to sidebar header */
    display: flex;
    align-items: center; /* Perfect vertical centering */
    justify-content: space-between;
    z-index: 30; 
    pointer-events: auto; 
    width: auto;
    right: var(--sidebar-width);
}
.fc .fc-button-primary {
    background-color: var(--text-light); color: var(--main-color);
    border: none; border-radius: 50%; width: 36px; height: 36px; padding: 0;
    display: flex; align-items: center; justify-content: center; font-weight: bold;
    transition: all 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.fc .fc-button-primary:hover {
    background-color: var(--text-light); color: var(--accent-color);
    transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.fc .fc-button-primary:not(:disabled).fc-button-active {
    background-color: var(--accent-color); color: var(--text-light);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Layout */
.calendar-outer {
    display: flex; width: 100%; max-width: 1200px; margin: 0 auto;
    background-color: var(--text-light); border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.08); position: relative;
    padding-top: 80px; overflow: hidden; min-height: 650px; 
}
.calendar-outer-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 75px;
    background-color: var(--header-bg);
    background: linear-gradient(90deg, var(--header-bg) 0%, var(--main-color) 100%);
    z-index: 1;
}
.calendar-container { 
    flex: 1; 
    padding: 20px 40px 40px 40px; 
    background-color: var(--text-light); 
}

/* --- SIDEBAR (Desktop) --- */
.ce-sidebar {
    width: var(--sidebar-width); 
    background-color: var(--text-light);
    border-left: 1px solid #eee; 
    display: flex; 
    flex-direction: column;
    position: relative; 
    flex-shrink: 0;
    height: auto; 
    z-index: 20; 
}

/* Header */
.ce-panel-name {
    background-color: var(--header-bg);
    background: linear-gradient(90deg, var(--header-bg) 0%, var(--main-color) 100%);
    color: var(--text-light); padding: 0 15px; text-align: center;
    position: absolute; top: -80px; right: 0; width: 100%; height: 75px; 
    box-sizing: border-box; display: flex; align-items: center; justify-content: center; /* Centered text */
}
.event-panel-title { margin: 0; font-size: 18px; font-weight: 600; flex-grow: 0; text-align: center; }

/* FIX: Hide top arrows globally as requested */
.ce-panel-name .sidebar-nav-btn { display: none; }

/* Body */
.event-details-container {
    flex: 1; 
    overflow-y: auto; 
    padding: 25px; 
    padding-bottom: 10px;
    display: flex; 
    flex-direction: column;
    opacity: 1; 
    transition: opacity 0.2s ease-in-out;
}
.event-details-container.fading { opacity: 0.5; }

/* Footer */
.calendar-actions {
    background: #fff;
    padding: 15px 25px 20px 25px;
    border-top: 1px solid #eee;
    z-index: 10;
    display: flex; 
    gap: 10px;
    align-items: center;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.03); 
}

/* --- Content Styling --- */
.event-image-wrapper {
    width: 100%; height: auto; 
    background: #f9f9f9;
    border-radius: 8px; overflow: hidden; margin-bottom: 20px; 
    display: flex; justify-content: center; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.event-image-wrapper img { 
    width: auto; max-width: 100%; height: auto; max-height: 250px; 
    display: block; object-fit: contain; 
}

/* --- UNIFIED TIMELINE BADGE (Single & Multi) --- */
.detailedview-multi-date {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0; 
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 50px; /* Pill shape */
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    padding: 5px 20px;
    width: fit-content;
    align-self: center;
}

.dv-multi-item {
    display: flex; 
    flex-direction: column; 
    align-items: center;
    padding: 5px 10px;
}

.dv-multi-month {
    font-size: 0.75em; 
    font-weight: 700; 
    text-transform: uppercase; 
    color: #888;
    line-height: 1;
    margin-bottom: 2px;
}

.dv-multi-day {
    font-size: 1.4em; 
    font-weight: 800; 
    color: var(--date-badge-text);
    line-height: 1;
}

.dv-multi-separator { 
    font-size: 1.2em; 
    color: #ddd; 
    margin: 0 5px; 
}

.dv-time {
    font-size: 0.9em; color: #666; margin-bottom: 15px;
    font-weight: 600; text-align: center;
}

.detailedview-title {
    font-size: 1.1em; font-weight: 700; color: var(--text-primary);
    margin-bottom: 15px; text-align: center; line-height: 1.4;
}
.detailedview-desc {
    font-size: 0.95rem; color: #4a4a4a; line-height: 1.7;
    margin-bottom: 15px; text-align: left; word-break: break-word;
}

/* Buttons */
.ce-btn-nav-small {
    flex: 0 0 44px; height: 44px; border-radius: 50%; border: 1px solid #eee;
    background: var(--text-light); color: var(--main-color); display: flex;
    align-items: center; justify-content: center; cursor: pointer;
    transition: all 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.ce-btn-nav-small:hover {
    background-color: var(--main-color); color: var(--text-light);
    transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.ce-action-center-wrapper { flex: 1; position: relative; }
.btn-add-calendar {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 14px; background-color: var(--btn-bg); color: var(--btn-text);
    border: none; cursor: pointer; text-decoration: none; border-radius: 10px;
    font-weight: 600; font-family: inherit; font-size: 15px;
    transition: all 0.2s; box-sizing: border-box; box-shadow: 0 4px 6px rgba(42, 89, 155, 0.2);
}
.btn-add-calendar:hover {
    background-color: #1e4275; transform: translateY(-2px);
    box-shadow: 6px 12px rgba(42, 89, 155, 0.3);
}

.calendar-options {
    display: none; position: absolute; bottom: 100%; left: 0; width: 100%; z-index: 20;
    box-sizing: border-box; flex-direction: column; gap: 8px; margin-bottom: 12px; 
    background: var(--text-light); padding: 12px; border-radius: 12px;
    border: 1px solid #eee; box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    animation: slideUp 0.2s ease-out;
}
.calendar-options.show { display: flex; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.btn-cal-option {
    display: flex; align-items: center; gap: 12px; padding: 12px 15px;
    background: var(--text-light); color: var(--text-primary); text-decoration: none;
    border-radius: 8px; font-size: 14px; font-weight: 500; border: 1px solid #eee; transition: all 0.2s;
}
.btn-cal-option:hover {
    background: #f0f7ff; border-color: var(--main-color); color: var(--main-color);
}
.section-divider {
    height: 1px; background: linear-gradient(90deg, transparent, #ddd, transparent); margin: 20px 0;
}

/* Events (Desktop) */
.fc-daygrid-event {
    background-color: var(--event-bg);
    color: var(--event-text) !important;
    border: none; border-radius: 4px; padding: 3px 6px;
    font-size: 0.85em; cursor: pointer; transition: all 0.1s;
    margin-top: 2px; text-decoration: none !important;
}
.fc-daygrid-event-dot { border-color: var(--event-text) !important; }
.fc-daygrid-event:hover {
    background-color: #3b70b7; transform: scale(1.02); color: var(--event-text) !important;
}
.fc-daygrid-event.active-event-highlight {
    background-color: var(--accent-color) !important;
    border-left: 4px solid #d35400; box-shadow: 0 3px 8px rgba(0,0,0,0.2);
    font-weight: bold; z-index: 5;
}
.fc-daygrid-day.fc-day-today { background-color: #f0f7ff !important; }

/* Tooltips */
.tippy-box[data-theme~='light'] {
    background-color: var(--text-light); color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid #eee;
    font-family: "Montserrat", sans-serif; font-size: 0.9em; border-radius: 6px;
}
.empty-state { text-align: center; color: #888; margin-top: 60px; font-style: italic; }

/* --- MOBILE SPECIFIC STYLES --- */
#ce-mobile-event-list { display: none; }
.ce-modal-close { display: none; }
.ce-sidebar-handle {
    display: none;
    width: 40px; height: 5px;
    background-color: #e0e0e0;
    border-radius: 10px;
    margin: 10px auto;
}

@media screen and (max-width: 767px) {
    /* 1. Layout */
    .calendar-outer { 
        flex-direction: column; padding-top: 60px; 
        height: auto; min-height: auto; 
        background: transparent; box-shadow: none;
    }
    .calendar-container { 
        padding: 5px; 
        background: #fff; border-radius: 20px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.05);
        margin-bottom: 20px;
        min-height: auto;
    }
    
    /* 2. Grid styling: Hide events, Show Dots */
    /* FIXED: Position Absolute for Mobile Header */
    .fc .fc-toolbar.fc-header-toolbar { 
        width: 100%; 
        padding: 0 15px; 
        margin-bottom: 0 !important; 
        padding-top: 0 !important;
        right: auto; 
        left: 0;
        top: 0;
        height: 60px; /* Match mobile header bg */
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: absolute; /* Reverted to absolute for blue header placement */
    }
    .fc-toolbar-title { font-size: 1rem !important; }
    .fc .fc-button { padding: 2px 5px !important; height: auto !important; } 
    
    /* Compact Weekdays */
    .fc-col-header-cell-cushion { font-size: 0.8rem; }

    /* Compact Dates */
    .fc .fc-daygrid-body-natural .fc-daygrid-day-events { margin-bottom: 0 !important; }
    .fc .fc-daygrid-body-unbalanced .fc-daygrid-day-events { min-height: 1em !important; }

    /* Hide default FullCalendar Events on Mobile */
    .fc-daygrid-event { display: none !important; }
    .fc-daygrid-day-bottom { display: none !important; }
    
    /* Custom Dots Container */
    .ce-mobile-dots {
        display: flex; justify-content: center; gap: 3px;
        position: absolute; bottom: 4px; left: 0; right: 0;
        pointer-events: none; /* Let clicks pass to cell */
    }
    .ce-mobile-dot {
        width: 6px; height: 6px; border-radius: 50%;
        background-color: var(--accent-color);
    }
    
    /* 3. Mobile List */
    #ce-mobile-event-list {
        display: flex; flex-direction: column; gap: 12px;
        width: 100%; padding-bottom: 40px;
    }
    
    /* QA Fix: Clean Card Layout */
    .ce-mobile-card {
        background: #fff; border-radius: 12px; padding: 12px;
        display: flex; align-items: center; gap: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.05);
        cursor: pointer; transition: transform 0.1s; border: 1px solid #f0f0f0;
    }
    .ce-mobile-card:active { transform: scale(0.98); background: #fafafa; }
    
    /* QA Fix: Image container needs fixed size to prevent collapse */
    .ce-mobile-card-img-wrapper {
        width: 60px; height: 60px; flex-shrink: 0;
    }
    .ce-mobile-card-img {
        width: 100%; height: 100%; border-radius: 8px;
        background: #f0f0f0; object-fit: cover;
    }
    
    .ce-mobile-card-content {
        flex: 1; display: flex; flex-direction: column; gap: 4px; overflow: hidden;
    }
    .ce-mobile-card-title {
        font-weight: 700; font-size: 15px; color: var(--text-primary);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .ce-mobile-card-time {
        font-size: 13px; color: #666; display: flex; align-items: center; gap: 5px;
    }
    .ce-mobile-card-arrow { color: var(--main-color); font-size: 14px; }

    /* 4. Slide-Up Modal */
    .ce-sidebar {
        position: fixed; bottom: 0; left: 0; width: 100%; height: 85vh; 
        border-radius: 20px 20px 0 0; 
        box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
        transform: translateY(110%); transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
        z-index: 9999; border: none;
    }
    .ce-sidebar.is-open { transform: translateY(0); }
    
    .ce-sidebar-handle { display: block; }
    
    .ce-panel-name {
        border-radius: 20px 20px 0 0; position: relative; top: 0; margin-bottom: 0;
        background: transparent; height: auto; padding: 5px 15px 15px 15px;
    }
    .event-panel-title { color: var(--text-primary); text-align: left; padding-left: 10px; font-size: 1.4em; }
    
    .ce-modal-close { 
        display: flex; position: absolute; top: 15px; right: 15px;
        background: rgba(0,0,0,0.05); border: none; border-radius: 50%;
        width: 32px; height: 32px; align-items: center; justify-content: center;
        cursor: pointer; font-size: 16px; color: #666; z-index: 10001;
    }
}