/* Simple Office: the Calendar page (calendar.js). Built on app.css's tokens, so it follows the light and dark theme. */
:root { --cal: #2563eb; --cal-soft: #e8effd; }
[data-bs-theme="dark"] { --cal: #7aa7ff; --cal-soft: rgba(122, 167, 255, .14); }
.tone-cal { --tone: var(--cal); --tone-soft: var(--cal-soft); }

.cal-toolbar { row-gap: 8px; }
.cal-title { font-size: 1.15rem; font-weight: 650; margin: 0 4px; white-space: nowrap; }
.cal-filter { min-width: 250px; }
.cal-filter .form-check { margin-bottom: 4px; }
.cal-team-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: .9rem; }
.cal-team-row input[type=color] { width: 28px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; flex-shrink: 0; }

/* chips: one line per item (month cells, all-day row, list) */
.cal-chip { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; border: 0; border-radius: 6px; padding: 1px 6px; margin-bottom: 2px;
  font-size: .78rem; line-height: 1.45; text-align: left; color: var(--text); cursor: pointer;
  background: color-mix(in srgb, var(--ev, var(--brand)) 14%, var(--surface)); border-left: 3px solid var(--ev, var(--brand)); }
.cal-chip:hover { background: color-mix(in srgb, var(--ev, var(--brand)) 24%, var(--surface)); }
.cal-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cal-chip b { font-weight: 600; flex-shrink: 0; }
.cal-chip i { flex-shrink: 0; opacity: .8; }
.cal-ev.tentative { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ev) 12%, var(--surface)) 0 6px, var(--surface) 6px 10px); }
.cal-ev.declined { opacity: .5; text-decoration: line-through; }
.cal-task { --ev: var(--projects); }
.cal-task.done span { text-decoration: line-through; opacity: .7; }
.cal-money { --ev: var(--polls); }

