/* ── Planna Internal Portal – Calendar day/week view styles ──
   Token mapping (new.html → tokens.css):
   --b1 → --border-1   --b2 → --border-2   --b3 → --border-3
   --t1 → --text-1     --t3 → --text-3     --bg-2 → --bg-elev
   --r1 → --r-sm       --r3 → --r-lg       --rd → --red
   --ac → --accent     --ai-b → --ai-border
*/

/* ═══════════════════════════════════════════════════════════
   CALENDAR GRID — CSS grid, one col per staff/day
═══════════════════════════════════════════════════════════ */

.cal-grid {
    display: grid;
    gap: 0;
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    overflow: hidden;
    overflow-x: auto;
}

/* Column (time gutter or staff/day) */
.cal-col {
    position: relative;
    border-right: 1px solid var(--border-1);
    min-width: 0;
}
.cal-col:last-child { border-right: none; }

/* Column header — sticky at top */
.cal-col-h {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-1);
    text-align: center;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border-1);
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.cal-col-sub {
    font-size: 10px;
    color: var(--text-3);
    font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════
   BODY — relative container for hour rows + event blocks
═══════════════════════════════════════════════════════════ */

.cal-body {
    position: relative;
    min-height: 600px;
}

/* Hour row — 60px tall, bottom border acts as grid line */
.cal-hour {
    height: 60px;
    border-bottom: 1px solid var(--border-2);
    position: relative;
}

/* Clickable hour rows in WeekView — show pointer + subtle accent on hover */
.cal-hour-clickable {
    cursor: pointer;
    transition: background .1s;
}
.cal-hour-clickable:hover {
    background: var(--accent-subtle);
}

/* 30-min dashed line at mid-hour for precise time reading */
.cal-hour::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 0;
    border-top: 1px dashed var(--border-1);
    opacity: 0.55;
    pointer-events: none;
}

/* Time labels — positioned left of their column */
.cal-hour-label {
    position: absolute;
    right: 6px;
    top: -7px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   EVENT BLOCKS
═══════════════════════════════════════════════════════════ */

/* Event blocks — sharp top corners for precise time alignment,
   rounded bottom corners for premium feel */
.cal-event {
    position: absolute;
    left: 3px;
    right: 3px;
    border-radius: 2px 2px var(--r-sm) var(--r-sm);
    padding: 4px 6px;
    font-size: 11px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow .12s, transform .12s;
    z-index: 5;
    user-select: none;
}
.cal-event:hover {
    box-shadow: var(--sh-md);
    transform: translateY(-1px);
    z-index: 6;
}
.cal-event:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-ring);
    z-index: 6;
}
.cal-hour-clickable:focus-visible {
    outline: none;
    background: var(--accent-subtle);
    z-index: 1;
}
.cal-slot:focus-visible {
    outline: none;
    background: var(--accent-subtle);
}
.cal-month-cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    z-index: 1;
}

/* Drag handle affordance — 6-dot grip pattern */
.cal-ev-drag-handle {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 16px;
    background-image: radial-gradient(circle, var(--text-3) 1.5px, transparent 1.5px);
    background-size: 4px 4px;
    background-position: 0 0, 0 4px, 0 8px, 4px 0, 4px 4px, 4px 8px;
    opacity: 0;
    transition: opacity .15s;
    cursor: grab;
}
.cal-event:hover .cal-ev-drag-handle {
    opacity: 0.45;
}
.cal-event:active .cal-ev-drag-handle {
    cursor: grabbing;
}

