/* Meeting Booking — Notion-style weekly calendar, no external calendar lib.
   Scoped by the .mb- class prefix. Africa/Johannesburg (SAST) throughout. */

.mb-root {
  --mb-green: #1f4b2f;
  --mb-green-soft: #2f6b45;
  --mb-border: #e3e6e2;
  --mb-mine: #2f6b45;
  --mb-mine-soft: #e6f2ea;
  --mb-blocked: #b42318;
  --mb-slot-h: 30px;
  --mb-time-w: 58px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  color: #1c241d;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.mb-muted { color: #8a948b; }

/* Header / toolbar */
.mb-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px; justify-content: space-between;
}
.mb-toolbar-left { display: flex; align-items: center; gap: 14px; }
.mb-toolbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mb-title { font-size: 20px; font-weight: 700; color: var(--mb-green); margin: 0; }
.mb-tabs { display: flex; gap: 6px; }
.mb-tab {
  border: 1px solid var(--mb-border); background: #fff; color: #37433a;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mb-tab.is-active { background: var(--mb-green); color: #fff; border-color: var(--mb-green); }

/* Drag-mode switch */
.mb-modeswitch { display: inline-flex; align-items: center; gap: 6px; background: #f4f7f4; border: 1px solid var(--mb-border); border-radius: 999px; padding: 3px 4px 3px 12px; }
.mb-mode-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6a766d; }
.mb-mode { border: none; background: transparent; color: #37433a; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.mb-mode.is-on { background: var(--mb-green); color: #fff; }
.mb-mode:nth-of-type(2).is-on { background: var(--mb-blocked); }

.mb-weeknav { display: flex; align-items: center; gap: 8px; }
.mb-btn {
  border: 1px solid var(--mb-border); background: #fff; color: #37433a;
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mb-btn:hover { background: #f4f7f4; }
.mb-btn-icon { padding: 7px 11px; font-size: 15px; line-height: 1; }
.mb-btn-primary { background: var(--mb-green); color: #fff; border-color: var(--mb-green); }
.mb-btn-primary:hover { background: var(--mb-green-soft); }
.mb-btn-danger { color: #b42318; border-color: #f0c4c0; }
.mb-weeklabel { font-size: 14px; font-weight: 600; min-width: 180px; text-align: center; }

/* People picker */
.mb-people { border: 1px solid var(--mb-border); border-radius: 10px; padding: 12px 14px; background: #fbfcfb; }
.mb-people-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #6a766d; margin-bottom: 8px; }
.mb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mb-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--mb-border); background: #fff; color: #37433a;
  padding: 5px 11px; border-radius: 999px; font-size: 13px; user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.mb-chip.is-on { font-weight: 600; }
.mb-chip .mb-dot { width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; flex: none; }

/* Legend */
.mb-hint { font-size: 12.5px; color: #6a766d; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.mb-legend { display: inline-flex; align-items: center; gap: 8px; }
.mb-legend-person { display: inline-flex; align-items: center; gap: 5px; }
.mb-legend .mb-sw { width: 12px; height: 12px; border-radius: 3px; }
.mb-sw.mine { background: var(--mb-mine); }
.mb-sw.busy { background: repeating-linear-gradient(45deg, #e2e8f0, #e2e8f0 4px, #cbd5e1 4px, #cbd5e1 8px); }
.mb-sw.blocked { background: repeating-linear-gradient(45deg, #f4d3cf, #f4d3cf 4px, #e9b7b1 4px, #e9b7b1 8px); }

/* Approvals bar (#177) — meetings booked FOR you, awaiting your call */
.mb-approvals { border: 1px solid #efe2b8; background: #fbf6e3; border-radius: 10px; padding: 12px 14px; }
.mb-approvals-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #8a7a3a; margin-bottom: 8px; }
.mb-approval-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 8px 0; border-top: 1px solid rgba(138, 122, 58, .18);
}
.mb-approval-row:first-of-type { border-top: none; }
.mb-approval-main { flex: 1; min-width: 180px; }
.mb-approval-title { font-size: 14px; font-weight: 600; }
.mb-approval-when { font-size: 12.5px; color: #6a766d; }
.mb-approval-actions { display: flex; gap: 8px; margin-left: auto; }

/* Calendar grid */
.mb-cal-wrap { border: 1px solid var(--mb-border); border-radius: 12px; overflow: hidden; background: #fff; }
.mb-cal-scroll { max-height: min(66vh, 720px); overflow: auto; }
.mb-grid { min-width: 720px; }

.mb-grid-head {
  display: grid; grid-template-columns: var(--mb-time-w) repeat(7, 1fr);
  border-bottom: 1px solid var(--mb-border); background: #f7faf7;
  position: sticky; top: 0; z-index: 6;
}
.mb-grid-head > div {
  padding: 8px 4px; text-align: center; font-size: 12px; font-weight: 600; color: #47554b;
  border-left: 1px solid var(--mb-border);
}
.mb-head-corner { border-left: none !important; }
.mb-head-day .mb-head-num { font-size: 15px; font-weight: 700; color: #1c241d; display: block; }
.mb-head-day.is-today .mb-head-num { color: #fff; background: var(--mb-green); border-radius: 999px; width: 26px; height: 26px; line-height: 26px; margin: 2px auto 0; }

.mb-grid-body { display: grid; grid-template-columns: var(--mb-time-w) repeat(7, 1fr); position: relative; }
.mb-timecol { border-right: 1px solid var(--mb-border); }
.mb-timelabel { height: var(--mb-slot-h); font-size: 11px; color: #8a948b; text-align: right; padding-right: 6px; transform: translateY(-6px); }
.mb-daycol { position: relative; border-left: 1px solid var(--mb-border); }
.mb-slot { height: var(--mb-slot-h); border-bottom: 1px dashed #eef1ee; box-sizing: border-box; }
.mb-slot.mb-slot-hour { border-bottom: 1px solid #e3e6e2; }
.mb-daycol.is-today { background: #f6fbf7; }

/* Availability lane bars (per selected person, left edge) */
.mb-availbar { position: absolute; width: 5px; border-radius: 3px; opacity: .9; z-index: 2; pointer-events: none; }

/* Current-time indicator */
.mb-nowline { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 4; pointer-events: none; }
.mb-nowline::before { content: ''; position: absolute; left: -1px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; }

/* Blocks */
.mb-block {
  position: absolute; right: 3px; border-radius: 6px; padding: 3px 6px;
  font-size: 11px; line-height: 1.25; overflow: hidden; box-sizing: border-box; z-index: 3;
}
.mb-block-busy {
  background: repeating-linear-gradient(45deg, #e2e8f0, #e2e8f0 6px, #cbd5e1 6px, #cbd5e1 12px);
  border: 1px solid #b6c2cf; color: #52606d; z-index: 2;
}
/* A colleague's block carries a 3px left edge in THEIR colour (set inline) —
   with one column per person that stripe is the "whose diary is this" cue. */
.mb-block-busy { cursor: pointer; }
.mb-block-mine { background: var(--mb-mine); color: #fff; cursor: grab; }
.mb-block-mine.is-dragging { opacity: .8; cursor: grabbing; z-index: 20; }
.mb-block-mine .mb-block-time { opacity: .85; font-size: 10px; }
.mb-block-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-block-invited { background: var(--mb-mine-soft); color: var(--mb-green); border: 1px solid var(--mb-mine); }

/* Awaiting approval (#177): dashed edge = booked, but not confirmed yet. */
.mb-block.is-pending { border: 1.5px dashed #b7871f; }
.mb-block-mine.is-pending { background: #8a6a17; }
.mb-block.is-declined { opacity: .55; text-decoration: line-through; }
.mb-badge {
  display: inline-block; font-size: 9px; font-weight: 700; line-height: 1.4;
  text-transform: uppercase; letter-spacing: .03em; border-radius: 3px;
  padding: 0 4px; margin-bottom: 1px; background: rgba(255, 255, 255, .28);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.mb-block-busy .mb-badge, .mb-block-invited .mb-badge { background: rgba(183, 135, 31, .22); color: #8a6a17; }
.mb-block-blocked {
  background: repeating-linear-gradient(45deg, #fbe4e1, #fbe4e1 5px, #f3cec9 5px, #f3cec9 10px);
  border: 1px solid #e9b7b1; color: #8a2b22; cursor: pointer; z-index: 2;
}
.mb-block-blocked .mb-block-time { opacity: .8; font-size: 10px; }

/* Drag-create selection */
.mb-selection { position: absolute; right: 3px; border-radius: 6px; z-index: 5; background: rgba(47,107,69,.22); border: 1.5px dashed var(--mb-green); pointer-events: none; }
.mb-selection.is-block { background: rgba(180,35,24,.18); border-color: var(--mb-blocked); }
.mb-create-btn {
  position: absolute; right: 3px; z-index: 8; white-space: nowrap;
  background: var(--mb-green); color: #fff; border: none; border-radius: 7px;
  padding: 5px 10px; font-size: 11.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.22);
}
.mb-create-btn:hover { background: var(--mb-green-soft); }

/* Availability editor */
.mb-avail { border: 1px solid var(--mb-border); border-radius: 12px; background: #fff; padding: 16px; }
.mb-avail-intro { font-size: 13px; color: #6a766d; margin-bottom: 14px; max-width: 640px; }
.mb-avail-picker { max-width: 320px; margin-bottom: 14px; }
.mb-avail-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f2f0; }
.mb-avail-row:last-child { border-bottom: none; }
.mb-avail-day { width: 96px; font-weight: 600; font-size: 14px; }
.mb-avail-blocks { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.mb-avail-block { display: inline-flex; align-items: center; gap: 6px; background: #f4f7f4; border: 1px solid var(--mb-border); border-radius: 8px; padding: 4px 8px; }
.mb-avail-block input[type="time"] { border: 1px solid var(--mb-border); border-radius: 6px; padding: 3px 6px; font-size: 13px; }
.mb-x { cursor: pointer; color: #b42318; font-weight: 700; border: none; background: none; font-size: 15px; line-height: 1; }
.mb-add-block { border: 1px dashed #94a3b8; background: #fff; color: var(--mb-green); border-radius: 8px; padding: 4px 10px; font-size: 13px; cursor: pointer; }

.mb-field { display: flex; flex-direction: column; gap: 4px; }
.mb-field label { font-size: 12px; font-weight: 600; color: #6a766d; }
.mb-field select, .mb-field input, .mb-field textarea {
  border: 1px solid var(--mb-border); border-radius: 8px; padding: 8px 10px; font-size: 14px; font-family: inherit;
}
.mb-link { color: var(--mb-green-soft); word-break: break-all; }

/* Editable time row */
.mb-timerow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-timerow input { border: 1px solid var(--mb-border); border-radius: 8px; padding: 7px 9px; font-size: 14px; font-family: inherit; }
.mb-timerow-sep { color: #8a948b; }

/* Attendee typeahead */
.mb-ta { border: 1px solid var(--mb-border); border-radius: 8px; padding: 6px; position: relative; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mb-ta-chips { display: contents; }
.mb-ta-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid; border-radius: 999px; padding: 3px 9px; font-size: 12.5px; font-weight: 600; }
.mb-ta-chip .mb-dot { width: 9px; height: 9px; border-radius: 50%; }
.mb-ta-x { cursor: pointer; font-weight: 700; margin-left: 2px; }
.mb-ta-input { flex: 1; min-width: 120px; border: none; outline: none; font-size: 14px; font-family: inherit; padding: 4px; background: transparent; }
.mb-ta-menu { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--mb-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.14); z-index: 10; max-height: 220px; overflow-y: auto; }
.mb-ta-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; font-size: 13.5px; }
.mb-ta-item:hover { background: #f4f7f4; }
.mb-ta-item .mb-dot { width: 10px; height: 10px; border-radius: 50%; }
.mb-resched { display: none; }
.mb-resched .mb-field { margin-bottom: 12px; }

/* Modal — declare the theme vars here too: modals mount on document.body,
   OUTSIDE .mb-root, so .mb-root's custom properties don't cascade to them. */
.mb-modal-backdrop {
  --mb-green: #1f4b2f;
  --mb-green-soft: #2f6b45;
  --mb-border: #e3e6e2;
  --mb-mine: #2f6b45;
  --mb-blocked: #b42318;
}
.mb-modal-backdrop { position: fixed; inset: 0; background: rgba(20,28,22,.42); z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.mb-modal { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: 0 18px 50px rgba(0,0,0,.28); padding: 20px 22px; }
.mb-modal h3 { margin: 0 0 4px; color: var(--mb-green); font-size: 18px; }
.mb-modal-when { font-size: 13px; color: #6a766d; margin-bottom: 14px; }
.mb-form { display: flex; flex-direction: column; gap: 12px; }
.mb-attendees-list { display: flex; flex-wrap: wrap; gap: 7px; max-height: 168px; overflow-y: auto; }
.mb-modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.mb-modal-actions-right { display: flex; gap: 10px; margin-left: auto; }
.mb-note { font-size: 12px; color: #8a7a3a; background: #fbf6e3; border: 1px solid #efe2b8; border-radius: 8px; padding: 8px 10px; }

.mb-empty { padding: 40px; text-align: center; color: #8a948b; font-size: 14px; }
.mb-spinner { padding: 40px; text-align: center; color: #8a948b; }

.mb-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #e2e8f0; padding: 11px 18px; border-radius: 10px; font-size: 13.5px; z-index: 5000; box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.mb-toast.is-error { background: #7f1d1d; }

@media (max-width: 640px) {
  .mb-toolbar { align-items: flex-start; }
  .mb-toolbar-right { width: 100%; justify-content: space-between; }
  .mb-weeklabel { min-width: 120px; font-size: 13px; }
  .mb-cal-scroll { max-height: 62vh; }
  :root .mb-root { --mb-slot-h: 34px; --mb-time-w: 48px; }
}

/* ── #134 dark mode overrides ─────────────────────────────── */
/* theme.css flips the --mb-* token block on both .mb-root and
   .mb-modal-backdrop, plus .mb-root's own colour, .mb-muted, .mb-modal-when,
   .mb-modal and the backdrop scrim. Everything below is a bare literal.

   One consequence of the token flip: --mb-green, --mb-green-soft, --mb-mine and
   --mb-blocked are now LIGHT (sage / coral), so every place that put #fff on
   them has to switch to dark ink or the pair drops under 3:1. */

/* toolbar + tabs */
html[data-theme="dark"] .mb-tab,
html[data-theme="dark"] .mb-btn,
html[data-theme="dark"] .mb-chip { background: #1e293b; color: #cbd5e1; }
html[data-theme="dark"] .mb-btn:hover { background: #334155; }
html[data-theme="dark"] .mb-tab.is-active,
html[data-theme="dark"] .mb-mode.is-on,
html[data-theme="dark"] .mb-mode:nth-of-type(2).is-on,
html[data-theme="dark"] .mb-btn-primary,
html[data-theme="dark"] .mb-btn-primary:hover,
html[data-theme="dark"] .mb-create-btn,
html[data-theme="dark"] .mb-create-btn:hover,
html[data-theme="dark"] .mb-head-day.is-today .mb-head-num,
html[data-theme="dark"] .mb-block-mine { color: #0f172a; }

html[data-theme="dark"] .mb-modeswitch { background: rgba(148, 163, 184, 0.10); }
html[data-theme="dark"] .mb-mode { color: #cbd5e1; }
html[data-theme="dark"] .mb-mode-label,
html[data-theme="dark"] .mb-people-head,
html[data-theme="dark"] .mb-hint,
html[data-theme="dark"] .mb-avail-intro,
html[data-theme="dark"] .mb-field label,
html[data-theme="dark"] .mb-timelabel,
html[data-theme="dark"] .mb-timerow-sep,
html[data-theme="dark"] .mb-empty,
html[data-theme="dark"] .mb-spinner { color: #94a3b8; }

html[data-theme="dark"] .mb-btn-danger {
  color: var(--mb-blocked);
  border-color: rgba(240, 139, 131, 0.34);
}

/* people picker + legend */
html[data-theme="dark"] .mb-people,
html[data-theme="dark"] .mb-cal-wrap,
html[data-theme="dark"] .mb-avail { background: #1e293b; }
html[data-theme="dark"] .mb-sw.busy {
  background: repeating-linear-gradient(45deg, #475569, #475569 4px, #334155 4px, #334155 8px);
}
html[data-theme="dark"] .mb-sw.blocked {
  background: repeating-linear-gradient(45deg, rgba(240, 139, 131, 0.45), rgba(240, 139, 131, 0.45) 4px, rgba(240, 139, 131, 0.24) 4px, rgba(240, 139, 131, 0.24) 8px);
}

/* calendar grid */
html[data-theme="dark"] .mb-grid-head { background: #273449; }
html[data-theme="dark"] .mb-grid-head > div { color: #cbd5e1; }
html[data-theme="dark"] .mb-head-day .mb-head-num { color: #e2e8f0; }
html[data-theme="dark"] .mb-slot { border-bottom-color: rgba(148, 163, 184, 0.10); }
html[data-theme="dark"] .mb-slot.mb-slot-hour { border-bottom-color: rgba(148, 163, 184, 0.18); }
html[data-theme="dark"] .mb-daycol.is-today { background: rgba(134, 201, 160, 0.07); }

/* blocks */
html[data-theme="dark"] .mb-block-busy {
  background: repeating-linear-gradient(45deg, #475569, #475569 6px, #3b4a61 6px, #3b4a61 12px);
  border-color: #64748b;
  color: #e2e8f0;
}
html[data-theme="dark"] .mb-block-blocked {
  background: repeating-linear-gradient(45deg, rgba(239, 68, 68, 0.30), rgba(239, 68, 68, 0.30) 5px, rgba(239, 68, 68, 0.18) 5px, rgba(239, 68, 68, 0.18) 10px);
  border-color: rgba(240, 139, 131, 0.55);
  color: #fecaca;
}
html[data-theme="dark"] .mb-selection { background: rgba(134, 201, 160, 0.22); }
html[data-theme="dark"] .mb-selection.is-block { background: rgba(240, 139, 131, 0.22); }

/* availability editor */
html[data-theme="dark"] .mb-avail-row { border-bottom-color: rgba(148, 163, 184, 0.12); }
html[data-theme="dark"] .mb-avail-block { background: rgba(148, 163, 184, 0.10); }
html[data-theme="dark"] .mb-x { color: var(--mb-blocked); }
html[data-theme="dark"] .mb-add-block {
  background: transparent;
  border-color: #64748b;
}

/* form controls carry no background of their own, so set them explicitly */
html[data-theme="dark"] .mb-avail-block input[type="time"],
html[data-theme="dark"] .mb-field select,
html[data-theme="dark"] .mb-field input,
html[data-theme="dark"] .mb-field textarea,
html[data-theme="dark"] .mb-timerow input {
  background: #0f172a;
  color: #e2e8f0;
}
html[data-theme="dark"] .mb-field input::placeholder,
html[data-theme="dark"] .mb-field textarea::placeholder,
html[data-theme="dark"] .mb-ta-input::placeholder { color: #64748b; }
html[data-theme="dark"] .mb-ta-input { color: #e2e8f0; }

/* attendee typeahead */
html[data-theme="dark"] .mb-ta-menu {
  background: #1e293b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] .mb-ta-item:hover { background: #334155; }

html[data-theme="dark"] .mb-note {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.34);
}

/* approvals bar + pending blocks */
html[data-theme="dark"] .mb-approvals {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.32);
}
html[data-theme="dark"] .mb-approvals-head { color: #fcd34d; }
html[data-theme="dark"] .mb-approval-row { border-top-color: rgba(245, 158, 11, 0.22); }
html[data-theme="dark"] .mb-approval-when { color: #94a3b8; }
html[data-theme="dark"] .mb-block.is-pending { border-color: #fcd34d; }
html[data-theme="dark"] .mb-block-mine.is-pending { background: #fcd34d; color: #0f172a; }
html[data-theme="dark"] .mb-block-busy .mb-badge,
html[data-theme="dark"] .mb-block-invited .mb-badge {
  background: rgba(252, 211, 77, 0.20);
  color: #fcd34d;
}

html[data-theme="dark"] .mb-toast { background: #334155; }