/* month */
.cal-month { overflow: hidden; }
.cal-mhead, .cal-mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-mhead div { padding: 8px; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.cal-mcell { min-height: 112px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.cal-mcell:nth-child(7n) { border-right: 0; }
.cal-mcell:nth-last-child(-n+7) { border-bottom: 0; }
.cal-mcell.other { background: var(--surface-2); }
.cal-mcell.other .cal-dnum { color: var(--muted); }
.cal-dnum { border: 0; background: none; font-size: .85rem; font-weight: 600; width: 26px; height: 26px; border-radius: 50%; color: var(--text); margin-bottom: 2px; padding: 0; }
.cal-dnum:hover { background: var(--brand-soft); }
.cal-mcell.today .cal-dnum { background: var(--brand); color: #fff; }
.cal-more { border: 0; background: none; font-size: .75rem; color: var(--brand-text); padding: 0 6px; font-weight: 600; }

/* week and day */
.cal-week { overflow: hidden; }
.cal-whead, .cal-wallday, .cal-wgrid { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); }
.cal-whead { border-bottom: 1px solid var(--line); }
.cal-wday { border: 0; background: none; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.cal-wday b { font-size: 1.25rem; color: var(--text); font-weight: 600; letter-spacing: 0; width: 36px; height: 36px; line-height: 36px; border-radius: 50%; }
.cal-wday:hover b { background: var(--brand-soft); }
.cal-wday.today { color: var(--brand-text); }
.cal-wday.today b { background: var(--brand); color: #fff; }
.cal-wallday { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal-wallday .cal-gutter { padding: 6px 4px; color: var(--muted); text-align: right; }
.cal-adcell { padding: 4px 3px; border-left: 1px solid var(--line); min-width: 0; cursor: pointer; }
.cal-wscroll { height: min(68vh, 760px); overflow-y: auto; position: relative; }
.cal-wgrid { position: relative; }
.cal-wgrid > .cal-gutter { position: relative; }
.cal-wgrid > .cal-gutter span { position: absolute; right: 8px; transform: translateY(-50%); font-size: .72rem; color: var(--muted); white-space: nowrap; }
.cal-wcol { position: relative; border-left: 1px solid var(--line); cursor: pointer;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px);
  background-size: 100% 48px, 100% 24px; }
.cal-wcol.today { background-color: color-mix(in srgb, var(--brand) 4%, transparent); }
.cal-block { position: absolute; border: 0; border-radius: 6px; padding: 3px 6px; text-align: left; overflow: hidden; display: flex; flex-direction: column; font-size: .76rem; line-height: 1.3;
  color: var(--text); background: color-mix(in srgb, var(--ev) 18%, var(--surface)); border-left: 3px solid var(--ev); box-shadow: var(--shadow-sm); cursor: pointer; z-index: 1; }
.cal-block:hover { background: color-mix(in srgb, var(--ev) 28%, var(--surface)); z-index: 2; }
.cal-block b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-block span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* list */
.cal-list { padding: 6px 0; }
.cal-lday { display: flex; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.cal-lday:last-child { border-bottom: 0; }
.cal-ldate { border: 0; background: none; width: 52px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: .75rem; padding: 0; }
.cal-ldate b { font-size: 1.35rem; color: var(--text); line-height: 1.2; }
.cal-lday.today .cal-ldate b { color: var(--brand-text); }
.cal-litems { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-top: 3px; }
.cal-lrow { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cal-lrow .cal-chip { width: auto; max-width: 100%; margin: 0; font-size: .85rem; padding: 3px 8px; }
.cal-ltime { width: 62px; flex-shrink: 0; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* event details and editor */
.cal-detail > div { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.cal-detail > div > i { color: var(--ev); margin-top: 2px; }
.cal-dwhen { font-weight: 600; }
.cal-dpeople > div { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-person { background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 1px 10px; font-size: .85rem; }
.cal-person small { color: var(--muted); }
.cal-person.resp-yes { border-color: color-mix(in srgb, var(--online) 50%, var(--line)); }
.cal-person.resp-no { opacity: .6; }
.cal-dnotes { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; display: block !important; }
.cal-respond { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.cal-respond span { margin-right: auto; }
.cal-plist { max-height: 210px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px; }

/* bookings */
.bk-list { overflow: hidden; }
.bk-day { padding: 10px 16px 6px; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.bk-row { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.bk-row:last-child { border-bottom: 0; }
.bk-row.cancelled { opacity: .65; }
.bk-time { width: 58px; flex-shrink: 0; font-weight: 650; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; }
.bk-time small { color: var(--muted); font-weight: 400; }
.bk-note { white-space: pre-wrap; margin-top: 2px; }
.bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.bk-grid > .bk-sec:nth-child(-n+2) { grid-column: 1 / -1; }
.bk-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bk-pad { padding: 4px 18px 18px; }
.bk-link { display: flex; align-items: center; gap: 10px; background: var(--brand-soft); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 14px; min-width: 0; }
.bk-link a { min-width: 0; flex-grow: 1; font-weight: 600; }
.bk-base { max-width: 45%; }
.bk-svc { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; }
.bk-day-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.bk-day-row:last-child { border-bottom: 0; }
.bk-dname { width: 120px; flex-shrink: 0; margin: 4px 0 0; }
.bk-ranges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 31px; }
.bk-range { display: inline-flex; align-items: center; gap: 4px; }
.bk-range input { width: 124px; }
.bk-offrow { display: flex; gap: 6px; margin-bottom: 6px; }
.bk-offrow input[type=date] { width: 160px; flex-shrink: 0; }
.bk-save { position: sticky; bottom: calc(var(--bottom-h) + 8px); display: flex; gap: 12px; align-items: center; margin-top: 16px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 5; }

@media (max-width: 991.98px) {
  .bk-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 699.98px) {
  .cal-toolbar .cal-title { order: -1; width: 100%; margin: 0; }
  .cal-mcell { min-height: 76px; padding: 2px; }
  .cal-mcell .cal-chip { font-size: 0; padding: 0; height: 6px; border-left-width: 0; background: var(--ev); margin: 1px 0; }
  .cal-mcell .cal-chip * { display: none; }
  .cal-more { font-size: .68rem; padding: 0 2px; }
  .cal-whead, .cal-wallday, .cal-wgrid { grid-template-columns: 40px repeat(var(--days), minmax(0, 1fr)); }
  .cal-wday { font-size: .65rem; }
  .cal-wday b { font-size: 1rem; width: 28px; height: 28px; line-height: 28px; }
  .cal-block { padding: 2px 3px; font-size: .68rem; }
  .cal-block span { display: none; }
  .bk-day-row { flex-direction: column; gap: 4px; }
  .bk-range input { width: 118px; }
  .bk-base { display: none; }
}

/* the dashboard card */
.cal-dash-tile { flex-direction: column; line-height: 1; gap: 1px; background: color-mix(in srgb, var(--ev) 14%, var(--surface)); color: var(--ev); border-left: 3px solid var(--ev); }
.cal-dash-tile b { font-size: 1rem; }
.cal-dash-tile small { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; }
#dash-events .row-time { text-align: right; line-height: 1.35; }
.cal-ask { color: var(--polls); font-weight: 600; }
.row-more { display: block; text-align: center; font-size: .85rem; padding: 8px; color: var(--brand-text); }
