/* ============================================================
   Orbit Appointments — Calendar view styles
   Scoped to .orbit-appts — ported from Calendar Prototype/app.css
   All prototype .tg-* / .appt / .slot-* selectors renamed to .cal-*
   ============================================================ */

/* ---- page scaffold ---- */
.orbit-appts .cal-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.orbit-appts .cal-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.orbit-appts .cal-toolbar .cal-tb-left,
.orbit-appts .cal-toolbar .cal-tb-center,
.orbit-appts .cal-toolbar .cal-tb-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.orbit-appts .cal-toolbar .cal-tb-center {
    flex: 1;
}

/* location autocomplete — accessible combobox replacing the native <select> */
.orbit-appts .cal-loc-autocomplete {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface-3);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    min-width: 220px;
    transition: border-color var(--dur-fast, 150ms) ease;
}

.orbit-appts .cal-loc-autocomplete:focus-within {
    border-color: rgba(var(--primary-rgb), 0.3);
}

.orbit-appts .cal-loc-icon {
    color: var(--fg-3);
    font-size: 14px;
    flex-shrink: 0;
}

.orbit-appts .cal-loc-input {
    border: none;
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-1);
    outline: none;
    flex: 1;
    min-width: 0;
}

.orbit-appts .cal-loc-clear {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    color: var(--fg-3);
    font-size: 12px;
    flex-shrink: 0;
}

.orbit-appts .cal-loc-clear:hover {
    background: var(--border-input);
    color: var(--fg-1);
}

.orbit-appts .cal-loc-results {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.orbit-appts .cal-loc-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.3;
    border-bottom: 1px solid var(--border);
}

.orbit-appts .cal-loc-item:last-child {
    border-bottom: none;
}

.orbit-appts .cal-loc-item:hover,
.orbit-appts .cal-loc-item.is-active {
    background: rgba(var(--primary-rgb), 0.06);
}

.orbit-appts .cal-loc-item .cal-loc-sub {
    font-size: 11px;
    color: var(--fg-3);
}

.orbit-appts .cal-loc-status {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--fg-3);
}

/* date navigation */
.orbit-appts .cal-nav-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-input);
    background: var(--bg-surface);
    color: var(--fg-2);
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--dur-fast, 150ms) ease;
}

.orbit-appts .cal-nav-btn:hover {
    background: var(--bg-surface-3);
    color: var(--fg-1);
}

.orbit-appts .cal-nav-btn:disabled,
.orbit-appts .cal-today-btn:disabled,
.orbit-appts .cal-seg:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.orbit-appts .cal-nav-btn:disabled:hover,
.orbit-appts .cal-today-btn:disabled:hover,
.orbit-appts .cal-seg:disabled:hover {
    background: inherit;
    color: inherit;
}

.orbit-appts .cal-date-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 2px 10px;
    min-width: 180px;
    border-radius: var(--radius-md);
}

.orbit-appts .cal-date-label .dl-main {
    font-weight: 600;
    font-size: 13px;
    color: var(--fg-1);
}

.orbit-appts .cal-date-label .dl-hint {
    font-weight: 500;
    font-size: 12px;
    color: var(--fg-2);
}

.orbit-appts .cal-today-btn {
    font-size: 12px;
    font-weight: 500;
    padding: 7px 12px;
    border: 1px solid var(--border-input);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    color: var(--fg-2);
    cursor: pointer;
    transition: background var(--dur-fast, 150ms) ease;
}

.orbit-appts .cal-today-btn:hover {
    background: var(--bg-surface-3);
    color: var(--fg-1);
}

/* segmented control (Day / Week) */
.orbit-appts .cal-seg-ctl {
    display: flex;
    padding: 3px;
    background: var(--bg-surface-3);
    border-radius: var(--radius-md);
    gap: 2px;
}

.orbit-appts .cal-seg {
    border: 0;
    background: transparent;
    padding: 6px 14px;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--fg-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.orbit-appts .cal-seg-on {
    background: var(--bg-surface);
    color: var(--fg-1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
}

/* ============================================================
   FILTER BAR (provider chips + status legend)
   ============================================================ */
.orbit-appts .cal-filterbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--fg-2);
}

