/* Stone Surgeons CRM — Schedule → Calendar (crm/calendar.js): Month / Week / Day.
   Pearl-glass look to match glass.css (its :root tokens: --glass, --edge, --smoke, --shadow, --blur, --line, --ink, --muted).
   Event colour comes from --ev-c (the first crew member's rep colour). --cal-hour must match HOUR in calendar.js. */

/* ── toolbar ── */
.cal-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.cal-nav { display: flex; gap: 6px; }
.cal-arrow { min-width: 40px; font-size: 18px; line-height: 1; }
.cal-title { flex: 1 1 220px; margin: 0; font-size: 20px; letter-spacing: -.02em; }
.cal-title .muted { font-size: 14px; font-weight: 400; letter-spacing: 0; }
.cal-bar .in { width: auto; min-width: 150px; padding: 9px 10px; }
.cal-seg {
  display: inline-flex; gap: 3px; padding: 4px; border-radius: 16px;
  background: rgba(255, 255, 255, .26); border: 1px solid var(--edge); border-bottom-color: var(--edge-dim);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 6px 16px rgba(55, 65, 80, .08);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
}
.cal-seg-b { border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; padding: 7px 16px; border-radius: 12px; cursor: pointer; }
.cal-seg-b:hover { background: rgba(255, 255, 255, .45); }
.cal-seg-b.on { background: var(--smoke); color: #fff; }
.cal-seg-b:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.cal-help { margin-top: 10px; }

/* ── layout: "Needs a date" on the left, the calendar beside it ── */
.cal { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; align-items: start; }
.cal-main { min-width: 0; }
.cal-side { order: -1; }
.cal-month, .cal-tg, .cal-aday {
  background: var(--glass); border: 1px solid var(--edge); border-bottom-color: var(--edge-dim); box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}

/* ── chips (month, all-day row, agenda, sidebar) ── */
.cal-chip {
  display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 12px; line-height: 1.25; padding: 3px 6px; border-radius: 8px; color: var(--ink);
  background: rgba(255, 255, 255, .6); background: color-mix(in srgb, var(--ev-c) 12%, rgba(255, 255, 255, .64));
  border: 1px solid rgba(255, 255, 255, .78); border-left: 3px solid var(--ev-c); cursor: pointer; user-select: none;
}
.cal-chip:hover { background: color-mix(in srgb, var(--ev-c) 20%, rgba(255, 255, 255, .78)); }
.cal-chip-t { font-weight: 700; white-space: nowrap; }
.cal-chip-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cal-chip-s { flex-basis: 100%; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ev-c); flex: none; }
.cal-s-cancelled { opacity: .55; text-decoration: line-through; }
.cal-s-completed .cal-chip-n::before, .cal-ev.cal-s-completed strong::before { content: "✓ "; }
.cal-s-in_progress { box-shadow: inset 0 0 0 1px var(--ev-c); }
.cal-chip:focus-visible, .cal-ev:focus-visible, .cal-more:focus-visible, .cal-dh-b:focus-visible, .cal-add:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.cal-chip.dragging, .cal-ev.dragging { opacity: .35; }
.cal-side .cal-chip, .cal-agenda .cal-chip { flex-wrap: wrap; font-size: 13px; padding: 6px 8px; border-radius: 10px; }
.cal-add { text-decoration: none; font-weight: 800; font-size: 16px; line-height: 1; padding: 3px 8px; border-radius: 8px; color: var(--ink); }
.cal-add:hover { background: rgba(255, 255, 255, .5); }

