/*
 * Shared FullCalendar styling for the public (home) and staff (bookings)
 * calendars. Consumed together with static/js/shared/calendar_core.js.
 *
 * Colour model
 * ------------
 * Status is always encoded the same way: solid fill = confirmed, pale fill
 * with dashed border = tentative (awaiting payment).
 *
 * Hue comes from the building (.evt-b0 .. .evt-b3) so week/day views convey
 * location at a glance without a 40-room legend. The plain status classes
 * (.evt-terpakai / .evt-tentatif) act as the fallback when no building class
 * is present (e.g. colorBy: 'status').
 */

/* ------------------------------------------------------------------ */
/* Legend swatches                                                     */
/* ------------------------------------------------------------------ */

.swatch-terpakai {
    background-color: oklch(var(--p));
    border: 1px solid oklch(var(--p));
}

.swatch-tentatif {
    background-color: oklch(var(--wa) / 0.25);
    border: 1px dashed oklch(var(--wa));
}

/* Generic "confirmed" swatch for the staff legend (hue comes from building) */
.swatch-solid {
    background-color: oklch(var(--bc) / 0.55);
    border: 1px solid oklch(var(--bc) / 0.55);
}

.swatch-b0 { background-color: oklch(var(--p)); }
.swatch-b1 { background-color: oklch(var(--s)); }
.swatch-b2 { background-color: oklch(var(--a)); }
.swatch-b3 { background-color: oklch(var(--n)); }

/* ------------------------------------------------------------------ */
/* Status colours (public: status only)                                */
/* ------------------------------------------------------------------ */

.fc .fc-h-event.evt-terpakai,
.fc .fc-v-event.evt-terpakai {
    background-color: oklch(var(--p));
    border-color: oklch(var(--p));
}

.fc .fc-h-event.evt-terpakai .fc-event-main,
.fc .fc-v-event.evt-terpakai .fc-event-main {
    color: oklch(var(--pc));
}

.fc .fc-h-event.evt-tentatif,
.fc .fc-v-event.evt-tentatif {
    background-color: oklch(var(--wa) / 0.25);
    border: 1px dashed oklch(var(--wa));
}

.fc .fc-h-event.evt-tentatif .fc-event-main,
.fc .fc-v-event.evt-tentatif .fc-event-main {
    color: oklch(var(--bc));
}

.fc .fc-list-event.evt-terpakai .fc-list-event-dot {
    border-color: oklch(var(--p));
}

.fc .fc-list-event.evt-tentatif .fc-list-event-dot {
    border-color: oklch(var(--wa));
}

/* ------------------------------------------------------------------ */
/* Building colours (staff): override the status colour with the       */
/* building hue while keeping the solid/dashed status treatment.        */
/* ------------------------------------------------------------------ */

.fc .fc-h-event.evt-b0.evt-terpakai, .fc .fc-v-event.evt-b0.evt-terpakai { background-color: oklch(var(--p)); border-color: oklch(var(--p)); }
.fc .fc-h-event.evt-b1.evt-terpakai, .fc .fc-v-event.evt-b1.evt-terpakai { background-color: oklch(var(--s)); border-color: oklch(var(--s)); }
.fc .fc-h-event.evt-b2.evt-terpakai, .fc .fc-v-event.evt-b2.evt-terpakai { background-color: oklch(var(--a)); border-color: oklch(var(--a)); }
.fc .fc-h-event.evt-b3.evt-terpakai, .fc .fc-v-event.evt-b3.evt-terpakai { background-color: oklch(var(--n)); border-color: oklch(var(--n)); }

.fc .fc-h-event.evt-b0.evt-terpakai .fc-event-main, .fc .fc-v-event.evt-b0.evt-terpakai .fc-event-main { color: oklch(var(--pc)); }
.fc .fc-h-event.evt-b1.evt-terpakai .fc-event-main, .fc .fc-v-event.evt-b1.evt-terpakai .fc-event-main { color: oklch(var(--sc)); }
.fc .fc-h-event.evt-b2.evt-terpakai .fc-event-main, .fc .fc-v-event.evt-b2.evt-terpakai .fc-event-main { color: oklch(var(--ac)); }
.fc .fc-h-event.evt-b3.evt-terpakai .fc-event-main, .fc .fc-v-event.evt-b3.evt-terpakai .fc-event-main { color: oklch(var(--nc)); }