.cal-event-name {
    display: block;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-event-det {
    display: block;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status colour variants */
.cal-ev-confirmed  { background: var(--blue-s);   border-left: 3px solid var(--blue);    color: var(--blue); }
.cal-ev-checkedin  { background: var(--green-s);  border-left: 3px solid var(--green);   color: var(--green); }
.cal-ev-inprogress { background: var(--amber-s);  border-left: 3px solid var(--amber);   color: var(--amber); }
.cal-ev-requested  { background: var(--amber-s);  border-left: 3px solid var(--amber);   color: var(--amber); }
.cal-ev-completed  { background: var(--bg-elev);  border-left: 3px solid var(--text-3);  color: var(--text-2); }
.cal-ev-noshow     { background: var(--red-s);    border-left: 3px solid var(--red);     color: var(--red); }
.cal-ev-cancelled  { background: var(--bg-elev);  border-left: 3px solid var(--border-3); color: var(--text-3); text-decoration: line-through; opacity: .6; }
/* B22: Processing blocks — staff is free, resource is still busy. Hatched pattern. */
.cal-ev-processing {
    background-image: repeating-linear-gradient(
        45deg, transparent, transparent 4px, var(--border-2) 4px, var(--border-2) 8px);
    opacity: 0.75;
}

/* Terminal (cancelled / no-show) opacity */
.cal-event-terminal {
    opacity: .55;
}

/* Past events — muted so user focuses on future */
.cal-hour-past .cal-event {
    opacity: .75;
    filter: saturate(.65);
}

/* ═══════════════════════════════════════════════════════════
   CURRENT TIME LINE
═══════════════════════════════════════════════════════════ */

.cal-now {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--red);
    opacity: 0.7;
    z-index: 1;
    pointer-events: none;
}
.cal-now::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
    position: absolute;
    left: -4px;
    top: -3px;
}

/* ═══════════════════════════════════════════════════════════
   WEEK VIEW — day header "today" highlight
═══════════════════════════════════════════════════════════ */

.cal-col-h.today {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   DRAG-TO-RESCHEDULE
═══════════════════════════════════════════════════════════ */

/* 15-minute drop slots stacked inside each cal-hour */
.cal-slot {
    height: 15px;
}

.cal-slot-active {
    background: var(--accent-subtle);
    box-shadow: inset 0 2px 0 var(--accent);
    position: relative;
    z-index: 3;
}

/* Draggable card affordance */
.cal-event[draggable="true"] {
    cursor: grab;
}

.cal-ev-dragging {
    opacity: 0.35;
    cursor: grabbing !important;
    box-shadow: none !important;
}

/* ═══════════════════════════════════════════════════════════
   BOOKING DETAIL DRAWER — shared + bottom-sheet on mobile
═══════════════════════════════════════════════════════════ */

.booking-drawer {
    width: min(420px, 100vw);
    overflow: hidden;
    will-change: transform;
    transition: transform .25s cubic-bezier(.32,.72,0,1);
}

/* Drag handle pill — visible on mobile only */
.drawer-handle {
    display: none;
    width: 36px;
    height: 4px;
    background: var(--border-3);
    border-radius: 2px;
    margin: 10px auto 2px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   DATE NAVIGATION — [←] [date heading] [→]
   Arrows flank the date so the navigation group is visually
   intuitive: the user sees arrows pointing away from the date.
═══════════════════════════════════════════════════════════ */

.cal-date-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Visible arrow buttons with border + subtle background */
.cal-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    border: 1px solid var(--border-2);
    background: var(--bg-card);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s, transform .08s;
    flex-shrink: 0;
    touch-action: manipulation;
}
.cal-nav-btn:hover {
    background: var(--bg-elev);
    color: var(--text-1);
    border-color: var(--border-3);
}
.cal-nav-btn:active {
    transform: scale(0.9);
    background: var(--bg-inset);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE BANNER — shown when auto-switched to list view
═══════════════════════════════════════════════════════════ */

.cal-mobile-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--accent-subtle);
    border-radius: var(--r-md);
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}
.cal-mobile-banner button {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 4px;
    min-height: 44px;
    font-family: inherit;
}

/* ═══════════════════════════════════════════════════════════
   CALENDAR SCROLL CONTAINER
═══════════════════════════════════════════════════════════ */

