/* cw-pod-signatures — tech-facing Service Terms signature pod.
   Visual language mirrors cw-pod-appointments (Roboto, Smart Cloud green,
   CW-blue accents, white cards on a light gray pod canvas). */

:root {
  --cw-green: #29ad10;
  --cw-green-dark: #1f7d0c;
  --cw-blue: #026ccf;
  --cw-text: #1f2733;
  --cw-muted: #6b7280;
  --error-red: #d93025;
  --amber: #b45309;
  --border: #e3e8ef;
  --bg-card: #ffffff;
  --bg-page: #f4f6f9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  color: var(--cw-text);
  background: var(--bg-page);
  font-size: 14px;
}

/* Loader */
.pod-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 14px;
}
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #d7e0ea;
  border-top-color: var(--cw-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loader-text {
  color: var(--cw-muted);
  font-size: 13px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  width: 34px;
  height: 34px;
}
.header-title {
  font-weight: 700;
  font-size: 15px;
}
.ticket-badge {
  background: #fef9c3;
  color: var(--amber);
  font-weight: 700;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.terms-version {
  font-size: 11px;
  color: var(--cw-muted);
}
.client-line {
  font-size: 13px;
  color: var(--cw-muted);
  margin-bottom: 12px;
}
.client-line strong {
  color: var(--cw-text);
}

/* Status rows */
.status-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}
.status-label strong {
  display: block;
  font-size: 13px;
}
.status-label small {
  color: var(--cw-muted);
  font-size: 11px;
}
.status-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--cw-muted);
  white-space: nowrap;
}
.status-badge.signed {
  background: #e7f7e3;
  color: var(--cw-green-dark);
}
.status-badge.pending {
  background: #fff4e5;
  color: var(--amber);
}
.status-badge.covered {
  background: #eef5ff;
  color: #2456c4;
}
/* "Covered by membership" banner in the actions card. */
.covered-banner {
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--cw-green-dark);
  background: #e7f7e3;
  border: 1px solid #cdeccb;
  border-left: 3px solid var(--cw-green);
  border-radius: 8px;
  padding: 11px 13px;
}
.invite-line {
  margin-top: 12px;
  font-size: 12px;
  color: var(--cw-muted);
  padding: 8px 10px;
  background: #eef5ff;
  border-radius: 8px;
}

/* Actions */
.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.hint {
  margin: 12px 0 0;
  font-size: 11px;
  color: var(--cw-muted);
  line-height: 1.5;
}

/* Buttons */
.btn-base {
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    transform 0.04s ease,
    filter 0.15s ease,
    background 0.15s ease;
}
.btn-base:active {
  transform: translateY(1px);
}
.btn-base:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.primary-btn {
  background: var(--cw-green);
  color: #fff;
}
.primary-btn:hover:not(:disabled) {
  background: var(--cw-green-dark);
}
.secondary-btn {
  background: #eef2f7;
  color: var(--cw-text);
  border: 1px solid var(--border);
}
.secondary-btn:hover:not(:disabled) {
  background: #e2e8f0;
}
.ghost-btn {
  background: transparent;
  color: var(--cw-muted);
  border: 1px solid var(--border);
}
.link-btn {
  background: none;
  border: none;
  color: var(--cw-blue);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
}
.link-btn.tiny {
  font-size: 11px;
}

/* Documents */
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.doc-list li {
  font-size: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-list .doc-empty {
  color: var(--cw-muted);
  border-style: dashed;
  justify-content: center;
}
.doc-icon {
  color: var(--error-red);
  font-weight: 700;
}
.doc-date {
  margin-left: auto;
  color: var(--cw-muted);
  font-size: 11px;
}

/* Overlay + modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  z-index: 100;
}
.sign-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}
.sign-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sign-modal-head h2 {
  margin: 0;
  font-size: 16px;
}
.icon-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--cw-muted);
  cursor: pointer;
}
.sign-instructions {
  font-size: 12px;
  color: var(--cw-muted);
  line-height: 1.5;
  margin: 8px 0 14px;
}

/* Include section */
.include-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfe;
  margin-bottom: 14px;
}
.include-head {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 8px;
}
.include-head small {
  color: var(--cw-muted);
  font-weight: 400;
}
.include-all {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  margin-bottom: 8px;
}
.include-group {
  margin-top: 10px;
}
.include-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cw-muted);
  margin-bottom: 4px;
}
.include-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.include-list li label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.include-list .inc-meta {
  color: var(--cw-muted);
  font-size: 11px;
}
.include-empty {
  font-size: 12px;
  color: var(--cw-muted);
  margin: 8px 0 0;
}

