/* Invoice email panel — choose, preview and edit the invoice email.
 *
 * A COPY of the quote tool's send panel styling (Online Quoting Tool PRO -
 * Estimates, calculator.html #sp-overlay). Same look on purpose — reworded for
 * invoices, not redesigned. The Scheduler's own copy: nothing is loaded from the
 * quote tool, so a change there never moves this.
 *
 * Differences from the original, each deliberate:
 *   · no body.calc-embedded rules — the diary is never an iframe inside a funnel
 *   · no funnel link / SMS counter rules — the invoice panel has neither
 *   · primary colour falls back to GHL blue #006aac (the diary's own brand var)
 *   · "Send as" carries a visible reason, because it cannot be changed
 *   · a phone layout, because the diary runs on technicians' phones
 *   · every tappable control at least 44px tall — the diary's check:touch floor
 */

/* 🪤 `hidden` loses to any author `display:` rule. The diary has a global
   [hidden] rule; other hosts (Client Finder) do not — so the panel carries its own. */
#sp-overlay [hidden] { display: none !important; }

#sp-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55);
  z-index: 9999; align-items: flex-start; justify-content: center; padding: 24px 14px; overflow-y: auto; }
#sp-overlay.open { display: flex; }
#sp-modal { background: #fff; width: 100%; max-width: 640px; border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; max-height: 92vh; }
#sp-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid #e5e7eb; }
#sp-head strong { font-size: 1rem; color: #1f2937; }
#sp-close { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: #6b7280;
  min-width: 44px; min-height: 44px; }