.cal-scroll {
    overflow-y: auto;
    overflow-x: auto;
    max-height: calc(100dvh - 200px);
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Media Queries optimized for actual iPhone widths
   
   Optimized for: 375px (iPhone SE), 390px (iPhone 13), 402px (iPhone 16 Pro)
   Then: 640px (tablets), 768px (iPad), 1024px (desktop)
═══════════════════════════════════════════════════════════ */

/* Tablet & up (640px+) — spacious layout */
@media (min-width: 640px) {
    .cal-grid { border-radius: var(--r-md); }
    .cal-col-h { padding: 7px 6px; }
    .cal-event-name { font-size: 10px; }
    .cal-event-det  { font-size: 9px; }
    /* Staff filter: horizontal scroll row */
    .cal-staff-filter {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 2px;
    }
}

/* Mobile <640px — compact, touch-optimized (375px iPhone SE and up) */
@media (max-width: 639px) {
    /* View tabs: move to own full-width row at the bottom of the toolbar */
    .cal-view-tabs {
        display: flex !important;
        width: 100%;
        order: 10;
    }
    /* Each tab stretches equally — icon-only at this breakpoint */
    .cal-view-tabs .tab {
        flex: 1;
        justify-content: center;
        min-height: 44px;
    }
    /* Compact — icon only (text hidden, icon visible) */
    .cal-btn-text { display: none; }
    /* Hide toolbar "+ Ny booking" button — FAB handles it */
    [data-testid="new-booking-btn"] { display: none !important; }

    .cal-grid { border-radius: var(--r-sm); }
    .cal-col-h { padding: 6px 4px; font-size: 10px; }
    /* Offset increased by ~48px for the new view-tab row */
    .cal-scroll { max-height: calc(100dvh - 228px); }

    /* Month cells: smaller but still tappable (min 44px for touch) */
    .cal-month-cell { min-height: clamp(44px, 13vw, 60px) !important; }
    /* Hide text labels, show dot row on mobile */
    .cal-month-label { display: none !important; }
    .cal-month-dots-row { display: flex !important; }

    /* Event blocks: larger touch target (44px minimum) */
    .cal-event { min-height: 44px; padding: 6px 6px 4px; }

    /* Bottom sheet: slide up from bottom on mobile */
    .booking-drawer {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 88dvh !important;
        border-radius: 20px 20px 0 0 !important;
        border-left: none !important;
        border-top: 1px solid var(--border-1) !important;
    }
    .drawer-handle { display: block; }
}

/* Fine-tune at 375px (iPhone SE, most constrained) */
@media (max-width: 375px) {
    .cal-col-h { padding: 5px 3px; font-size: 9px; }
    .cal-event-name { font-size: 9px; line-height: 1.2; }
    .cal-event-det  { font-size: 8px; }
    .cal-hour-label { font-size: 9px; }
}

/* Optimization for 390-402px (iPhone 13-16 Pro range — 33%+ market) */
@media (min-width: 390px) and (max-width: 639px) {
    .cal-col-h { padding: 6px 4px; }
    .cal-event { min-height: 40px; }
}

/* ═══════════════════════════════════════════════════════════
   STAFF AVATAR CHIP — booking blocks in week / list view
═══════════════════════════════════════════════════════════ */

.cal-ev-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 8px;
    font-weight: 700;
    color: var(--text-on-accent);
    flex-shrink: 0;
    overflow: hidden;
    border: 1.5px solid rgba(255,255,255,.45);
    box-shadow: var(--sh-sm);
    letter-spacing: 0;
}
.cal-ev-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ═══════════════════════════════════════════════════════════
   STATUS MICRO DOT — top-right corner of week booking block
═══════════════════════════════════════════════════════════ */

.cal-ev-sdot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.5);
    flex-shrink: 0;
}
.cal-ev-sdot-confirmed  { background: var(--blue);   }
.cal-ev-sdot-confirmed::after  { content: 'C'; }
.cal-ev-sdot-checkedin  { background: var(--green);  }
.cal-ev-sdot-checkedin::after  { content: 'I'; }
.cal-ev-sdot-inprogress { background: var(--amber);  }
.cal-ev-sdot-inprogress::after { content: 'P'; }
.cal-ev-sdot-requested  { background: var(--amber);  }
.cal-ev-sdot-requested::after  { content: 'R'; }
.cal-ev-sdot-completed  { background: var(--text-3); }
.cal-ev-sdot-completed::after  { content: 'D'; }
.cal-ev-sdot-cancelled  { background: var(--red);    }
.cal-ev-sdot-cancelled::after  { content: 'X'; }
.cal-ev-sdot-noshow     { background: var(--red);    }
.cal-ev-sdot-noshow::after     { content: 'N'; }

/* Status dot letter — single char for colorblind accessibility */
.cal-ev-sdot::after {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5px;
    font-weight: 800;
    color: var(--text-on-accent);
    line-height: 1;
}

