/* ==========================================================================
   OneStaff v5 "Flow" - event calendar (app/Views/events/index.php)
   Loaded by includes/head.php after onestaff-flow-widgets.css. Reads only the
   --os-* tokens (never a parallel palette) and is scoped under .os-cal-page, so
   it cannot leak into the calendar widgets used elsewhere (dashboard, client tab).
   Event colour comes from --ev, set per event in eventDidMount.
   ========================================================================== */

/* ---------- page shell: no card-in-card, the calendar and the side panel are the two surfaces ---------- */
.os-cal-page { background: transparent !important; border: 0 !important; box-shadow: none !important; }
.os-cal-page > .card-body { padding: 0 !important; }
.os-cal-page .os-cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.os-cal-page .os-cal-layout.os-cal-solo { grid-template-columns: minmax(0, 1fr); }
.os-cal-page .os-cal-main {
    min-width: 0; padding: 18px 20px 20px;
    background: var(--os-surface); border: 1px solid var(--os-line); border-radius: var(--os-r-xl);
}
.os-cal-page .os-cal-side { min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: 16px; position: sticky; top: 16px; }
@media (max-width: 1200px) {
    .os-cal-page .os-cal-layout { grid-template-columns: minmax(0, 1fr); }
    .os-cal-page .os-cal-side { position: static; margin: 0; padding: 0; border: 0; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
}
@media (max-width: 575px) {
    .os-cal-page .os-cal-main { padding: 12px 10px 14px; border-radius: var(--os-r-lg); }
}

/* ---------- toolbar: title + count on the left, today | prev next | view switch on the right ---------- */
.os-cal-page .fc .fc-header-toolbar { margin: 0 0 16px; gap: 12px; flex-wrap: wrap; }
.os-cal-page .fc .fc-toolbar-chunk { display: flex; align-items: center; gap: 8px; }
.os-cal-page .fc .fc-toolbar-title { margin: 0; font: 600 22px/1.2 var(--os-font-display) !important; letter-spacing: -0.02em; color: var(--os-text) !important; }
.os-cal-count {
    display: inline-flex; align-items: center; height: 24px; padding: 0 10px; margin-left: 4px;
    border-radius: 999px; background: var(--os-wash); color: var(--os-muted);
    font: 500 12px/1 var(--os-font); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.os-cal-count.is-empty { color: var(--os-faint); }

.os-cal-page .fc .fc-button,
.os-cal-page .fc .fc-button-primary {
    height: 34px; padding: 0 14px; min-width: 34px; border-radius: var(--os-r-sm) !important;
    background: var(--os-surface) !important; border: 1px solid var(--os-line-2) !important; color: var(--os-text-2) !important;
    font: 500 13px/1 var(--os-font) !important; text-transform: capitalize; box-shadow: none !important; outline: 0;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.os-cal-page .fc .fc-button:hover:not(:disabled) { background: var(--os-wash-2) !important; color: var(--os-text) !important; }
.os-cal-page .fc .fc-button:focus-visible { box-shadow: 0 0 0 2px var(--os-accent-ring) !important; }
.os-cal-page .fc .fc-button:disabled { opacity: 0.4; }
/* prev / next: two square ghost buttons */
.os-cal-page .fc .fc-button-group { display: inline-flex; gap: 4px; box-sizing: border-box; }
.os-cal-page .fc .fc-button-group > .fc-button { margin: 0 !important; }
.os-cal-page .fc .fc-prev-button, .os-cal-page .fc .fc-next-button { padding: 0; width: 34px; display: inline-grid; place-items: center; }
.os-cal-page .fc .fc-icon { font-size: 1.25em; }
/* view switch: one segmented control, the active segment is "ink" */
.os-cal-page .fc .fc-toolbar-chunk > .fc-button-group:last-child {
    gap: 2px; padding: 3px; border-radius: var(--os-r-md); background: var(--os-wash); box-shadow: inset 0 0 0 1px var(--os-line);
}
.os-cal-page .fc .fc-toolbar-chunk > .fc-button-group:last-child > .fc-button {
    height: 28px; padding: 0 12px; border-color: transparent !important; background: transparent !important; color: var(--os-muted) !important; border-radius: 8px !important;
}
.os-cal-page .fc .fc-toolbar-chunk > .fc-button-group:last-child > .fc-button:hover:not(.fc-button-active) { color: var(--os-text) !important; background: var(--os-wash-2) !important; }
.os-cal-page .fc .fc-toolbar-chunk > .fc-button-group:last-child > .fc-button.fc-button-active { background: var(--os-ink) !important; color: var(--os-on-ink) !important; }
.os-cal-page .fc .fc-button { white-space: nowrap; }
@media (max-width: 767px) {
    .os-cal-page .fc .fc-toolbar-title { font-size: 18px !important; }
    .os-cal-page .fc .fc-header-toolbar { display: grid; gap: 10px; }
    /* chunk 2: today + prev/next on one row, the view switch spans the row below */
    .os-cal-page .fc .fc-toolbar-chunk:last-child { flex-wrap: wrap; width: 100%; }
    .os-cal-page .fc .fc-toolbar-chunk:last-child > .fc-today-button { margin-right: auto; }
    .os-cal-page .fc .fc-toolbar-chunk > .fc-button-group:last-child { flex: 1 0 100%; order: 3; }
    .os-cal-page .fc .fc-toolbar-chunk > .fc-button-group:last-child > .fc-button { flex: 1; padding: 0 6px; }
}

/* ---------- grid ---------- */
.os-cal-page .fc .fc-view-harness { border-radius: var(--os-r-md); }
.os-cal-page .fc .fc-scrollgrid { border-color: var(--os-line) !important; border-radius: var(--os-r-md); }
.os-cal-page .fc .fc-scrollgrid td,
.os-cal-page .fc .fc-scrollgrid th,
.os-cal-page .fc .fc-theme-standard td,
.os-cal-page .fc .fc-theme-standard th { border-color: var(--os-line) !important; }
.os-cal-page .fc .fc-col-header-cell { padding: 0 !important; background: transparent !important; }
.os-cal-page .fc .fc-col-header-cell-cushion {
    display: block; padding: 11px 8px !important; font-size: 11px !important; font-weight: 600 !important;
    letter-spacing: 0.07em !important; text-transform: uppercase !important; color: var(--os-faint) !important;
}
/* day numbers sit top-left, today is the one green marker */
.os-cal-page .fc .fc-daygrid-day-top { flex-direction: row; }
.os-cal-page .fc .fc-daygrid-day-number {
    padding: 0 !important; margin: 8px 0 4px 10px; min-width: 24px; height: 24px; display: inline-grid; place-items: center;
    font: 500 12.5px/1 var(--os-font); font-variant-numeric: tabular-nums; color: var(--os-text-2) !important;
    border-radius: 999px; text-decoration: none; transition: background 140ms ease;
}
.os-cal-page .fc .fc-daygrid-day-number:hover { background: var(--os-wash-2); }
.os-cal-page .fc .fc-day-today { background: rgba(var(--os-green-rgb), 0.045) !important; }
.os-cal-page .fc .fc-day-today .fc-daygrid-day-number {
    margin: 8px 0 4px 8px; padding: 0 8px !important; background: var(--os-green-ink) !important; color: #fff !important; font-weight: 600;
}
.os-cal-page .fc .fc-day-other .fc-daygrid-day-top { opacity: 0.38; }
.os-cal-page .fc .fc-day-sat:not(.fc-day-today),
.os-cal-page .fc .fc-day-sun:not(.fc-day-today) { background: rgba(var(--os-tint), 0.022) !important; }
.os-cal-page .fc .fc-daygrid-day-frame { min-height: 112px; padding-bottom: 2px; cursor: pointer; }
.os-cal-page .fc .fc-daygrid-day-events { padding: 0 6px 2px; }
.os-cal-page .fc .fc-daygrid-event-harness { margin-top: 2px; }
.os-cal-page .fc .fc-highlight { background: rgba(var(--os-green-rgb), 0.1) !important; }

/* "+3 more" */
.os-cal-page .fc .fc-daygrid-more-link { margin: 3px 0 0 6px; padding: 1px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: var(--os-muted); }
.os-cal-page .fc .fc-daygrid-more-link:hover { background: var(--os-wash-2); color: var(--os-text); text-decoration: none; }
.os-cal-page .fc .fc-popover {
    background: var(--os-surface-3) !important; border: 1px solid var(--os-line-2) !important; border-radius: var(--os-r-md); box-shadow: var(--os-shadow-md); overflow: hidden;
}
.os-cal-page .fc .fc-popover-header { padding: 8px 12px; background: var(--os-wash) !important; color: var(--os-text); font-weight: 600; font-size: 12.5px; }
.os-cal-page .fc .fc-popover-body { padding: 6px; }

/* ---------- events: soft tint of the event colour + a 3px accent edge ---------- */
.os-cal-page .fc .fc-event {
    --ev: #4a8af4;
    min-height: 22px; padding: 2px 7px 2px 6px !important; margin: 0;
    background: color-mix(in srgb, var(--ev) 14%, var(--os-surface)) !important;
    border: 0 !important; border-left: 3px solid var(--ev) !important; border-radius: 6px !important; box-shadow: none !important;
    color: var(--os-text) !important; font-size: 12px; font-weight: 500; line-height: 1.35; cursor: pointer;
    transition: background 140ms ease, transform 140ms ease;
}
:root[data-theme="dark"] .os-cal-page .fc .fc-event { background: color-mix(in srgb, var(--ev) 24%, var(--os-surface)) !important; }
.os-cal-page .fc .fc-event:hover { background: color-mix(in srgb, var(--ev) 24%, var(--os-surface)) !important; filter: none; z-index: 5; }
:root[data-theme="dark"] .os-cal-page .fc .fc-event:hover { background: color-mix(in srgb, var(--ev) 34%, var(--os-surface)) !important; }
.os-cal-page .fc .fc-event:focus-visible { outline: 2px solid var(--os-accent-ring); outline-offset: 1px; }
.os-cal-page .fc .fc-event .fc-event-main, .os-cal-page .fc .fc-event .fc-event-main-frame { color: inherit; }
.os-cal-page .fc .fc-daygrid-event-dot { display: none; }
.os-cal-page .fc .fc-daygrid-dot-event { padding-left: 6px !important; }
/* multi-day bars: round and edge only where the event really starts / ends */
.os-cal-page .fc .fc-event:not(.fc-event-start) { border-left-width: 0 !important; border-top-left-radius: 0 !important; border-bottom-left-radius: 0 !important; }
.os-cal-page .fc .fc-event:not(.fc-event-end) { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }

.os-cal-page .os-ev { display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; }
.os-cal-page .os-ev-icon { flex: none; width: 12px; height: 12px; color: var(--ev); }
.os-cal-page .os-ev-time { flex: none; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: color-mix(in srgb, var(--ev) 62%, var(--os-text)); }
.os-cal-page .os-ev-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- week / day ---------- */
.os-cal-page .fc .fc-timegrid-slot { height: 2.6em; border-color: var(--os-line) !important; }
.os-cal-page .fc .fc-timegrid-slot-minor { border-top-style: dotted !important; }
.os-cal-page .fc .fc-timegrid-slot-label-cushion { font-size: 11px; font-weight: 500; color: var(--os-faint); text-transform: lowercase; }
.os-cal-page .fc .fc-timegrid-axis-cushion { font-size: 11px; color: var(--os-faint); }
.os-cal-page .fc .fc-timegrid-event { box-shadow: none !important; }
.os-cal-page .fc .fc-timegrid-event .os-ev { flex-direction: column; align-items: flex-start; gap: 1px; white-space: normal; }
.os-cal-page .fc .fc-timegrid-event .os-ev-time { order: 2; font-weight: 500; }
.os-cal-page .fc .fc-timegrid-event .os-ev-title { white-space: normal; font-weight: 600; }
.os-cal-page .fc .fc-timegrid-now-indicator-line { border-color: var(--os-coral); }
.os-cal-page .fc .fc-timegrid-now-indicator-arrow { border-left-color: var(--os-coral); border-right-color: var(--os-coral); }
.os-cal-page .fc .fc-timegrid-col.fc-day-today { background: rgba(var(--os-green-rgb), 0.035) !important; }
.os-cal-page .fc .fc-timegrid-divider { padding: 0; border-color: var(--os-line); }
.os-cal-page .fc .fc-col-header-cell.fc-day-today .fc-col-header-cell-cushion { color: var(--os-green-ink) !important; }

/* ---------- list ---------- */
.os-cal-page .fc .fc-list { border: 1px solid var(--os-line); border-radius: var(--os-r-md); overflow: hidden; }
.os-cal-page .fc .fc-list-empty { background: transparent; color: var(--os-muted); }
.os-cal-page .fc .fc-list-day-cushion { background: var(--os-wash) !important; padding: 10px 16px !important; font-size: 11.5px !important; letter-spacing: 0.06em; text-transform: uppercase; color: var(--os-muted) !important; }
.os-cal-page .fc .fc-list-day-text, .os-cal-page .fc .fc-list-day-side-text { color: inherit; font-weight: 600; text-decoration: none; }
/* list rows are <tr class="fc-event">: they must not take the chip tint (the dot carries the colour) */
.os-cal-page .fc .fc-list-event.fc-event,
.os-cal-page .fc .fc-list-event.fc-event:hover,
:root[data-theme="dark"] .os-cal-page .fc .fc-list-event.fc-event,
:root[data-theme="dark"] .os-cal-page .fc .fc-list-event.fc-event:hover { background: transparent !important; border: 0 !important; border-radius: 0 !important; padding: 0 !important; min-height: 0; }
.os-cal-page .fc .fc-list-event td { padding: 11px 16px !important; font-size: 13.5px !important; color: var(--os-text-2); }
.os-cal-page .fc .fc-list-event { cursor: pointer; }
.os-cal-page .fc .fc-list-event:hover td { background: var(--os-wash) !important; }
.os-cal-page .fc .fc-list-event-dot { border-width: 5px; }
.os-cal-page .fc .fc-list-event-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--os-muted); }
.os-cal-page .fc .fc-list-event-title { color: var(--os-text); font-weight: 500; }
.os-cal-page .fc .fc-list-event-title .os-ev-icon { display: inline-block; vertical-align: -2px; margin-right: 6px; }
.os-cal-page .fc .fc-list-event-title a { color: inherit; text-decoration: none; }

/* ---------- side panel: today card ---------- */
.os-cal-today, .os-cal-up {
    background: var(--os-surface); border: 1px solid var(--os-line); border-radius: var(--os-r-xl);
}
.os-cal-today { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 16px; row-gap: 14px; padding: 18px 20px; }
.os-cal-today-day { font: 600 46px/1 var(--os-font-display); letter-spacing: -0.04em; color: var(--os-text); font-variant-numeric: tabular-nums; }
.os-cal-today-main { display: grid; gap: 3px; min-width: 0; }
.os-cal-today-main b { font: 600 16px/1.2 var(--os-font-display); color: var(--os-text); }
.os-cal-today-main span { font-size: 12.5px; color: var(--os-muted); }
.os-cal-today-pill {
    grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
    border-radius: var(--os-r-sm); background: var(--os-wash); color: var(--os-muted); font-size: 12.5px; font-weight: 500;
}
.os-cal-today-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--os-faint); flex: none; }
.os-cal-today-pill.is-busy { background: var(--os-green-soft); color: var(--os-green-ink); }
.os-cal-today-pill.is-busy::before { background: var(--os-green); }
:root[data-theme="dark"] .os-cal-today-pill.is-busy { background: rgba(var(--os-green-rgb), 0.12); }