/* Terms scroll */
.terms-scroll {
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  margin-bottom: 14px;
  font-size: 12px;
  line-height: 1.55;
}
.terms-scroll h3.t-chapter {
  font-size: 12.5px;
  color: var(--cw-text);
  border-left: 3px solid var(--cw-green);
  padding-left: 8px;
  margin: 16px 0 6px;
}
.terms-scroll h4.t-section {
  font-size: 12px;
  color: var(--cw-blue);
  margin: 12px 0 4px;
}
.terms-scroll p {
  margin: 0 0 8px;
}
.terms-scroll p.t-caps {
  font-weight: 700;
}
.terms-scroll li {
  margin: 0 0 6px;
}

/* Sign fields */
.sign-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.field-label {
  font-size: 12px;
  font-weight: 600;
}
.text-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.text-input:focus {
  outline: none;
  border-color: var(--cw-green);
  box-shadow: 0 0 0 3px rgba(41, 173, 16, 0.15);
}
/* Read-only "Signing as <client>" block — the tech doesn't type the name. */
.signer-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.signer-id-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--cw-muted);
}
.signer-id-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--cw-text);
}
.signer-input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.canvas-wrap {
  position: relative;
  border: 1px dashed #c7d0db;
  border-radius: 8px;
  background: #fff;
  height: 150px;
  touch-action: none;
}
#sigCanvas {
  width: 100%;
  height: 100%;
  display: block;
}
.sig-x {
  position: absolute;
  left: 14px;
  bottom: 30px;
  color: var(--cw-muted);
  font-weight: 700;
}
.sig-line {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 28px;
  border-bottom: 1px solid #c7d0db;
}
.consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 11.5px;
  color: var(--cw-muted);
  line-height: 1.5;
}
.consent input {
  margin-top: 2px;
}
/* Larger consent on the signature screen — easier to read and a bigger, more
   deliberate checkbox for the client to tick right before they sign. */
.consent-lg {
  font-size: 13.5px;
  color: var(--cw-text);
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
}
.consent-lg input {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: var(--cw-green);
  cursor: pointer;
}
.sign-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.sign-actions .btn-base {
  flex: 1;
}

/* Two-step in-person signing (review screen → signature screen) */
.sign-step.hidden {
  display: none;
}

/* Pop-out signing window (window.open, opened maximized): make the modal fill
   the whole window so the signature pad on step 2 can be as large as possible.
   The embedded-pod fallback (popup blocked) keeps the normal centered modal. */
body.is-popout .overlay {
  padding: 0;
  align-items: stretch;
  overflow: hidden;
}
body.is-popout .sign-modal {
  max-width: none;
  width: 100%;
  height: 100vh;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}
body.is-popout .sign-modal-head,
body.is-popout .sign-instructions,
body.is-popout .sign-actions {
  flex-shrink: 0;
}
/* The active step fills the leftover height: the review step scrolls as one,
   the signature step grows its canvas to fill the space. */
body.is-popout #reviewStep:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
body.is-popout #reviewStep .terms-scroll {
  max-height: none;
}
body.is-popout #signStep:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.is-popout #signStep .sign-fields {
  flex: 1 1 auto;
  min-height: 0;
}
body.is-popout #signStep #drawPane {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.is-popout #signStep #drawPane .canvas-wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 260px;
}

/* Toasts */
.toast-stack {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 28px);
  max-width: 460px;
}
.toast {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
  animation: toastIn 0.18s ease;
}
.toast.success {
  background: var(--cw-green-dark);
}
.toast.error {
  background: var(--error-red);
}
.toast.info {
  background: var(--cw-blue);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .sign-modal {
    padding: 14px;
  }
}