/* ═══════════════════════════════════════════════════════════
   CURRENT TIME LINE — with HH:mm label bubble
═══════════════════════════════════════════════════════════ */

.cal-now-label {
    position: absolute;
    left: 2px;
    top: -8px;
    background: var(--red);
    color: var(--text-on-accent);
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    box-shadow: var(--sh-sm);
    z-index: 0;
}

/* ═══════════════════════════════════════════════════════════
   UTILIZATION BAR — under each staff column header
═══════════════════════════════════════════════════════════ */

.cal-util-track {
    height: 3px;
    background: var(--border-2);
    border-radius: 99px;
    margin: 4px 6px 0;
    overflow: hidden;
    width: calc(100% - 12px);
}
.cal-util-fill {
    height: 100%;
    border-radius: 99px;
    transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* ═══════════════════════════════════════════════════════════
   DAY VIEW — column header inner layout
═══════════════════════════════════════════════════════════ */

.cal-col-hinner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 2px;
}
.cal-col-hinner-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════════
   WEEK VIEW — staff-coloured booking block layout
═══════════════════════════════════════════════════════════ */

.cal-ev-week-row1 {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.cal-ev-week-name {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    color: var(--text-1);
}
.cal-ev-week-det {
    display: block;
    font-size: 10px;
    color: var(--text-2);
    opacity: .85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════
   LIST VIEW — staff avatar chip
═══════════════════════════════════════════════════════════ */

.cal-list-av {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-on-accent);
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.dark .cal-list-av {
    box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.cal-list-av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ═══════════════════════════════════════════════════════════
   LIST VIEW — status filter (Hick's Law: max 5 choices)
═══════════════════════════════════════════════════════════ */

.cal-list-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: var(--s2);
    padding-bottom: var(--s1);
    border-bottom: 1px solid var(--border-2);
}

@media (max-width: 639px) {
    .cal-list-filter {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
    }
    .cal-list-filter::-webkit-scrollbar { display: none; }
}

.cal-list-filter-chip {
    min-height: 44px;
    padding: 8px 14px;
    border-radius: var(--r-lg);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-2);
    background: var(--bg-elev);
    color: var(--text-2);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .1s, color .1s, border-color .1s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cal-list-filter-chip:hover {
    background: var(--surface-2);
}

.cal-list-filter-chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.cal-list-filter-chip--active {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent);
}

.cal-list-filter-chip--active:hover {
    background: var(--accent);
    opacity: 0.9;
}

.cal-list-filter-chip--inactive {
    background: var(--bg-elev);
    color: var(--text-2);
    border-color: var(--border-2);
}

/* ═══════════════════════════════════════════════════════════
   LIST VIEW — base layout styles (replaces inline styles)
═══════════════════════════════════════════════════════════ */

/* Day wrapper */
.cal-list-day { }

/* Date header row */
.cal-list-day-header {
    display: flex;
    align-items: center;
    gap: var(--s2);
    padding: var(--s1) 0;
    margin-bottom: var(--s1);
    border-bottom: 1px solid var(--border-2);
}

/* "I dag" badge */
.cal-list-day-badge {
    background: var(--accent);
    color: var(--text-on-accent);
    border-radius: var(--r-sm);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
}

/* Day name text */
.cal-list-day-title {
    font-size: 13px;
    font-weight: 600;
}
.cal-list-day-title--today {
    color: var(--accent);
}
.cal-list-day-title--other {
    color: var(--text-1);
}

/* Entry count text */
.cal-list-day-count {
    font-size: 11px;
    color: var(--text-3);
}

/* Entries container */
.cal-list-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Individual booking row */
.cal-list-item {
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: var(--s2) var(--s3);
    border-radius: var(--r-sm);
    border: 1px solid var(--border-2);
    background: var(--surface-1);
    cursor: pointer;
    transition: background .1s;
}
.cal-list-item:hover {
    background: var(--surface-2);
}

/* Time column */
.cal-list-time {
    min-width: 52px;
    text-align: right;
    flex-shrink: 0;
}
.cal-list-time-start {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}
.cal-list-time-dur {
    font-size: 12px;
    color: var(--text-3);
}

/* Vertical divider */
.cal-list-divider {
    width: 1px;
    height: 32px;
    background: var(--border-2);
    flex-shrink: 0;
}

/* Details block */
.cal-list-details {
    flex: 1;
    min-width: 0;
}
.cal-list-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-list-meta {
    font-size: 12px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status chip */
.cal-list-status {
    background: var(--accent);
    color: var(--text-on-accent);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.cal-list-status--confirmed  { background: var(--accent); }
.cal-list-status--requested  { background: var(--amber); }
.cal-list-status--checkedin  { background: var(--blue); }
.cal-list-status--inprogress { background: var(--accent); }
.cal-list-status--completed  { background: var(--text-3); }
.cal-list-status--cancelled  { background: var(--red); }
.cal-list-status--noshow     { background: var(--red); }

/* Chevron icon */
.cal-list-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-3);
    flex-shrink: 0;
}

/* Entry animation */
@keyframes calListItemEnter {
    from { opacity: 0; transform: translateX(-4px); }
    to   { opacity: 1; transform: translateX(0); }
}
.cal-list-item-enter {
    animation: calListItemEnter 150ms cubic-bezier(.4,0,.2,1) both;
}

/* ═══════════════════════════════════════════════════════════
   MONTH VIEW — booking density background tints
═══════════════════════════════════════════════════════════ */

.cal-month-dense-1 { background: color-mix(in srgb, var(--accent) 2.5%, transparent) !important; }
.cal-month-dense-2 { background: color-mix(in srgb, var(--accent) 5%,   transparent) !important; }
.cal-month-dense-3 { background: color-mix(in srgb, var(--accent) 8%,   transparent) !important; }
.cal-month-dense-4 { background: color-mix(in srgb, var(--accent) 11%,  transparent) !important; }
.dark .cal-month-dense-1 { background: color-mix(in srgb, var(--accent) 6%,  transparent) !important; }
.dark .cal-month-dense-2 { background: color-mix(in srgb, var(--accent) 10%, transparent) !important; }
.dark .cal-month-dense-3 { background: color-mix(in srgb, var(--accent) 14%, transparent) !important; }
.dark .cal-month-dense-4 { background: color-mix(in srgb, var(--accent) 18%, transparent) !important; }

/* ═══════════════════════════════════════════════════════════
   VIEW TRANSITION — fade + subtle slide on view switch
═══════════════════════════════════════════════════════════ */

@keyframes calFadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0);   }
}
.cal-view-enter {
    animation: calFadeIn .14s ease both;
}

