/* Signing pages - shared styles (same file on ShareMyLoan and GuarantorMyLoan).
   The page bodies still use their original class names (row, col-lg-*, form-control, btn)
   and element ids, which the signing scripts rely on - so those are styled here rather than renamed. */

:root {
  --ink: #282560;
  --text: #3d4457;
  --muted: #6b7385;
  --brand: #007e77;
  --brand-dark: #00635d;
  --accent: #19a79f;
  --bg: #f2f5f7;
  --card: #ffffff;
  --line: #dde3ea;
  --focus: rgba(25, 167, 159, 0.35);
  --warn-bg: #fff7e6;
  --warn-line: #f0b44c;
  --warn-text: #7a4b00;
  --error-bg: #fdecec;
  --error-line: #e06363;
  --error-text: #9b1c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); }

/* ---------- header ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand img { display: block; height: 44px; width: auto; }
.help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.help:hover { border-color: var(--accent); }
.help strong { color: var(--brand); font-weight: 600; }

/* ---------- page + card ---------- */
.page {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 40px;
}
.text-center { text-align: center; }

.card h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card h4 {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  margin: 24px 0 8px;
}
.card p { margin: 12px 0; }
.card hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* "Document 1 of 5. ..." line under the heading */
.card h2 + p { margin: 8px 0 4px !important; }
.card h2 + p strong {
  display: inline-block;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card h2 + p + p i { color: var(--muted); font-style: normal; font-size: 15px; }

/* ---------- layout helpers used by the page bodies ---------- */
.row { display: flex; flex-wrap: wrap; justify-content: center; margin: 0; }
.row > [class*="col-"] { width: 100%; padding: 0; }
.row > .col-lg-3 { flex: 0 0 0; }
.col-lg-6 { max-width: 620px; margin: 0 auto; }
.col-lg-12 { flex: 1 1 100%; }
.row > .col-lg-4 { flex: 1 1 0; min-width: 0; }
.form-group { margin-bottom: 16px; text-align: left; }
.form-group .row { gap: 12px; flex-wrap: nowrap; }
.form-group .row > .col-lg-4 { margin-bottom: 0; }

/* ---------- document viewer ---------- */
.card iframe {
  display: block;
  width: 100% !important;
  height: min(70vh, 680px) !important;
  margin: 16px 0 0 !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px;
  background: #eef1f4;
}

/* ---------- notices (pages set color:red inline) ---------- */
.card p[style*="color:red"],
.card p[style*="color: red"] {
  color: var(--warn-text) !important;
  background: var(--warn-bg);
  border-left: 4px solid var(--warn-line);
  border-radius: 8px;
  padding: 12px 16px !important;
  margin: 16px 0 !important;
  text-align: left;
  font-size: 15px;
}
.card p[style*="color:red"][style*="font-weight:bold"],
.card p[style*="color: red"][style*="font-weight: bold"] {
  color: var(--error-text) !important;
  background: var(--error-bg);
  border-left-color: var(--error-line);
  font-weight: 600 !important;
}

/* ---------- forms ---------- */
.card label { color: var(--ink); font-weight: 600; }
.required_field { display: inline; color: var(--error-line); margin-left: 2px; }
.glyphicon { display: none; }
label.error { display: block; color: var(--error-text); font-weight: 500; font-size: 13px; min-height: 0; margin: 4px 0 0; }
.has-error .form-control { border-color: var(--error-line); }

.form-control {
  display: block;
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid #cdd5df;
  border-radius: 10px;
  background-color: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b7385' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }
.form-control:disabled { background-color: #f4f6f8; color: var(--muted); }

/* the "Confirm [ ]" tick box */
.card label:has(> input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}
.card label:has(> input[type="checkbox"]:checked) { border-color: var(--accent); background: #effaf9; }
.card input[type="checkbox"] { width: 22px; height: 22px; margin: 0 !important; accent-color: var(--brand); cursor: pointer; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  min-height: 52px;
  padding: 14px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.05s;
  -webkit-appearance: none;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus); }
.btn:disabled { background: #b8c1cc; cursor: not-allowed; transform: none; }

/* ---------- loading overlay (shown by setting display:block) ---------- */
.loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(20, 22, 48, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.loading-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}
.site-footer .wrap { max-width: 960px; margin: 0 auto; padding: 20px; }
.site-footer p { margin: 4px 0; }

/* ---------- step progress (added by js/sign-ui.js) ---------- */
.steps { max-width: 420px; margin: 0 auto 20px; }
.steps-label { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; margin-bottom: 8px; }
.steps-bar { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.steps-bar li { flex: 1; height: 6px; border-radius: 999px; background: var(--line); }
.steps-bar li.done { background: var(--accent); }
.steps-bar li.current { background: var(--brand); }

/* ---------- signature preview (added by js/sign-ui.js) ---------- */
.sig-preview {
  margin: 4px 0 20px;
  padding: 14px 18px 12px;
  border: 1px dashed #c3ccd7;
  border-radius: 12px;
  background: #fbfcfd;
  text-align: left;
}
.sig-caption { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.sig-ink {
  min-height: 56px;
  padding: 4px 2px 0;
  border-bottom: 2px solid var(--ink);
  color: var(--ink);
  font-family: "Caveat", "Segoe Script", "Bradley Hand", cursive;
  font-size: 40px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.sig-meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.sig-preview.is-empty .sig-ink::before { content: "Type your full name above"; color: #b8c1cc; font-family: "Inter", system-ui, sans-serif; font-size: 15px; line-height: 56px; }

/* ---------- "already signed" page (signed.php) ---------- */
.notice-page { padding: 12px 0 4px; }
.notice-page p { max-width: 520px; margin-left: auto; margin-right: auto; }
.notice-page h2 + p { margin: 12px auto !important; }
.notice-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e3f5f3;
  color: var(--brand);
}
.notice-icon-info { background: var(--warn-bg); color: var(--warn-text); }
.notice-help { color: var(--muted); font-size: 15px; }

/* ---------- confirmation page boxes (inline styled) ---------- */
.card div[style*="border:1px solid #000"] { border-color: var(--line) !important; }
.card div[style*="background:#007E77"] { border-radius: 12px 12px 0 0; letter-spacing: 0.04em; }
.card div[style*="border-top:0"] { border-radius: 0 0 12px 12px; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .site-header .wrap { padding: 10px 16px; }
  .brand img { height: 34px; }
  .help { padding: 7px 12px; font-size: 13px; }
  .help-label { display: none; }
  .page { padding: 16px 12px 32px; }
  .card { padding: 24px 18px; border-radius: 12px; }
  .card h2 { font-size: 24px; }
  .card iframe { height: 65vh !important; }
  .form-group .row { gap: 8px; }
  .form-control { padding: 0 10px; }
  select.form-control { padding-right: 28px; background-position: right 10px center; }
}