.fc .fc-h-event.evt-b0.evt-tentatif, .fc .fc-v-event.evt-b0.evt-tentatif { background-color: oklch(var(--p) / 0.18); border: 1px dashed oklch(var(--p)); }
.fc .fc-h-event.evt-b1.evt-tentatif, .fc .fc-v-event.evt-b1.evt-tentatif { background-color: oklch(var(--s) / 0.18); border: 1px dashed oklch(var(--s)); }
.fc .fc-h-event.evt-b2.evt-tentatif, .fc .fc-v-event.evt-b2.evt-tentatif { background-color: oklch(var(--a) / 0.18); border: 1px dashed oklch(var(--a)); }
.fc .fc-h-event.evt-b3.evt-tentatif, .fc .fc-v-event.evt-b3.evt-tentatif { background-color: oklch(var(--n) / 0.18); border: 1px dashed oklch(var(--n)); }

.fc .fc-list-event.evt-b0 .fc-list-event-dot { border-color: oklch(var(--p)); }
.fc .fc-list-event.evt-b1 .fc-list-event-dot { border-color: oklch(var(--s)); }
.fc .fc-list-event.evt-b2 .fc-list-event-dot { border-color: oklch(var(--a)); }
.fc .fc-list-event.evt-b3 .fc-list-event-dot { border-color: oklch(var(--n)); }

