/* Bootstrap-Styled Calendar */

#calendar {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    background: var(--bs-body-bg);
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
}

.fc {
    max-width: 100%;
    width: 100% !important;
    font-family: var(--bs-body-font-family);
}

.fc table {
    width: 100% !important;
    table-layout: fixed;
}

.fc .fc-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bs-light);
    border-radius: 0.5rem 0.5rem 0 0;
    border-bottom: 1px solid var(--bs-border-color);
}

.fc .fc-toolbar-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--bs-body-color);
}

.fc .fc-button {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

.fc .fc-button:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

.fc .fc-button:disabled {
    background-color: var(--bs-secondary);
    border-color: var(--bs-secondary);
    opacity: 0.65;
}

.fc-theme-standard td, .fc-theme-standard th {
    border: 1px solid var(--bs-border-color);
}

.fc .fc-col-header-cell {
    background-color: var(--bs-light);
    color: var(--bs-body-color);
    font-weight: 600;
    padding: 0.75rem 0.5rem;
    text-transform: uppercase;
    font-size: 0.875rem;
}

.fc .fc-daygrid-day {
    background-color: var(--bs-body-bg);
    transition: background-color 0.15s ease-in-out;
}

.fc .fc-daygrid-day:hover {
    background-color: var(--bs-light);
}

.fc .fc-daygrid-day-number {
    color: var(--bs-body-color);
    padding: 0.5rem;
    font-weight: 500;
}

.fc .fc-list-event-title,
.fc .fc-list-event-time,
.fc .fc-list-day-text,
.fc .fc-list-day-side-text {
    color: var(--bs-body-color);
}

.fc .fc-day-today {
    background-color: rgba(13, 110, 253, 0.15) !important;
}

.fc .fc-day-today .fc-daygrid-day-number {
    background-color: var(--bs-primary);
    color: #fff !important;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.fc .fc-event {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    color: #fff !important;
}

.fc .fc-event-title {
    color: #fff !important;
}

.fc .fc-daygrid-event-dot {
    border-color: #fff !important;
}

/* Dark Mode */
[data-bs-theme="dark"] #calendar {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .fc .fc-toolbar {
    background: var(--bs-dark);
}