#sp-body { padding: 16px 18px; overflow-y: auto; }
.sp-field { margin-bottom: 14px; }
.sp-field > label { display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: #6b7280; margin-bottom: 5px; }
#sp-body select, #sp-body input[type=text], #sp-body textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: .9rem; font-family: inherit; }
.sp-channels { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sp-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; font-size: .9rem; color: #1f2937;
  min-height: 44px; }
/* `.sp-field > label` outranks `.sp-check` and makes these blocks; with the 44px
   floor their text then sat at the TOP, out of line with "Send as". */
.sp-channels > label.sp-check { display: inline-flex; align-items: center; margin-bottom: 0; }
#sp-overlay button, #sp-overlay input, #sp-overlay select { font-family: inherit; }
.sp-check.disabled { opacity: .5; cursor: not-allowed; }
.sp-check.disabled input { cursor: not-allowed; }
.sp-ch-note { font-weight: 500; font-size: .78rem; color: #b91c1c; }
/* 📤 "Sending as" — the ETAS compose page's row, copied (22 Oct 2026). A
   send-time setting, not a field to fill in absent-mindedly: highlighted amber
   while unset — and the * and the words say so too, never the colour alone. */
.sp-send-as-row {
  margin: 0 0 14px; padding: 12px;
  border: 1px solid #e3e8ef; border-radius: 8px;
  background: #f8fafc;
}
.sp-send-as-row.required { border-color: #fde68a; background: #fef3c7; }
#sp-body .sp-send-as-row > label { display: grid; gap: 6px; margin-bottom: 0; }
.sp-send-as-required-marker { color: #92400e; font-weight: 700; margin-left: 4px; }
#sp-send-as-note { font-size: .78rem; color: #4b5563; }
#sp-preview { width: 100%; height: 280px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
/* Wording editor. State reads from the ✎/↺ glyphs and the word "Editing"
   as well as the fill, so it never depends on colour alone. */
.sp-edit-controls { float: right; display: inline-flex; align-items: center; gap: 6px; }
.sp-edit-btn {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 44px; padding: 6px 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer;
  background: #fff; color: #4b5563;
  border: 1px solid #e5e7eb; border-radius: 8px;
  text-transform: none; letter-spacing: normal;
}
.sp-edit-btn:hover:not(:disabled) { background: #eef6fb; color: #006aac; border-color: #006aac; }
.sp-edit-btn.on { background: #006aac; color: #fff; border-color: #006aac; }
.sp-edit-btn:disabled { opacity: .45; cursor: not-allowed; }
.sp-edit-status { font-size: 12px; font-weight: 600; color: #006aac; text-transform: none; letter-spacing: normal; }
.sp-edit-hint {
  margin: 6px 0 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45;
  color: #4b5563; background: #eef6fb; border: 1px solid #cfe6f5; border-radius: 8px;
}
.sp-tpl-wrap { position: relative; }
#sp-template-dropdown { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff;
  border: 1px solid #006aac; border-top: 0; border-radius: 0 0 8px 8px; max-height: 260px; overflow-y: auto;
  box-shadow: 0 10px 24px rgba(0,0,0,.15); }
#sp-template-dropdown[hidden] { display: none; }
.sp-tpl-count { padding: 6px 10px; font-size: .72rem; color: #6b7280; border-bottom: 1px solid #eef2f7; position: sticky; top: 0; background: #fff; }
.sp-tpl-item { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 9px 10px;
  font-size: .86rem; cursor: pointer; color: #1f2937; border-bottom: 1px solid #f1f5f9; min-height: 44px; }
.sp-tpl-item:hover, .sp-tpl-item.active { background: #ebf5fb; }
.sp-tpl-item small { display: block; color: #6b7280; font-size: .72rem; }
.sp-tpl-empty { padding: 10px; font-size: .82rem; color: #6b7280; }
.sp-muted { font-size: .78rem; color: #6b7280; }
/* "Show all templates" / "Back to folder …" escape hatch under the picker.
   Underlined ALWAYS, not just on hover: colour alone must never be the only
   signal that something is clickable. */
.sp-tpl-scope-toggle {
  all: unset; cursor: pointer; color: #006aac; font-size: .78rem;
  font-weight: 600; text-decoration: underline; display: inline-block;
  /* Still reads as a text link — but a 44px tap target, not a 15px one. */
  min-height: 44px; line-height: 44px; vertical-align: middle;
}
.sp-tpl-scope-toggle:hover { color: #005589; }
.sp-tpl-scope-toggle:focus-visible { outline: 2px solid #006aac; outline-offset: 2px; }
/* 📧 CC / BCC — the ETAS compose page's expander row, same look and values. */
.sp-expander {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  width: 100%; min-height: 44px; padding: 11px 12px; margin-bottom: 10px; text-align: left;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  background: #f8fafc; color: #111827; border: 1px solid #e3e8ef; border-radius: 8px;
}
.sp-expander:hover { background: #eef4fb; border-color: #cfe0ef; color: #006aac; }
.sp-expander.open {
  background: #eef4fb; border-color: #cfe0ef; color: #006aac;
  margin-bottom: 0; border-radius: 8px 8px 0 0;
}
.sp-expander-icon { font-size: 14px; line-height: 1; flex-shrink: 0; }
.sp-expander-label { white-space: nowrap; }
.sp-expander-sub { margin-left: auto; font-size: 12px; font-weight: 400; color: #64748b; white-space: nowrap; }
.sp-expander.open .sp-expander-sub { display: none; }
.sp-expander-chev { font-size: 15px; line-height: 1; color: #64748b; margin-left: 6px; transition: transform .15s ease; }
.sp-expander.open .sp-expander-chev { transform: rotate(180deg); color: #006aac; margin-left: auto; }
.sp-expander-panel {
  border: 1px solid #cfe0ef; border-top: 0; border-radius: 0 0 8px 8px;
  padding: 14px 13px 2px; margin-bottom: 14px; background: #fff;
}
.sp-expander-panel .sp-field > label { text-transform: none; letter-spacing: normal; font-size: 13px; font-weight: 600; color: #334155; }
#sp-body .sp-expander-panel textarea { min-height: 44px; resize: vertical; }
/* ✉ "Also copied to …" — the secondary email, always on unless unticked. */
#sp-body .sp-secondary {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; margin-bottom: 10px;
  border: 1px solid #cfe0ef; border-radius: 8px; background: #eef4fb; cursor: pointer;
  font-size: 13px; font-weight: 400; color: #111827; text-transform: none; letter-spacing: normal;
}
#sp-body .sp-secondary input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; }
#sp-body .sp-secondary > span { min-width: 0; overflow-wrap: anywhere; }
/* 📧 People at this company — tick to copy them in (2026-10-09). */
.sp-cc-people-title { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.sp-cc-people-list { display: grid; gap: 6px; }
#sp-body .sp-cc-person {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px;
  border: 1px solid #e3e8ef; border-radius: 8px; cursor: pointer; background: #fff;
  font-size: 13px; font-weight: 400; color: #111827; text-transform: none; letter-spacing: normal;
}
#sp-body .sp-cc-person:has(input:checked) { border-color: #006aac; background: #eef4fb; }
#sp-body .sp-cc-person input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; }
#sp-body .sp-cc-person > span { min-width: 0; overflow-wrap: anywhere; }
.sp-cc-billing { font-size: 12px; font-weight: 600; color: #006aac; white-space: nowrap; }
#sp-feedback { font-size: .85rem; margin-top: 8px; }
#sp-feedback.err { color: #b91c1c; } #sp-feedback.ok { color: #127a3e; } #sp-feedback.warn { color: #92400e; }
#sp-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid #e5e7eb; }
.sp-btn-primary { background: var(--brand, #006aac); color: #fff; border: 0; padding: 10px 20px; border-radius: 7px; font-weight: 700; cursor: pointer;
  min-height: 44px; }
.sp-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.sp-btn-ghost { background: #fff; color: #6b7280; border: 1px solid #cbd5e1; padding: 10px 16px; border-radius: 7px; cursor: pointer;
  min-height: 44px; }

/* Phone: the whole screen, footer always reachable. The same panel, only sized
   for a small screen. */
@media (max-width: 640px) {
  #sp-overlay { padding: 0; }
  #sp-modal { max-width: none; max-height: none; height: 100dvh; border-radius: 0; }
  #sp-body { flex: 1 1 auto; }
  .sp-edit-controls { float: none; display: flex; flex-wrap: wrap; margin-top: 6px; }
}