.fc .fc-daygrid-event,
.fc .fc-timegrid-event,
.fc .fc-list-event {
    cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* FullCalendar root variables                                        */
/* ------------------------------------------------------------------ */

.fc {
    --fc-today-bg-color: color-mix(in oklab, oklch(var(--p)) 8%, oklch(var(--b1)));
    --fc-now-indicator-color: oklch(var(--p));
    --fc-border-color: oklch(var(--b3));
}

/* ------------------------------------------------------------------ */
/* Date cell & number hierarchy: past, today, future, and other-month */
/* ------------------------------------------------------------------ */

/* Past date cell & number */
.fc .fc-daygrid-day.fc-day-past {
    background-color: oklch(var(--b2) / 0.4);
}

.fc .fc-daygrid-day.fc-day-past .fc-daygrid-day-number {
    color: oklch(var(--bc) / 0.45);
    font-weight: 500;
}

/* Today cell & signature circular badge */
.fc .fc-daygrid-day.fc-day-today {
    background-color: color-mix(in oklab, oklch(var(--p)) 8%, oklch(var(--b1))) !important;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-frame {
    box-shadow: inset 0 0 0 1.5px oklch(var(--p) / 0.45);
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
    background-color: oklch(var(--p));
    color: oklch(var(--pc)) !important;
    font-weight: 700;
    font-size: 0.825rem;
    min-width: 1.65rem;
    height: 1.65rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0.2rem 0.25rem 0.1rem;
    box-shadow: 0 1px 3px oklch(var(--p) / 0.35);
    text-decoration: none;
}

/* Future date cell & number */
.fc .fc-daygrid-day.fc-day-future {
    background-color: oklch(var(--b1));
}

.fc .fc-daygrid-day.fc-day-future .fc-daygrid-day-number {
    color: oklch(var(--bc) / 0.85);
    font-weight: 600;
}

/* Adjacent/other-month date cells */
.fc .fc-daygrid-day.fc-day-other {
    background-color: oklch(var(--b2) / 0.25);
}

.fc .fc-daygrid-day.fc-day-other .fc-daygrid-day-number {
    color: oklch(var(--bc) / 0.28);
    font-weight: 400;
}

/* ------------------------------------------------------------------ */
/* Month view: one aggregated summary card per day                     */
/* ------------------------------------------------------------------ */

.fc .fc-daygrid-event.evt-summary {
    border-radius: 0.5rem;
    padding: 0.35rem 0.5rem;
    margin: 0.15rem 0.25rem 0.25rem;
    color: oklch(var(--bc));
    transition: all 0.15s ease-in-out;
}

.fc .fc-daygrid-event.evt-summary .fc-event-main {
    color: inherit;
}

.evt-summary .sum-main {
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
}

.evt-summary .sum-num {
    font-size: 1.25rem;
    font-weight: 700;
    transition: color 0.15s ease;
}

.evt-summary .sum-label,
.evt-summary .sum-label-short {
    font-size: 0.7rem;
    opacity: 0.75;
}

/* Narrow cells (< ~1100px wide grid): use the short label */
.evt-summary .sum-label-short {
    display: none;
}

@media (max-width: 1100px) {
    .evt-summary .sum-label {
        display: none;
    }

    .evt-summary .sum-label-short {
        display: inline;
    }
}

.evt-summary .sum-free {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.1rem;
}

.evt-summary .sum-bar {
    height: 0.25rem;
    margin: 0.3rem 0 0.25rem;
    border-radius: 999px;
    overflow: hidden;
    transition: background-color 0.15s ease;
}

.evt-summary .sum-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: background-color 0.15s ease;
}

.evt-summary .sum-meta {
    font-size: 0.68rem;
    white-space: normal;
    line-height: 1.25;
}

.evt-summary .sum-tentative {
    font-size: 0.68rem;
    margin-top: 0.15rem;
    font-weight: 600;
}

/* Today pill on summary card */
.evt-summary .sum-today-pill {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    background-color: oklch(var(--p));
    color: oklch(var(--pc));
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

/* ------------------------------------------------------------------ */
/* Summary cards: Past date treatment                                 */
/* ------------------------------------------------------------------ */

.fc .fc-daygrid-day.fc-day-past .fc-daygrid-event.evt-summary,
.fc .fc-daygrid-event.evt-summary.sum-past {
    background-color: oklch(var(--b2) / 0.55);
    border: 1px solid oklch(var(--b3) / 0.7);
    color: oklch(var(--bc) / 0.6);
    opacity: 0.75;
    box-shadow: none;
}

.fc-day-past .evt-summary .sum-main .sum-num,
.evt-summary.sum-past .sum-main .sum-num {
    /* Past occupancy is history, not an urgent alert */
    color: oklch(var(--bc) / 0.55);
}

.fc-day-past .evt-summary .sum-label,
.fc-day-past .evt-summary .sum-label-short,
.evt-summary.sum-past .sum-label,
.evt-summary.sum-past .sum-label-short {
    color: oklch(var(--bc) / 0.5);
}

.fc-day-past .evt-summary .sum-free,
.evt-summary.sum-past .sum-free {
    color: oklch(var(--bc) / 0.55);
    font-weight: 500;
}

.fc-day-past .evt-summary .sum-bar,
.evt-summary.sum-past .sum-bar {
    background-color: oklch(var(--bc) / 0.08);
}

.fc-day-past .evt-summary .sum-bar-fill,
.evt-summary.sum-past .sum-bar-fill {
    background-color: oklch(var(--bc) / 0.28);
}

.fc-day-past .evt-summary .sum-meta,
.evt-summary.sum-past .sum-meta {
    color: oklch(var(--bc) / 0.45);
}

.fc-day-past .evt-summary .sum-tentative,
.evt-summary.sum-past .sum-tentative {
    color: oklch(var(--wa) / 0.65);
}

.fc .fc-daygrid-day.fc-day-past .fc-daygrid-event.evt-summary:hover,
.fc .fc-daygrid-event.evt-summary.sum-past:hover {
    background-color: oklch(var(--b1));
    border-color: oklch(var(--bc) / 0.35);
    color: oklch(var(--bc));
    opacity: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* ------------------------------------------------------------------ */
/* Summary cards: Today date treatment                                */
/* ------------------------------------------------------------------ */

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-event.evt-summary,
.fc .fc-daygrid-event.evt-summary.sum-today {
    background-color: oklch(var(--b1));
    border: 1.5px solid oklch(var(--p));
    box-shadow: 0 4px 12px -2px oklch(var(--p) / 0.2), 0 2px 4px -1px oklch(var(--p) / 0.1);
    color: oklch(var(--bc));
    opacity: 1;
}

.fc-day-today .evt-summary .sum-main .sum-num,
.evt-summary.sum-today .sum-main .sum-num {
    color: oklch(var(--p));
    font-weight: 800;
}

.fc-day-today .evt-summary .sum-main .sum-num.sum-num-zero,
.evt-summary.sum-today .sum-main .sum-num.sum-num-zero {
    color: oklch(var(--bc) / 0.5);
}

.fc-day-today .evt-summary .sum-free,
.evt-summary.sum-today .sum-free {
    color: oklch(var(--bc));
    font-weight: 700;
}

.fc-day-today .evt-summary .sum-bar,
.evt-summary.sum-today .sum-bar {
    background-color: oklch(var(--p) / 0.15);
}

.fc-day-today .evt-summary .sum-bar-fill,
.evt-summary.sum-today .sum-bar-fill {
    background-color: oklch(var(--p));
}

.fc-day-today .evt-summary .sum-meta,
.evt-summary.sum-today .sum-meta {
    color: oklch(var(--bc) / 0.7);
}

.fc-day-today .evt-summary .sum-tentative,
.evt-summary.sum-today .sum-tentative {
    color: oklch(var(--wa));
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-event.evt-summary:hover,
.fc .fc-daygrid-event.evt-summary.sum-today:hover {
    border-color: oklch(var(--p));
    box-shadow: 0 6px 16px -2px oklch(var(--p) / 0.28);
    transform: translateY(-1px);
}

/* ------------------------------------------------------------------ */
/* Summary cards: Future date treatment                               */
/* ------------------------------------------------------------------ */

.fc .fc-daygrid-day.fc-day-future .fc-daygrid-event.evt-summary,
.fc .fc-daygrid-event.evt-summary.sum-future {
    background-color: oklch(var(--b1));
    border: 1px solid oklch(var(--b3));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    color: oklch(var(--bc));
    opacity: 1;
}

.fc-day-future .evt-summary .sum-main .sum-num,
.evt-summary.sum-future .sum-main .sum-num {
    color: oklch(var(--er) / 0.88);
    font-weight: 700;
}

.fc-day-future .evt-summary .sum-main .sum-num.sum-num-zero,
.evt-summary.sum-future .sum-main .sum-num.sum-num-zero {
    color: oklch(var(--bc) / 0.45);
}

.fc-day-future .evt-summary .sum-free,
.evt-summary.sum-future .sum-free {
    color: oklch(var(--bc));
    font-weight: 600;
}

.fc-day-future .evt-summary .sum-bar,
.evt-summary.sum-future .sum-bar {
    background-color: color-mix(in oklab, oklch(var(--bc)) 16%, oklch(var(--b2)));
}

.fc-day-future .evt-summary .sum-bar-fill,
.evt-summary.sum-future .sum-bar-fill {
    background-color: oklch(var(--er) / 0.85);
}

.fc-day-future .evt-summary .sum-meta,
.evt-summary.sum-future .sum-meta {
    color: oklch(var(--bc) / 0.7);
}

.fc-day-future .evt-summary .sum-tentative,
.evt-summary.sum-future .sum-tentative {
    color: oklch(var(--wa));
}

.fc .fc-daygrid-day.fc-day-future .fc-daygrid-event.evt-summary:hover,
.fc .fc-daygrid-event.evt-summary.sum-future:hover {
    border-color: oklch(var(--p));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* ------------------------------------------------------------------ */
/* Summary cards: Other/adjacent-month date treatment                 */
/* ------------------------------------------------------------------ */

.fc .fc-daygrid-day.fc-day-other .fc-daygrid-event.evt-summary {
    opacity: 0.38;
    filter: grayscale(0.6);
    background-color: oklch(var(--b2) / 0.3);
    border: 1px dashed oklch(var(--b3));
    box-shadow: none;
}

.fc .fc-daygrid-day.fc-day-other .fc-daygrid-event.evt-summary:hover {
    opacity: 0.85;
    filter: none;
    border-style: solid;
    border-color: oklch(var(--bc) / 0.3);
}

@media (max-width: 640px) {
    .fc .fc-daygrid-event.evt-summary {
        padding: 0.2rem 0.3rem;
        margin: 0.1rem;
    }

    .evt-summary .sum-num {
        font-size: 1rem;
    }

    /* Only the busy count + occupancy bar fit in a ~50px cell */
    .evt-summary .sum-today-pill,
    .evt-summary .sum-label,
    .evt-summary .sum-label-short,
    .evt-summary .sum-free,
    .evt-summary .sum-meta,
    .evt-summary .sum-tentative {
        display: none;
    }

    .evt-summary .sum-bar {
        margin: 0.2rem 0 0.1rem;
    }
}

.fc .fc-daygrid-day-number,
.fc .fc-daygrid-day-frame {
    cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Week and Day Views (timeGrid): past/today/future hierarchy          */
/* ------------------------------------------------------------------ */

.fc .fc-col-header-cell.fc-day-past {
    background-color: oklch(var(--b2) / 0.35);
    opacity: 0.65;
}

.fc .fc-col-header-cell.fc-day-today {
    background-color: oklch(var(--p) / 0.12) !important;
    color: oklch(var(--p)) !important;
    font-weight: 700;
}

.fc .fc-timegrid-col.fc-day-past {
    background-color: oklch(var(--b2) / 0.2);
}

.fc .fc-timegrid-col.fc-day-today {
    background-color: color-mix(in oklab, oklch(var(--p)) 4%, transparent);
}

.fc .fc-day-past .fc-timegrid-event,
.fc .fc-timegrid-event.fc-event-past {
    opacity: 0.65;
    filter: saturate(0.65);
    transition: all 0.15s ease;
}

.fc .fc-day-past .fc-timegrid-event:hover,
.fc .fc-timegrid-event.fc-event-past:hover {
    opacity: 1;
    filter: none;
}

.fc .fc-timegrid-now-indicator-line {
    border-color: oklch(var(--p));
    border-width: 2px;
}

.fc .fc-timegrid-now-indicator-arrow {
    border-color: oklch(var(--p));
}

/* ------------------------------------------------------------------ */
/* List View: past and today styling                                  */
/* ------------------------------------------------------------------ */

.fc .fc-list-day.fc-day-past .fc-list-day-cushion {
    opacity: 0.65;
    background-color: oklch(var(--b2) / 0.6) !important;
}

.fc .fc-list-day.fc-day-today .fc-list-day-cushion {
    background-color: oklch(var(--p) / 0.15) !important;
    color: oklch(var(--p)) !important;
    font-weight: 700;
}

.fc .fc-list-day.fc-day-past + .fc-list-event,
.fc .fc-list-event.fc-event-past {
    opacity: 0.7;
}

/* ------------------------------------------------------------------ */
/* General FullCalendar polish                                          */
/* ------------------------------------------------------------------ */

.fc-theme-standard .fc-list {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid oklch(var(--b3, 0.85 0 0));
    background-color: oklch(var(--b1));
}

.fc .fc-list-table {
    width: 100% !important;
}

@media (max-width: 768px) {
    /* Responsive toolbar: buttons on top, title below */
    .fc .fc-header-toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem !important;
    }

    .fc-header-toolbar .fc-toolbar-chunk:nth-child(1) {
        order: 1;
    }

    .fc-header-toolbar .fc-toolbar-chunk:nth-child(3) {
        order: 2;
    }

    .fc-header-toolbar .fc-toolbar-chunk:nth-child(2) {
        order: 3;
        width: 100%;
        text-align: center;
        display: flex;
        justify-content: center;
    }

    .fc-toolbar-title {
        font-size: 1rem !important;
        margin-top: 0.25rem;
    }
}

@media (max-width: 640px) {
    .fc .fc-list-day-cushion {
        padding: 8px 10px !important;
        font-size: 0.825rem !important;
        background-color: oklch(var(--b2, 0.92 0 0)) !important;
    }

    .fc .fc-list-event td {
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    .fc .fc-list-event-time {
        font-size: 0.75rem !important;
        padding-left: 8px !important;
        padding-right: 4px !important;
        white-space: nowrap;
        width: 1%;
        font-weight: 500;
    }

    .fc .fc-list-event-graphic {
        padding-left: 2px !important;
        padding-right: 2px !important;
        width: 1%;
    }

    .fc .fc-list-event-title {
        font-size: 0.825rem !important;
        padding-left: 6px !important;
        padding-right: 8px !important;
        line-height: 1.35;
    }

    .fc .fc-button {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.8rem !important;
    }
}