/* ═══════════════════════════════════════════════════════════
   KEYBOARD SHORTCUT HINT — tiny badge in toolbar (desktop)
═══════════════════════════════════════════════════════════ */

.cal-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 4px;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-3);
    background: var(--bg-inset);
    border: 1px solid var(--border-3);
    border-radius: 3px;
    line-height: 1.4;
    letter-spacing: .02em;
    font-family: ui-monospace, monospace;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE OVERRIDES — chips and labels per breakpoint
═══════════════════════════════════════════════════════════ */

/* Mobile <640px — hide chips, keep dots tiny */
@media (max-width: 639px) {
    .cal-ev-chip    { display: none !important; }
    .cal-ev-sdot    { width: 5px; height: 5px; top: 3px; right: 3px; }
    .cal-now-label  { display: none !important; }
    .cal-kbd        { display: none !important; }
    .cal-list-av    { width: 24px; height: 24px; font-size: 9px; }
    .cal-util-track { display: none; }
}

/* iPad 640–1023px — slightly smaller chips */
@media (min-width: 640px) and (max-width: 1023px) {
    .cal-ev-chip    { width: 15px; height: 15px; font-size: 7px; }
    .cal-list-av    { width: 26px; height: 26px; font-size: 9px; }
    .cal-kbd        { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   WEEK VIEW — DAY NUMBER CIRCLE
═══════════════════════════════════════════════════════════ */

.cal-col-day-num {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.cal-col-day-num.today {
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   MONTH VIEW — DAY NUMBER
═══════════════════════════════════════════════════════════ */

.cal-month-day-num {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-1);
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.cal-month-day-num.today {
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 700;
}

.cal-month-day-num.other-month {
    color: var(--text-3);
    font-weight: 400;
}

/* ═══════════════════════════════════════════════════════════
   PAST TIME GRAY-OUT — all hours before "now" get subtle tint
═══════════════════════════════════════════════════════════ */

.cal-hour-past {
    background: var(--bg-inset);
}

/* ═══════════════════════════════════════════════════════════
   DAY PROGRESS — Goal-Gradient Effect, utilization indicator
═══════════════════════════════════════════════════════════ */

.cal-day-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 80px;
    max-width: 140px;
}

.cal-day-progress-track {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--border-2);
    overflow: hidden;
}

.cal-day-progress-fill {
    height: 100%;
    border-radius: 2px;
    width: var(--progress-pct, 0%);
    background: var(--progress-color, var(--accent));
    transition: width .3s cubic-bezier(.4,0,.2,1);
}

.cal-day-progress-text {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    white-space: nowrap;
}

@media (max-width: 639px) {
    .cal-day-progress-track { display: none; }
    .cal-day-progress-text { display: inline; font-size: 10px; }
}

/* ═══════════════════════════════════════════════════════════
   BUSINESS HOURS TINT — highlight the active part of the day
═══════════════════════════════════════════════════════════ */

.cal-hour-business {
    background: var(--accent-subtle);
}

/* ═══════════════════════════════════════════════════════════
   TIME-ZONE CHUNKING — morning / afternoon / evening tints
═══════════════════════════════════════════════════════════ */

.cal-hour-morning {
    background: color-mix(in srgb, var(--amber) 2.5%, transparent);
}
.cal-hour-afternoon {
    background: transparent;
}
.cal-hour-evening {
    background: color-mix(in srgb, var(--blue) 2.5%, transparent);
}
.dark .cal-hour-morning {
    background: color-mix(in srgb, var(--amber) 5%, transparent);
}
.dark .cal-hour-evening {
    background: color-mix(in srgb, var(--blue) 5%, transparent);
}

/* ═══════════════════════════════════════════════════════════
   BOOKING DETAIL DRAWER — replaces inline styles
═══════════════════════════════════════════════════════════ */

.booking-drawer-backdrop {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    cursor: pointer;
}
.dark .booking-drawer-backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.booking-drawer {
    background: var(--bg-card);
    border-left: 1px solid var(--border-2);
}

.booking-drawer-header {
    padding: var(--s5) var(--s6);
    border-bottom: 1px solid var(--border-1);
    flex-shrink: 0;
}

.booking-drawer-body {
    padding: var(--s5);
    display: flex;
    flex-direction: column;
    gap: var(--s3);
    overscroll-behavior: contain;
}

.booking-drawer-client {
    color: var(--text-1);
    font-weight: 600;
}

.booking-drawer-icon {
    color: var(--text-3);
    flex-shrink: 0;
}

.booking-drawer-actions {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
}

/* Status-specific action buttons */
.btn-danger {
    background: var(--red-s);
    color: var(--red);
    border: none;
    border-radius: var(--r-md);
    padding: 7px 14px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    width: 100%;
}
.btn-danger:hover {
    background: var(--red);
    color: var(--text-on-accent);
}

.btn-success {
    background: var(--green-s);
    color: var(--green);
    border: none;
    border-radius: var(--r-md);
    padding: 7px 14px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    width: 100%;
}
.btn-success:hover {
    background: var(--green);
    color: var(--text-on-accent);
}

.btn-warning {
    background: var(--amber-s);
    color: var(--amber);
    border: none;
    border-radius: var(--r-md);
    padding: 7px 14px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    width: 100%;
}
.btn-warning:hover {
    background: var(--amber);
    color: var(--text-on-accent);
}

.booking-drawer-gapfill {
    padding: 12px 14px;
}

.booking-drawer-gapfill-title {
    color: var(--text-1);
    margin-bottom: var(--s2);
    display: flex;
    align-items: center;
    gap: 4px;
}

.booking-drawer-gapfill-candidate {
    color: var(--text-2);
    padding: 3px 0;
}

/* ═══════════════════════════════════════════════════════════
   ENTRY ANIMATION — fade + slide in when bookings appear
═══════════════════════════════════════════════════════════ */

@keyframes calEventEnter {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0);   }
}
.cal-event-enter {
    animation: calEventEnter 150ms cubic-bezier(.4,0,.2,1) both;
}

