/* ============================================================
   BOOKING — MODALS
   Manual-book section numbering, courier picker cards, and the
   shared form grid used by both the manual form and the edit modal.
   ============================================================ */

/* ---- Visually hidden, still focusable ----
   The reference hides its radio with `opacity:0`. That keeps the input in the
   tab order but paints nothing, so the keyboard user gets a control with no
   visible focus indicator at all. Clipping keeps the native focus behaviour
   working while removing it from the visual flow, and the card restores an
   outline via :focus-within below. */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Numbered sections (manual form) ---- */
.bk-msec { padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 14px; }
.bk-msec:first-of-type { border-top: 0; margin-top: 0; padding-top: 4px; }
.bk-msec-h {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}
.bk-num {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary-dark);
  font-size: 11px;
  flex: 0 0 auto;
}

/* ---- Courier picker cards ---- */
.bk-couriers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px;
}
.bk-courier {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-md, 11px);
  background: var(--elev);
  cursor: pointer;
  position: relative;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.bk-courier:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.bk-courier.is-selected {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 22%, transparent);
}
/* Keyboard users get the indicator the reference loses. */
.bk-courier:has(:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.bk-courier.is-off { opacity: .5; cursor: not-allowed; }

.bk-c-logo {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--elev);
  overflow: hidden;
}
.bk-c-logo img, .bk-c-logo svg { max-width: 100%; max-height: 100%; }

.bk-c-tx { min-width: 0; flex: 1 1 auto; }
.bk-c-tx b { display: block; font-size: 12px; }
.bk-c-tx small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bk-tick { margin-left: auto; color: var(--primary); opacity: 0; flex: 0 0 auto; }
.bk-courier.is-selected .bk-tick { opacity: 1; }

/* Badges. "Best for this order" is the one that matters — it tells you which
   card the routing engine would pick if you left it on auto. */
.bk-c-best, .bk-c-off, .bk-c-sla {
  display: inline-block;
  margin-top: 5px;
  font-size: 9.5px;
  font-weight: 750;
  padding: 2px 6px;
  border-radius: 5px;
}
.bk-c-best {
  background: color-mix(in srgb, var(--success, #22c55e) 16%, transparent);
  color: var(--success-dark);
}
.bk-c-off { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn-text); }
.bk-c-sla { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); }

.bk-cinfo { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Form grid, shared by manual form and edit modal ----
   `_renderField` emits a `.w{n}` span class per field for the multi-column
   fields (address, notes, courier), so those still get a full row. */
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fgrid .w2 { grid-column: span 2; }
.fgrid .w3 { grid-column: span 2; }
.fgrid .w6 { grid-column: 1 / -1; }
.fgrid > .w { min-width: 0; }

@media (max-width: 760px) {
  .fgrid { grid-template-columns: 1fr; }
  /* Every span collapses to one column, otherwise a w2/w6 field overflows a
     single-column grid and the form scrolls sideways. */
  .fgrid .w2, .fgrid .w3, .fgrid .w6 { grid-column: span 1; }
  .bk-couriers { grid-template-columns: 1fr; }
}

/* ---- Modal body: solid, and never see-through ----
   The modal surface must be opaque. This rule is deliberately specific and sits
   late, because a previously dangling selector elsewhere in the cascade left
   every dialog in the app rendering translucent over the page behind it. */
#bk-editModal .modal,
#bk-confirmModal .modal,
#bk-orderModal .modal,
#bk-bulkModal .modal,
#bk-reviewModal .modal {
  background: var(--card);
  background-image: none;
  opacity: 1;
  backdrop-filter: none;
}

/* ---- Confirm modal: 2x2 stat grid ---- */
.bk-cstats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.bk-cstat {
  padding: 12px 13px;
  border-radius: var(--r-md, 11px);
  background: var(--elev);
  border: 1px solid var(--line);
}
.bk-cstat span { display: block; font-size: 10.5px; color: var(--muted); }
.bk-cstat strong { display: block; font-size: 17px; margin-top: 5px; letter-spacing: -.3px; }
/* ---- Manual booking dialog ----
   Was a full page. Now it sits over the orders list in one wide dialog: form
   on the left, live summary and estimate on the right, so everything about the
   order being entered is visible at once instead of needing a scroll. */
#bk-manualModal .modal.bk-manual-modal {
  width: min(1080px, 96vw);
  max-height: 92vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas: "head head" "body side";
  gap: 0;
  padding: 0;
  background: var(--card);
}
#bk-manualModal .mh { grid-area: head; margin: 0; border-radius: 0; }
#bk-manualModal .mb { grid-area: body; overflow-y: auto; padding: 16px 20px; }
.bk-maside {
  grid-area: side;
  overflow-y: auto;
  padding: 16px 18px;
  border-left: 1px solid var(--line);
  background: var(--elev);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bk-mform { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.bk-mform .mf { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
#bk-manualModal .bk-msec { border-top: 0; margin-top: 0; padding-top: 0; }
@media (max-width: 900px) {
  #bk-manualModal .modal.bk-manual-modal {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "body" "side";
  }
  .bk-maside { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---- Confirm dialog: a question, not a summary ---- */
.bk-confirm-modal { width: min(420px, 92vw); }
.bk-confirm-body:empty { display: none; }
.bk-confirm-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