/* ---------- side panel: upcoming, grouped by day ---------- */
.os-cal-up { padding: 18px 20px 12px; }
.os-cal-up-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.os-cal-up-head h2 { margin: 0; font: 600 15px/1.3 var(--os-font-display); color: var(--os-text); }
.os-cal-up-group { padding: 12px 0 6px; }
.os-cal-up-group + .os-cal-up-group { border-top: 1px solid var(--os-line); }
.os-cal-up-day { margin-bottom: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--os-faint); }
.os-cal-up-group.is-today .os-cal-up-day { color: var(--os-green-ink); }
.os-cal-up-list { list-style: none; margin: 0 -8px; padding: 0; display: grid; gap: 2px; }
.os-cal-up-list li { display: flex; align-items: stretch; gap: 12px; padding: 0; border-radius: var(--os-r-sm); }
.os-cal-up-time {
    flex: 0 0 56px; padding: 8px 0 8px 8px; display: flex; flex-direction: column; gap: 1px;
    font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--os-text-2);
}
.os-cal-up-time small { font-size: 11px; font-weight: 500; color: var(--os-faint); }
.os-cal-up-item {
    flex: 1; min-width: 0; display: flex; align-items: center; margin: 3px 0; padding: 4px 10px 4px 12px;
    border-left: 3px solid var(--ev, #4a8af4); border-radius: 4px 8px 8px 4px; color: var(--os-text) !important; text-decoration: none !important;
    background: color-mix(in srgb, var(--ev, #4a8af4) 10%, transparent); transition: background 140ms ease;
}
.os-cal-up-item:hover { background: color-mix(in srgb, var(--ev, #4a8af4) 20%, transparent); }
.os-cal-up-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.os-cal-up .os-empty { padding: 28px 8px 22px; }

@media print {
    .os-cal-page .os-cal-side { display: none; }
    .os-cal-page .os-cal-layout { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .os-cal-page .fc .fc-event, .os-cal-up-item, .os-cal-page .fc .fc-button { transition: none; }
}

/* phone: grid + chip sizing (kept at the end so it wins over the desktop grid rules above) */
@media (max-width: 767px) {
    .os-cal-page .fc .fc-col-header-cell-cushion { padding: 9px 0 !important; font-size: 10px !important; letter-spacing: 0.02em !important; text-align: center; }
    .os-cal-page .fc .fc-daygrid-day-frame { min-height: 76px; }
    .os-cal-page .fc .fc-daygrid-day-number { margin: 6px 0 2px 4px; }
    .os-cal-page .fc .fc-day-today .fc-daygrid-day-number { margin-left: 3px; }
    .os-cal-page .fc .fc-daygrid-day-events { padding: 0 2px 2px; }
    .os-cal-page .fc .fc-event { padding: 1px 4px 1px 4px !important; font-size: 11px; }
    .os-cal-page .os-ev-time { display: none; }
    .os-cal-page .fc .fc-timegrid-event .os-ev-time, .os-cal-page .fc .fc-list-event .os-ev-time { display: inline; }
}