/* ═══════════════════════════════════════════════════════════
   MOTION SAFETY — respect OS reduce-motion preference
═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .cal-view-enter        { animation: none; }
    .cal-event             { transition: none; }
    .cal-event-enter       { animation: none; }
    .booking-drawer        { transition: none; }
    .cal-hour-clickable    { transition: none; }
    .cal-month-cell        { transition: none; }
    .cal-util-fill         { transition: none; }
    .cal-nav-btn           { transition: none; }
    .cal-nav-btn:active    { transform: none; }
    .cal-slot-btn          { transition: none; }
    .cal-slot-btn:active   { transform: none; }
}

/* ═══════════════════════════════════════════════════════════
   WEEK VIEW — EMPTY DAY STATE
═══════════════════════════════════════════════════════════ */

.cal-empty-day {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.cal-empty-day span {
    font-size: 11px;
    color: var(--text-3);
    letter-spacing: .03em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}
.cal-empty-day .cal-empty-hint {
    font-size: 9px;
    color: var(--text-2);
    margin-top: 4px;
    writing-mode: horizontal-tb;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE FAB — Fitts's Law: Ny booking in thumb zone on mobile
   Hidden on desktop (640px+). Fixed bottom-right on mobile.
═══════════════════════════════════════════════════════════ */

.cal-fab-mobile { display: none; }

@media (max-width: 639px) {
    .cal-fab-mobile {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        position: fixed;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
        right: 16px;
        z-index: 50;
        background: var(--accent);
        color: var(--text-on-accent);
        border: none;
        border-radius: 99px;
        padding: 0 20px;
        min-height: 52px;
        font-size: 14px;
        font-weight: 700;
        font-family: inherit;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-touch-callout: none;
        box-shadow: 0 4px 14px var(--accent-ring);
        transition: background .12s, transform .08s, box-shadow .12s;
    }
    .cal-fab-mobile:hover  { background: var(--accent-hover); }
    .cal-fab-mobile:active { transform: scale(0.96); box-shadow: 0 2px 8px var(--accent-ring); }
}

@media (prefers-reduced-motion: reduce) {
    .cal-fab-mobile { transition: none; }
}

/* ── Wizard step slide-in animation (Goal-Gradient / Zeigarnik) ── */
@keyframes wizard-step-enter {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
.wizard-step {
    animation: wizard-step-enter 220ms cubic-bezier(.25,.46,.45,.94) both;
}

/* ── Celebrate confetti burst (Peak-End Rule) ── */
@keyframes planna-celebrate {
    0%   { transform: scale(0.6) rotate(-10deg); opacity: 0; }
    55%  { transform: scale(1.25) rotate(6deg);  opacity: 1; }
    75%  { transform: scale(0.95) rotate(-3deg); }
    100% { transform: scale(1) rotate(0deg);     opacity: 1; }
}
.celebrate {
    display: inline-block;
    animation: planna-celebrate 600ms cubic-bezier(.34,1.56,.64,1) both;
    animation-delay: 80ms;
}

/* ── Slot picker buttons (Hick's Law / Fitts's Law) ── */
.cal-slot-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 8px;
    border: 1.5px solid var(--border-2);
    border-radius: var(--r-md);
    background: var(--surface-1);
    color: var(--text-1);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .12s, background .12s, transform .06s;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    width: 100%;
}
.cal-slot-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}
.cal-slot-btn:active { transform: scale(0.96); }

.cal-slot-btn--sel {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--text-on-accent);
    font-weight: 700;
}
.cal-slot-btn--sel:hover { background: var(--accent-hover); }