/* ── Month ── */
.cal-month { border-radius: 22px; overflow: hidden; }
.cal-mrow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd { padding: 9px 10px 7px; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cal-cell { min-height: 112px; min-width: 0; padding: 6px 6px 8px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.cal-mrow > .cal-cell:first-child { border-left: 0; }
.cal-cell:hover { background: rgba(255, 255, 255, .2); }
.cal-cell.out { background: rgba(60, 70, 85, .04); }
.cal-cell.out .cal-dnum { opacity: .45; }
.cal-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }
.cal-cell-h { display: flex; align-items: center; justify-content: space-between; }
.cal-dnum { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; font-size: 13px; font-weight: 650; box-sizing: border-box; }
.cal-cell.today .cal-dnum { background: var(--smoke); color: #fff; }
.cal-cell.today { background: rgba(255, 255, 255, .24); }
.cal-cell .cal-add { opacity: 0; }
.cal-cell:hover .cal-add, .cal-cell:focus-within .cal-add { opacity: 1; }
.cal-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-more { align-self: flex-start; border: 0; background: none; font: inherit; font-size: 12px; font-weight: 650; color: var(--blue); padding: 1px 4px; border-radius: 6px; cursor: pointer; }
.cal-more:hover { background: rgba(255, 255, 255, .5); }

/* ── Week + Day time grid ── */
.cal-tg { --cal-hour: 44px; border-radius: 22px; overflow: hidden; }
.cal-trow { display: grid; grid-template-columns: 56px repeat(var(--cal-days), minmax(0, 1fr)); }
.cal-thead { border-bottom: 1px solid var(--line); }
.cal-dh { display: flex; align-items: center; justify-content: space-between; gap: 2px; padding: 6px 6px 6px 8px; border-left: 1px solid var(--line); min-width: 0; }
.cal-dh-b { border: 0; background: none; font: inherit; color: var(--ink); display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 10px; min-width: 0; white-space: nowrap; }
button.cal-dh-b { cursor: pointer; }
button.cal-dh-b:hover { background: rgba(255, 255, 255, .45); }
.cal-dh-b span { font-size: 13px; color: var(--muted); }
.cal-dh-b b { font-size: 18px; line-height: 26px; min-width: 26px; text-align: center; border-radius: 13px; padding: 0 4px; }
.cal-dh.today .cal-dh-b b { background: var(--smoke); color: #fff; }
.cal-dh .cal-add { opacity: .75; }
.cal-allday { border-bottom: 1px solid var(--line); }
.cal-allday .cal-gut { font-size: 11px; color: var(--muted); padding: 9px 8px 0 0; text-align: right; }
.cal-ad { border-left: 1px solid var(--line); padding: 4px; min-height: 30px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-scroll { max-height: calc(var(--cal-hour) * 15 + 1px); overflow-y: auto; overscroll-behavior: contain; }
.cal-scroll:focus { outline: none; }
.cal-body { height: calc(var(--cal-hour) * 24); }
.cal-hours { position: relative; }
.cal-hl { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.cal-col {
  position: relative; min-width: 0; border-left: 1px solid var(--line); cursor: cell;
  background-image:
    repeating-linear-gradient(to bottom, rgba(40, 50, 65, .12) 0 1px, transparent 1px var(--cal-hour)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--cal-hour) / 2), rgba(40, 50, 65, .05) calc(var(--cal-hour) / 2) calc(var(--cal-hour) / 2 + 1px), transparent calc(var(--cal-hour) / 2 + 1px) var(--cal-hour));
}
.cal-col.today { background-color: rgba(255, 255, 255, .16); }
.cal-ev {
  position: absolute; box-sizing: border-box; overflow: hidden; z-index: 1; display: flex; flex-direction: column; gap: 1px;
  padding: 3px 6px; border-radius: 9px; font-size: 12px; line-height: 1.25; color: var(--ink); cursor: pointer; user-select: none;
  background: rgba(255, 255, 255, .72); background: color-mix(in srgb, var(--ev-c) 16%, rgba(255, 255, 255, .74));
  border: 1px solid rgba(255, 255, 255, .85); border-left: 4px solid var(--ev-c); box-shadow: 0 4px 12px rgba(55, 65, 80, .12);
}
.cal-ev:hover, .cal-ev:focus-visible { z-index: 3; box-shadow: 0 8px 20px rgba(55, 65, 80, .22); }
.cal-ev-t { font-weight: 700; font-size: 11px; white-space: nowrap; }
.cal-ev strong, .cal-ev-s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev-s { color: var(--muted); font-size: 11px; }
.cal-ev-short { flex-direction: row; align-items: center; gap: 5px; padding-top: 0; padding-bottom: 0; }
.cal-ev-plan { position: absolute; top: 2px; right: 5px; font-weight: 800; font-size: 12px; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: #c92a2a; z-index: 4; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #c92a2a; }

/* ── Week on a phone: agenda ── */
.cal-agenda { display: flex; flex-direction: column; gap: 10px; }
.cal-aday { border-radius: 20px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.cal-aday.today { box-shadow: inset 0 3px 0 #2a3038, var(--shadow); }
.cal-aday-h { display: flex; align-items: center; justify-content: space-between; }
.cal-aday-h .cal-dh-b { font-size: 15px; padding: 4px 6px; }
.cal-none { margin: 0; padding: 0 6px 4px; }

@media (max-width: 760px) {
  .cal { grid-template-columns: 1fr; }
  .cal-side { order: 1; position: static; min-height: 0; }
  .cal-title { order: -1; flex-basis: 100%; font-size: 18px; }
  .cal-seg { flex: 1 1 100%; }
  .cal-seg-b { flex: 1; padding: 9px 6px; }
  .cal-bar .in { flex: 1 1 40%; min-width: 0; }
  .cal-cell { min-height: 58px; padding: 3px; gap: 2px; }
  .cal-wd { padding: 7px 2px; text-align: center; letter-spacing: 0; }
  .cal-dnum { min-width: 22px; height: 22px; font-size: 12px; padding: 0 4px; }
  .cal-cell-h { justify-content: center; }
  .cal-cell .cal-add { display: none; }
  .cal-month .cal-chips { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .cal-month .cal-chip { padding: 0; border: 0; background: none; box-shadow: none; }
  .cal-month .cal-chip-t, .cal-month .cal-chip-n { display: none; }
  .cal-month .cal-dot { display: block; }
  .cal-more { font-size: 10px; padding: 0 2px; }
  .cal-trow { grid-template-columns: 44px repeat(var(--cal-days), minmax(0, 1fr)); }
  .cal-hl { right: 5px; font-size: 10px; }
  .cal-scroll { max-height: 62vh; }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .cal-month, .cal-tg, .cal-aday, .cal-seg { background: rgba(246, 247, 249, .94); }
}
@media (prefers-reduced-transparency: reduce) {
  .cal-month, .cal-tg, .cal-aday, .cal-seg { background: #f6f7f9; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (forced-colors: active) {
  .cal-chip, .cal-ev { border: 1px solid CanvasText; }
  .cal-seg-b.on, .cal-cell.today .cal-dnum, .cal-dh.today .cal-dh-b b { background: Highlight; color: HighlightText; }
  .cal-now { background: Highlight; }
}
