/* Job sign-off UI — shared by the phone portal and the contact card.
   Self-contained: the contact card has no .booking-sheet styles of its own, so
   the shell is scoped under .cf-signoff-sheet rather than borrowed from
   portal-mobile.css. Both pages therefore render the sheet identically. */

.cf-signoff-sheet { position: fixed; inset: 0; z-index: 10001; display: flex; align-items: flex-end; justify-content: center; }
.cf-signoff-sheet .booking-sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.cf-signoff-sheet .booking-sheet__panel {
  position: relative; background: #fff; width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
  font-family: inherit; color: #111827;
}
@media (min-width: 600px) {
  .cf-signoff-sheet { align-items: center; }
  .cf-signoff-sheet .booking-sheet__panel { border-radius: 16px; }
}

/* A scrollbar you can actually catch with a thumb.
   ~6mm. The default hairline is fine with a mouse and hopeless when the phone
   is sideways in a customer's hand and the signature pad has eaten the screen —
   people miss it, hit the backdrop, and used to lose the whole sheet.
   Always visible (not overlay), so there is something to aim at before you drag.
   ⚠️ iOS Safari draws its own non-interactive overlay indicator and ignores
   most of this, which is why the landscape rules below matter more there. */
.cf-signoff-sheet .booking-sheet__panel { scrollbar-width: auto; scrollbar-color: #94a3b8 #eef2f6; }
.cf-signoff-sheet .booking-sheet__panel::-webkit-scrollbar { width: 22px; }
.cf-signoff-sheet .booking-sheet__panel::-webkit-scrollbar-track {
  background: #eef2f6; border-radius: 11px;
}
.cf-signoff-sheet .booking-sheet__panel::-webkit-scrollbar-thumb {
  background: #94a3b8; border-radius: 11px;
  /* Inset so the thumb reads as a grabbable pill rather than a full-width slab,
     while the hit area stays the full 22px. */
  border: 4px solid #eef2f6; background-clip: padding-box;
  min-height: 48px;                 /* never smaller than a fingertip */
}
.cf-signoff-sheet .booking-sheet__panel::-webkit-scrollbar-thumb:active { background: #64748b; background-clip: padding-box; }

/* The landscape layout lives at the BOTTOM of this file — see the note there.
   Putting it here cost an evening: the base rules below override it. */
.cf-signoff-sheet .booking-sheet__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cf-signoff-sheet .booking-sheet__title { font-size: 18px; font-weight: 700; }
.cf-signoff-sheet .booking-sheet__when { font-size: 14px; color: #4b5563; margin-top: 2px; }
.cf-signoff-sheet .booking-sheet__close {
  background: none; border: 0; font-size: 28px; line-height: 1; color: #6b7280; cursor: pointer; padding: 0 4px;
}
.cf-signoff-sheet .booking-field { display: flex; flex-direction: column; gap: 6px; }
.cf-signoff-sheet .booking-field > span {
  font-size: 12px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: 0.04em;
}
.cf-signoff-sheet .booking-sheet__foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.cf-signoff-sheet .booking-cancel {
  padding: 10px 16px; border-radius: 8px; border: 1px solid #d9e0e6;
  background: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.cf-signoff-sheet .booking-save {
  padding: 10px 18px; border-radius: 8px; border: 0;
  background: #006aac; color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.cf-signoff-sheet .booking-save:disabled { opacity: 0.5; cursor: not-allowed; }

.signoff-declaration {
  margin: 0; padding: 10px 12px; border-radius: 8px;
  background: #f1f5f9; color: #334155; font-size: 14px; line-height: 1.45;
}
.signoff-name, .signoff-role, .signoff-notes {
  padding: 10px 12px; border-radius: 8px; border: 1px solid #d9e0e6;
  font: inherit; font-family: inherit; background: #fff; width: 100%; box-sizing: border-box;
}
.signoff-notes { resize: vertical; min-height: 80px; max-height: 40vh; }
.signoff-pad-wrap {
  position: relative; border: 2px dashed #d9e0e6; border-radius: 10px;
  background: #fff; height: 190px; overflow: hidden;
}
/* touch-action:none is load-bearing — without it a signing stroke scrolls the
   sheet out from under the customer mid-signature. */
.signoff-pad { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.signoff-pad__hint {
  position: absolute; inset: auto 0 12px 0; text-align: center;
  font-size: 13px; color: #9ca3af; pointer-events: none;
}
.signoff-pad__hint.is-hidden { display: none; }
.signoff-clear {
  align-self: flex-start; background: none; border: 0; padding: 4px 0;
  font: inherit; font-weight: 600; color: #6b7280; cursor: pointer;
}
.signoff-skip { margin-right: auto; background: none; border: 0; font: inherit; font-weight: 600; color: #6b7280; cursor: pointer; }
/* The tick boxes themselves are styled by pay-split.css (shared with the Xero
   payment sheets). */
.signoff-pay { display: block; }
/* The single dropdown — every location until split payments is switched on for
   it (on test at YBH only, 14 Oct 2026). Exactly the rules it always had. */
.signoff-pay--single { display: flex; gap: 8px; align-items: center; }
.signoff-pay--single select {
  padding: 10px 12px; border-radius: 8px; border: 1px solid #d9e0e6; font: inherit; background: #fff;
}
.signoff-pay-amount-wrap {
  /* min-width:0 — without it the box cannot shrink below the input's natural
     width and ran off the side of a narrow phone (seen 22 Nov 2026). */
  display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0;
  padding: 0 10px; border-radius: 8px; border: 1px solid #d9e0e6; background: #fff;
}
.signoff-pay-amount-wrap.is-hidden { display: none; }
.signoff-pay-currency { color: #6b7280; font-weight: 600; }
.signoff-pay-amount { flex: 1; min-width: 0; border: 0; outline: none; padding: 10px 0; font: inherit; }

/* Signed-summary sheet — what's on file, and how to undo it. */
.signed-summary {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px;
  margin: 0; padding: 12px; border-radius: 8px; background: #f8fafc;
}
.signed-summary dt { font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }
.signed-summary dd { margin: 0; font-size: 15px; }
.signed-view {
  display: inline-block; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #d9e0e6; text-align: center; text-decoration: none;
  font-weight: 600; color: #006aac; background: #fff;
}
.signed-remove { margin-right: auto; color: #b42318; background: none; border: 0; font: inherit; font-weight: 700; cursor: pointer; }

/* The host button, on both the portal appointment row and the contact card. */
.appt-signoff-btn {
  padding: 8px 12px; border-radius: 8px; border: 1px solid #d9e0e6;
  background: #fff; font: inherit; font-weight: 600; cursor: pointer;
}

/* ════════════════════════════════════════════════════════════════════
   TOUCH TARGETS — 44px, Apple's minimum for a fingertip.
   Measured, not guessed: scripts/audit-touch-targets.mjs in GBU Scheduler
   renders this sheet in a real browser and fails under 44px. Before this,
   "Nobody home — skip" was 25px, the × was 28px and Clear was 31px — on a
   sheet operated with a customer waiting.
   Skip and Clear also gain a border: at 25px with no box they read as stray
   text sitting beside two real buttons, not as something you can press.
   ════════════════════════════════════════════════════════════════════ */
.cf-signoff-sheet .booking-sheet__close {
  min-width: 44px; min-height: 44px; font-size: 26px; padding: 0;
}
.cf-signoff-sheet .signoff-clear,
.cf-signoff-sheet .signoff-skip {
  min-height: 44px; padding: 0 14px; border: 1px solid #d9e0e6;
  border-radius: 8px; background: #fff; color: #4b5563;
}
.cf-signoff-sheet .booking-cancel,
.cf-signoff-sheet .booking-save { min-height: 44px; }
.cf-signoff-sheet .signoff-pay--single select { min-height: 44px; }
.cf-signoff-sheet .signoff-pay-amount-wrap { min-height: 44px; }

/* ════════════════════════════════════════════════════════════════════
   THE BUTTONS ARE PINNED TO THE BOTTOM ON A PHONE (Allan, 25 Nov 2026).
   The declaration, the pad, the notes and the payment box make this sheet
   taller than a phone screen, so Cancel / Save sat at the END of the scroll
   and went off the bottom. One rule covers every sheet this file draws (the
   pad, "Signed off", "Record a payment") and the customer's own sign-off page.
   The bar runs edge to edge across the panel's side and bottom padding, with
   a white background, so nothing shows through underneath it — the deposit
   sheet's bar (deposit-ui.css).
   🪤 bottom is MINUS the panel's bottom padding: a sticky bar is held inside
   the panel's CONTENT box, so at 0 the fields scrolled past in a 16px strip
   below the buttons. A negative margin alone does not fix that.
   Phone only — upright, or any screen under 520px tall — so the desktop's
   centred sheet is unchanged. The sideways layout below sets its own numbers
   (its panel padding is smaller), which is why this sits ABOVE it.
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 599.98px), (max-height: 520px) {
  .cf-signoff-sheet .booking-sheet__foot {
    position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); z-index: 1;
    background: #fff; border-top: 1px solid #e5e7eb;
    margin: 0 -16px calc(-16px - env(safe-area-inset-bottom));
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }
}

/* ════════════════════════════════════════════════════════════════════
   LANDSCAPE PHONE — the sheet handed over sideways.
   ~390px of height, and the signature pad is the only thing that genuinely
   needs room. Stacked, the notes and the payment box end up below the fold,
   which is precisely where the amount you are asking someone to confirm
   should never be. So: two columns, pad on the left, the short fields beside
   it, footer pinned full-width underneath. Mirrors the booking modal's own
   .bp-left / .bp-right split, so it is a familiar shape rather than a new one.

   🪤 THIS BLOCK MUST STAY AT THE BOTTOM OF THE FILE. It was originally written
   up near the scrollbar rules, where `.signoff-pad-wrap` and `.signoff-notes`
   are redefined LATER at equal specificity — so the base rules won and the
   whole media query was inert while looking perfectly correct. It shipped that
   way and was only caught by measuring the rendered pad (190px, not 104px).
   Every selector here is also prefixed `.cf-signoff-sheet` for a specificity
   win, so a future re-order cannot silently kill it twice.
   ════════════════════════════════════════════════════════════════════ */
@media (max-height: 520px) and (orientation: landscape) {
  .cf-signoff-sheet .booking-sheet__panel {
    max-height: 100vh;
    padding: 12px 14px calc(8px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1.25fr 1fr;
    /* head · declaration · name · notes · payment · foot */
    grid-template-rows: auto auto auto auto auto auto;
    column-gap: 16px; row-gap: 8px; align-content: start;
  }
  /* EVERY child is placed explicitly. Leaving any to auto-placement put the
     footer above the fields — it fills the first free cell, not the last row. */
  .cf-signoff-sheet .booking-sheet__head { grid-column: 1 / -1; grid-row: 1; }
  .cf-signoff-sheet .signoff-declaration { grid-column: 1 / -1; grid-row: 2; font-size: 12px; padding: 7px 10px; }
  .cf-signoff-sheet .booking-sheet__panel > :nth-child(4) { grid-column: 1; grid-row: 3 / span 3; }  /* signature + Clear */
  .cf-signoff-sheet .booking-sheet__panel > :nth-child(3) { grid-column: 2; grid-row: 3; }           /* customer name */
  .cf-signoff-sheet .booking-sheet__panel > :nth-child(5) { grid-column: 2; grid-row: 4; }           /* notes */
  .cf-signoff-sheet .booking-sheet__panel > :nth-child(6) { grid-column: 2; grid-row: 5; }           /* payment */
  .cf-signoff-sheet .booking-sheet__foot { grid-column: 1 / -1; grid-row: 6; margin-top: 2px; }
  /* Pinned (the phone rule above), on THIS panel's 14px sides and 8px foot. The
     bar's line takes 2px of the row gap above it and 6px sits over the buttons,
     so it is no taller than the old footer: on an 844x390 phone the sheet still
     fits without scrolling (a 2px top margin and 8px here made it 5px too tall). */
  .cf-signoff-sheet .booking-sheet__foot {
    bottom: calc(-8px - env(safe-area-inset-bottom));
    margin: -2px -14px calc(-8px - env(safe-area-inset-bottom));
    padding: 6px 14px calc(8px + env(safe-area-inset-bottom));
  }

  /* The pad gives up the height, not the targets. An earlier pass had Clear at
     40px and the notes box at 38px to make things fit — but a rule you exempt
     is a rule you stop trusting, and the pad had 12px to spare. */
  .cf-signoff-sheet .signoff-pad-wrap { height: 138px; }
  .cf-signoff-sheet .signoff-notes    { min-height: 44px; max-height: 44px; }
  .cf-signoff-sheet .booking-field > span { font-size: 11px; }
}

/* ════════════════════════════════════════════════════════════════════
   NARROW PHONE, UPRIGHT — the pinned button row must stay ONE row.
   Giving Skip / Cancel / Save 44px targets also made them WIDE: the three
   together needed 422px on a 360-412px screen, so the pinned footer wrapped
   to THREE rows and stood 66px tall, on the sheet with the least room to
   spare. Reported live 2026-08-18.
   Only the WIDTH comes in — padding and label size. Every button keeps its
   44px height, which is the part a fingertip actually needs. Measured at
   360/390/412px: one row with 20/50/72px to spare.
   Landscape is untouched (the block above already fits it on one row).
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .cf-signoff-sheet .booking-sheet__foot { gap: 5px; }
  .cf-signoff-sheet .signoff-skip { padding: 0 6px; font-size: 12px; }
  .cf-signoff-sheet .booking-cancel { padding: 10px 10px; font-size: 13px; }
  .cf-signoff-sheet .booking-save { padding: 10px 12px; font-size: 13px; }
}

/* Sign-off by link (Task 9) */
.cf-signoff-sheet .signoff-sendlink {
  align-self: stretch; min-height: 44px; padding: 10px 14px; border-radius: 8px;
  border: 1px solid #006aac; background: #fff; color: #006aac;
  font: inherit; font-weight: 600; cursor: pointer;
}
.cf-signoff-sheet .signed-via { margin: 0; font-size: 14px; color: #334155; }

/* 💷 Record a payment — the pad's "Payment taken" as its own sheet (22 Nov 2026). */
.payclaim-lead{margin:0 0 12px;color:#475569;font-size:14px;}
.payclaim-waiting{margin:0 0 14px;padding:12px 14px;border-radius:10px;background:#fff7ed;border:1px solid #fdba74;color:#7c2d12;font-size:15px;line-height:1.45;}
.payclaim-msg{margin:10px 0 0;color:#b91c1c;font-size:14px;font-weight:600;}
.payclaim-msg:empty{display:none;}