/* provider chips */
.orbit-appts .cal-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.orbit-appts .cal-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px 5px 5px;
    border-radius: var(--radius-chip, 999px);
    background: var(--bg-surface);
    border: 1px solid var(--border-input);
    font-size: 12px;
    font-weight: 500;
    color: var(--fg-2);
    cursor: pointer;
    transition: all 150ms ease;
}

.orbit-appts .cal-chip-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
}

.orbit-appts .cal-chip-off {
    opacity: 0.50;
}

.orbit-appts .cal-chip-off .cal-chip-dot {
    filter: grayscale(0.7);
}

.orbit-appts .cal-chip-on {
    border-color: transparent;
    color: var(--fg-1);
}

.orbit-appts .cal-chip:hover {
    border-color: rgba(var(--primary-rgb), 0.3);
}

/* status legend */
.orbit-appts .cal-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-left: auto;
}

.orbit-appts .cal-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--fg-2);
}

.orbit-appts .cal-legend-sw {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* week-view provider picker */
.orbit-appts .cal-provider-picker {
    padding: 6px 10px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    background: var(--bg-surface-3);
    font: inherit;
    font-size: 12px;
    color: var(--fg-1);
    outline: none;
    cursor: pointer;
    min-width: 200px;
}

/* ============================================================
   TIME GRID  (.tg → .cal-grid)
   ============================================================ */
.orbit-appts .cal-grid {
    --cal-px-hour: 56px;
    --cal-gutter: 60px;
    display: grid;
    flex: 1;
    min-height: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: auto;
    align-content: start;
}

.orbit-appts .cal-grid-head {
    display: grid;
    position: sticky;
    top: 0;
    z-index: 12;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.orbit-appts .cal-grid-head .cal-gutter-corner {
    border-right: 1px solid var(--border);
}

/* column header cell */
.orbit-appts .cal-col-head {
    padding: 10px 12px;
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.orbit-appts .cal-col-head:last-child {
    border-right: 0;
}

/* provider avatar in column head */
.orbit-appts .cal-col-head .pav {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}

.orbit-appts .cal-col-head .ch-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.orbit-appts .cal-col-head .ch-name {
    font-weight: 600;
    font-size: 12.5px;
    color: var(--fg-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.orbit-appts .cal-col-head .ch-sub {
    font-size: 10.5px;
    color: var(--fg-3);
}

/* day-mode column head (week view) */
.orbit-appts .cal-col-head.dayhead {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.orbit-appts .cal-col-head.dayhead.today {
    background: rgba(var(--primary-rgb), 0.05);
}

.orbit-appts .cal-col-head .dh-dow {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-3);
}

.orbit-appts .cal-col-head .dh-num {
    font-size: 18px;
    font-weight: 600;
    color: var(--fg-1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.orbit-appts .cal-col-head.dayhead.today .dh-num {
    color: rgb(var(--primary-rgb));
}

.orbit-appts .cal-col-head .dh-count {
    font-size: 10px;
    font-weight: 600;
    color: #1b8a68;
    background: rgba(38, 191, 148, 0.12);
    padding: 1px 7px;
    border-radius: var(--radius-chip, 999px);
}

/* grid body — gutter + columns */
.orbit-appts .cal-grid-body {
    display: grid;
    position: relative;
}

.orbit-appts .cal-gutter {
    position: relative;
    border-right: 1px solid var(--border);
    background: var(--bg-surface);
    width: var(--cal-gutter);
}

.orbit-appts .cal-gutter-label {
    position: absolute;
    right: 8px;
    transform: translateY(-50%);
    font-size: 10.5px;
    font-family: var(--font-mono);
    color: var(--fg-3);
    white-space: nowrap;
}

/* column body */
.orbit-appts .cal-col {
    position: relative;
    border-right: 1px solid var(--border);
}

.orbit-appts .cal-col:last-child {
    border-right: 0;
}

/* hour / half-hour lines */
.orbit-appts .cal-hour-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
}

.orbit-appts .cal-half-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed rgba(0, 0, 0, 0.035);
}

/* off-hours shading */
.orbit-appts .cal-offhours {
    position: absolute;
    left: 0;
    right: 0;
    background: repeating-linear-gradient(45deg,
            rgba(0, 0, 0, 0.012) 0 6px,
            rgba(0, 0, 0, 0.030) 6px 12px);
}

/* closed column */
.orbit-appts .cal-col.closed {
    background: var(--bg-surface-2);
}

.orbit-appts .cal-col-closed-note {
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--fg-3);
    font-size: 11px;
    font-weight: 500;
}

/* ============================================================
   CURRENT-TIME INDICATOR  (.now-line → .cal-now-line)
   ============================================================ */
.orbit-appts .cal-now-line {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 8;
    pointer-events: none;
}

.orbit-appts .cal-now-line::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    border-top: 2px solid var(--danger, #e6533c);
}

.orbit-appts .cal-now-dot {
    position: absolute;
    left: -4px;
    top: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger, #e6533c);
}

/* ============================================================
   APPOINTMENT BLOCK  (.appt → .cal-appt)
   ============================================================ */
.orbit-appts .cal-appt {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: var(--radius-sm);
    padding: 4px 7px 4px 9px;
    overflow: hidden;
    border: 1px solid rgba(var(--cal-slot-rgb), 0.30);
    background: rgba(var(--cal-slot-rgb), 0.10);
    border-left: 3px solid rgb(var(--cal-slot-rgb));
    transition: box-shadow 150ms ease, transform 150ms ease;
    z-index: 4;
}

.orbit-appts .cal-appt:hover {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}

.orbit-appts .cal-appt .a-time {
    font-size: 9.5px;
    font-family: var(--font-mono);
    color: rgba(var(--cal-slot-rgb), 0.95);
    font-weight: 600;
    line-height: 1.1;
}

.orbit-appts .cal-appt .a-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-1);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.orbit-appts .cal-appt .a-meta {
    font-size: 10.5px;
    color: var(--fg-2);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
}

.orbit-appts .slot-modality {
    display: inline-flex;
    flex: 0 0 12px;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    color: var(--fg-2);
}

.orbit-appts .slot-service-type {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.orbit-appts .a-compact,
.orbit-appts .so-compact,
.orbit-appts .so-primary {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.orbit-appts .a-compact,
.orbit-appts .so-compact {
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1;
}

.orbit-appts .cal-appt.tiny {
    display: flex;
    align-items: center;
    padding: 0 6px 0 8px;
}

.orbit-appts .cal-appt.tiny .a-name {
    font-size: 11px;
}

.orbit-appts .cal-appt.tiny .a-time {
    flex-shrink: 0;
}

/* status overlays */
.orbit-appts .cal-appt.cal-st-completed {
    opacity: 0.62;
}

.orbit-appts .cal-appt.cal-st-cancelled {
    opacity: 0.7;
}

.orbit-appts .cal-appt.cal-st-cancelled .a-name {
    text-decoration: line-through;
    text-decoration-color: var(--danger, #e6533c);
}

.orbit-appts .cal-appt.cal-st-cancelled,
.orbit-appts .cal-appt.cal-st-noshow {
    background: repeating-linear-gradient(45deg,
            rgba(230, 83, 60, 0.05) 0 7px,
            rgba(230, 83, 60, 0.12) 7px 14px);
    border-color: rgba(230, 83, 60, 0.4);
    border-left-color: var(--danger, #e6533c);
}

.orbit-appts .cal-appt.cal-st-checkedin {
    box-shadow: inset 3px 0 0 rgb(73, 182, 245);
}

/* ============================================================
   AVAILABLE SLOT  (.slot-open → .cal-slot-open)
   ============================================================ */
.orbit-appts .cal-slot-open {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: var(--radius-sm);
    border: 1.5px dashed rgba(38, 191, 148, 0.55);
    background: rgba(38, 191, 148, 0.07);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #1b8a68;
    gap: 1px;
    z-index: 3;
}

.orbit-appts .cal-slot-open .so-time {
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.orbit-appts .cal-slot-open .so-label {
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}

.orbit-appts .cal-slot-open:not(.tiny) .so-primary {
    justify-content: center;
}

.orbit-appts .cal-slot-open > .slot-service-type {
    max-width: 100%;
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1;
}

.orbit-appts .cal-slot-open.tiny {
    padding: 0 3px;
}

.orbit-appts .cal-slot-open.tiny .so-compact {
    justify-content: center;
    width: 100%;
}

.orbit-appts .cal-slot-open.tiny .so-label {
    display: none;
}

/* ============================================================
   BLOCKED SLOT  (.slot-block → .cal-slot-block)
   ============================================================ */
.orbit-appts .cal-slot-block {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: var(--radius-sm);
    background: repeating-linear-gradient(45deg,
            rgba(121, 135, 161, 0.06) 0 6px,
            rgba(121, 135, 161, 0.14) 6px 12px);
    border: 1px solid rgba(121, 135, 161, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--fg-3);
    font-size: 10.5px;
    font-weight: 500;
    z-index: 2;
}

/* ============================================================
   DAY SUMMARY BAR  (.day-summary / .ds-card → .cal-summary / .cal-metric)
   ============================================================ */
.orbit-appts .cal-summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 20px 0;
}

.orbit-appts .cal-metric {
    flex: 1;
    min-width: 130px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.orbit-appts .cal-metric-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.orbit-appts .cal-metric-num {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--fg-1);
}

.orbit-appts .cal-metric-label {
    font-size: 11px;
    color: var(--fg-3);
    margin-top: 2px;
}

/* ============================================================
   SCROLL AREA
   ============================================================ */
.orbit-appts .cal-scroll {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-page, var(--bg-surface-2));
}

.orbit-appts .cal-inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 14px 20px 32px;
}

.orbit-appts .cal-state {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    color: var(--fg-2);
    padding: 18px 20px;
    font-size: 13px;
    font-weight: 500;
}

.orbit-appts .cal-state-loading {
    color: var(--fg-1);
}

.orbit-appts .cal-state-error {
    border-color: rgba(230, 83, 60, 0.28);
    background: rgba(230, 83, 60, 0.06);
    color: var(--danger, #e6533c);
}

.orbit-appts .cal-state-partial {
    margin-bottom: 12px;
    border-color: rgba(var(--primary-rgb), 0.25);
    background: rgba(var(--primary-rgb), 0.06);
    color: var(--fg-1);
}

.orbit-appts .cal-detail-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.24);
    z-index: 40;
}

.orbit-appts .cal-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(420px, 100vw);
    height: 100vh;
    background: var(--bg-surface);
    box-shadow: -12px 0 32px rgba(15, 23, 42, 0.16);
    z-index: 41;
    display: flex;
    flex-direction: column;
}

.orbit-appts .cd-head,
.orbit-appts .cd-foot {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.orbit-appts .cd-foot {
    border-bottom: 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.orbit-appts .cd-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.orbit-appts .cd-time {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--fg-2);
    font-weight: 600;
}

.orbit-appts .cd-close {
    border: 0;
    background: transparent;
    color: var(--fg-2);
    cursor: pointer;
    font-size: 16px;
}

.orbit-appts .cd-body {
    padding: 20px 18px;
    overflow: auto;
}

.orbit-appts .cd-name {
    margin: 0 0 18px;
    font-size: 22px;
    line-height: 1.2;
    color: var(--fg-1);
}

.orbit-appts .cd-fields {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 10px 12px;
    margin: 0;
}

.orbit-appts .cd-fields dt {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-3);
}

.orbit-appts .cd-fields dd {
    margin: 0;
    font-size: 13px;
    color: var(--fg-1);
}

.orbit-appts .cd-loading {
    color: var(--fg-2);
}

.orbit-appts .cd-error {
    color: var(--danger, #e6533c);
}

.orbit-appts .cd-manage {
    width: 100%;
    border: 0;
    border-radius: var(--radius-md);
    background: rgb(var(--primary-rgb));
    color: white;
    padding: 11px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