[data-bs-theme="dark"] .fc .fc-toolbar-title {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-button {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

[data-bs-theme="dark"] .fc .fc-button:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

[data-bs-theme="dark"] .fc .fc-button-active {
    background-color: #0a58ca;
    border-color: #0a53be;
}

[data-bs-theme="dark"] .fc .fc-col-header-cell {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .fc .fc-daygrid-day {
    background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .fc .fc-daygrid-day-number,
[data-bs-theme="dark"] .fc a.fc-daygrid-day-number {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-day-today {
    background-color: rgba(13, 110, 253, 0.2) !important;
}

[data-bs-theme="dark"] .fc .fc-list-event-title,
[data-bs-theme="dark"] .fc .fc-list-event-time,
[data-bs-theme="dark"] .fc .fc-list-day-text,
[data-bs-theme="dark"] .fc .fc-list-day-side-text,
[data-bs-theme="dark"] .fc a.fc-list-event-title,
[data-bs-theme="dark"] .fc a.fc-list-day-text {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc-theme-standard td,
[data-bs-theme="dark"] .fc-theme-standard th {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .fc .fc-daygrid-day-top {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-timegrid-slot-label,
[data-bs-theme="dark"] .fc .fc-timegrid-axis {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-timegrid-slot-label-cushion,
[data-bs-theme="dark"] .fc .fc-timegrid-axis-cushion {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-list-day-cushion,
[data-bs-theme="dark"] .fc .fc-list-event-dot,
[data-bs-theme="dark"] .fc .fc-list-event-graphic {
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-list-table {
    background-color: var(--bs-dark) !important;
}

[data-bs-theme="dark"] .fc .fc-scrollgrid {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .fc .fc-timegrid-col {
    background-color: var(--bs-dark) !important;
}

[data-bs-theme="dark"] .fc .fc-timegrid-slot {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .fc .fc-timegrid-divider {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .fc .fc-toolbar {
        flex-direction: column;
        padding: 0.75rem;
    }
    
    .fc .fc-toolbar-title {
        font-size: 1.25rem;
    }
    
    .fc .fc-button {
        padding: 0.3rem 0.5rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 575px) {
    .fc .fc-toolbar-title {
        font-size: 1rem;
    }
    
    .fc .fc-button {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
    
    .fc .fc-daygrid-day-number {
        font-size: 0.75rem;
    }
    
    .fc .fc-col-header-cell {
        font-size: 0.7rem;
        padding: 0.5rem 0.25rem;
    }
}

/* Popover Styling */
.fc .fc-popover {
    background-color: #ffffff !important;
    border: 2px solid var(--bs-border-color) !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3) !important;
    opacity: 1 !important;
}

.fc .fc-popover-header {
    background-color: var(--bs-primary) !important;
    color: #fff !important;
    padding: 0.75rem !important;
    opacity: 1 !important;
}

.fc .fc-popover-title {
    color: #fff !important;
    font-weight: 600 !important;
}

.fc .fc-popover-body {
    background-color: #ffffff !important;
    color: #212529 !important;
    padding: 0.5rem !important;
    opacity: 1 !important;
}

.fc .fc-popover .fc-event-title {
    color: #fff !important;
}

.fc .fc-more-popover .fc-event {
    color: #fff !important;
    margin-bottom: 0.25rem !important;
}

[data-bs-theme="dark"] .fc .fc-popover {
    background-color: #212529 !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

[data-bs-theme="dark"] .fc .fc-popover-body {
    background-color: #212529 !important;
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .fc .fc-popover .fc-event-title {
    color: #fff !important;
}


/* Calendar Header Styling */
.fc .fc-col-header {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0b5ed7 100%);
}

.fc .fc-col-header-cell {
    background-color: transparent;
    color: #fff;
    font-weight: 700;
    padding: 1rem 0.5rem;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    border-color: rgba(255, 255, 255, 0.2);
}

.fc .fc-col-header-cell-cushion {
    color: #fff;
}

/* Dark Mode Header */
[data-bs-theme="dark"] .fc .fc-col-header {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

[data-bs-theme="dark"] .fc .fc-col-header-cell {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.15);
}

/* Responsive Header */
@media (max-width: 768px) {
    .fc .fc-col-header-cell {
        padding: 0.75rem 0.25rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 575px) {
    .fc .fc-col-header-cell {
        padding: 0.5rem 0.125rem;
        font-size: 0.7rem;
        letter-spacing: 0;
    }
}

/* Homepage mobile QA override: keep FullCalendar inside narrow screens. */
@media (max-width: 575.98px) {
    body[data-page="index"],
    body[data-page="index"] .homepage-shell {
        max-width: 100%;
        overflow-x: hidden;
    }

    body[data-page="index"] #calendar {
        box-shadow: 0 18px 46px rgba(13, 138, 255, 0.12);
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.72rem;
        width: 100%;
    }

    body[data-page="index"] #calendar .fc,
    body[data-page="index"] #calendar .fc-view-harness,
    body[data-page="index"] #calendar .fc-view-harness-active,
    body[data-page="index"] #calendar .fc-scrollgrid,
    body[data-page="index"] #calendar .fc-scrollgrid table,
    body[data-page="index"] #calendar table,
    body[data-page="index"] #calendar th,
    body[data-page="index"] #calendar td,
    body[data-page="index"] #calendar .fc-col-header,
    body[data-page="index"] #calendar .fc-col-header table,
    body[data-page="index"] #calendar .fc-daygrid-body,
    body[data-page="index"] #calendar .fc-daygrid-body table {
        max-width: 100% !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    body[data-page="index"] #calendar .fc-scrollgrid {
        table-layout: fixed !important;
    }

    body[data-page="index"] #calendar .fc-toolbar {
        align-items: center;
        background: transparent;
        border: 0;
        display: grid;
        gap: 0.45rem;
        grid-template-columns: minmax(0, 1fr) auto;
        margin: 0 0 0.6rem !important;
        padding: 0;
    }

    body[data-page="index"] #calendar .fc-toolbar-chunk {
        display: flex;
        justify-content: flex-end;
        margin: 0;
        min-width: 0;
        width: auto;
    }

    body[data-page="index"] #calendar .fc-toolbar-chunk:first-child {
        order: 2;
    }

    body[data-page="index"] #calendar .fc-toolbar-chunk:nth-child(2) {
        justify-content: flex-start;
        order: 1;
    }

    body[data-page="index"] #calendar .fc-toolbar-chunk:last-child {
        display: none;
    }

    body[data-page="index"] #calendar .fc-toolbar-title {
        color: #071b30;
        font-size: 0.92rem;
        line-height: 1.1;
        overflow-wrap: anywhere;
        text-align: left;
    }

    body[data-page="index"] #calendar .fc-button-group {
        border-radius: 999px;
        padding: 0.16rem;
    }

    body[data-page="index"] #calendar .fc-button {
        border-radius: 999px;
        font-size: 0.66rem;
        min-height: 34px;
        min-width: 34px;
        padding: 0.22rem 0.4rem;
    }

    body[data-page="index"] #calendar .fc-col-header-cell {
        font-size: 0.62rem;
        padding: 0.36rem 0;
    }

    body[data-page="index"] #calendar .fc-col-header-cell-cushion {
        display: block;
        padding: 0;
    }

    body[data-page="index"] #calendar .fc-daygrid-day-frame {
        min-height: 32px;
    }

    body[data-page="index"] #calendar .fc-daygrid-day-number {
        font-size: 0.66rem;
        padding: 0.16rem;
    }

    body[data-page="index"] #calendar .fc-day-today .fc-daygrid-day-number {
        height: 1.55rem;
        width: 1.55rem;
    }
}