.cal-slot-btn--ai {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 600;
    position: relative;
}
.cal-slot-btn--ai::after {
    content: "✦";
    position: absolute;
    top: 4px;
    right: 5px;
    font-size: 7px;
    opacity: .7;
}

/* ── DayView empty column state ── */
.cal-col-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    pointer-events: none;
    width: 90%;
    text-align: center;
}
.cal-col-empty i {
    width: 18px;
    height: 18px;
    color: var(--text-3);
}
.cal-col-empty span {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-3);
}

/* ═══════════════════════════════════════════════════════════
   UTILITY CLASSES — replace inline styles in Day/Week View
═══════════════════════════════════════════════════════════ */

/* Time gutter column border */
.cal-time-gutter {
    border-right: 1px solid var(--border-2);
}

/* Hidden header placeholder (keeps column header height consistent) */
.cal-col-h--hidden {
    visibility: hidden;
}

/* Staff column header (no bottom padding) */
.cal-col-h--staff {
    padding-bottom: 0;
}

/* Small avatar image in day-view column header */
.cal-av-sm {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Small avatar initials circle in day-view column header */
.cal-av-sm-init {
    width: 26px;
    height: 26px;
    font-size: 10px;
    flex-shrink: 0;
}

/* Staff name label in day-view column header */
.cal-staff-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-1);
}

/* Week view day header inner layout */
.cal-day-header-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* Week view day header label (Mon, Tue, etc.) */
.cal-day-header-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
}
.cal-day-header-label--today {
    color: var(--accent);
}

/* Slot hover tooltip — shows duration hint before click */
.cal-slot:hover::before {
    content: '15 min';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-1);
    color: var(--bg-card);
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s;
    z-index: 10;
}
.cal-slot:hover::before {
    opacity: 1;
}

/* Mobile slot sizing — expand invisible hit area + visual quarter-hour dividers */
@media (max-width: 639px) {
    .cal-slot {
        position: relative;
    }
    .cal-slot::after {
        content: '';
        position: absolute;
        inset: -7px 0;
        z-index: 2;
    }
    /* Visual boundary between quarter-hour slots */
    .cal-slot + .cal-slot {
        border-top: 1px dashed var(--border-1);
    }
}

/* ═══════════════════════════════════════════════════════════
   MONTH VIEW — base layout (replaces inline styles)
═══════════════════════════════════════════════════════════ */

/* Month grid container */
.cal-month-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Header row (Mon-Sun) */
.cal-month-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border-2);
}

/* Header cell (Mon, Tue, etc.) */
.cal-month-header-cell {
    padding: var(--s1) var(--s2);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Week row (7 cells) */
.cal-month-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

/* Month cell (individual day) */
.cal-month-cell {
    min-height: clamp(70px, 12vw, 90px);
    padding: var(--s1) var(--s2);
    overflow: hidden;
    border-right: 1px solid var(--border-2);
    border-bottom: 1px solid var(--border-2);
    cursor: pointer;
    transition: background .1s;
}
.cal-month-cell:hover {
    background: var(--bg-elev);
}
.cal-month-cell--selected,
.cal-month-cell--selected:hover {
    background: var(--accent-subtle) !important;
}
.cal-month-cell--other-month {
    opacity: 0.35;
}

/* Day number wrapper (centered) */
.cal-month-day-num-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

/* Booking labels container */
.cal-month-labels {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Individual booking label */
.cal-month-label {
    color: var(--text-1);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Dot inside booking label (staff color) */
.cal-month-label-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

/* Text inside booking label */
.cal-month-label-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Overflow "+N more" text */
.cal-month-overflow {
    font-size: 10px;
    color: var(--text-3);
    padding-left: 4px;
}

/* Mobile dot row */
.cal-month-dots-row {
    display: none;
    gap: 3px;
    flex-wrap: wrap;
}

/* Individual dot in mobile row */
.cal-month-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    background: var(--dot-bg, var(--accent));
}

/* "+N" text in mobile dot row */
.cal-month-dots-more {
    font-size: 9px;
    color: var(--text-3);
}

/* ═══════════════════════════════════════════════════════════
   MONTH VIEW — entry animation (staggered per cell)
═══════════════════════════════════════════════════════════ */

@keyframes calMonthCellEnter {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: translateY(0);   }
}
.cal-month-cell-enter {
    animation: calMonthCellEnter 120ms cubic-bezier(.4,0,.2,1) both;
}

@media (prefers-reduced-motion: reduce) {
    .wizard-step    { animation: none; }
    .celebrate      { animation: none; }
    .cal-slot-btn   { transition: none; }
    .cal-slot-btn:active { transform: none; }
    .cal-month-cell       { transition: none; }
    .cal-month-cell-enter { animation: none; }
    .cal-list-item        { transition: none; }
    .cal-list-item-enter   { animation: none; }
}
