/* =========================
   Base layout (your styles)
   ========================= */
*,
*::before,
*::after { box-sizing: border-box; }

.wrapper { display: flex; justify-content: center; }
.text-box { margin-top: 0px; }

.container-div {
  display: flex;
  flex-wrap: wrap;
  max-width: 1340px;
  margin: 0 auto;
  background: white;
  padding: 20px;
  border-radius: 6px;
}
.full-width {
  flex: 0 0 100%;
  padding: 0 20px!important;
  margin-top: -30px;
  border-radius: 4px;
}
.half60 { flex: 0 0 calc(60% - 10px); padding: 20px; }
.half40 { flex: 0 0 calc(40% - 10px); padding: 20px; }

.half40 img {
  max-width: 65%;
  height: auto;
  display: block;
  margin: 0 auto;
  padding-top: 40px;
}

.form-group { margin-bottom: 15px; }
label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  text-transform: none;
  margin-top: 10px;
}
input {
  width: 50%;
  padding: 8px;
  box-sizing: border-box;
}
.mobile { display: none; visibility: hidden; }
.desktop { display: block; visibility: visible; }
p { margin: 0 0 1em 0; }

/* Responsive */
@media (max-width: 768px) {
  .container-div { width: 100%; }
  .half60 { flex: 0 0 100%; padding: 10px; }
  .mobile {
    display: block; visibility: visible;
    width: 40%; height: auto; float: right; padding: 10px;
  }
  .desktop { display: none; visibility: hidden; }
  input { width: 100%; }
}

/* =========================
   Fonts (your overrides)
   ========================= */
@font-face {
  font-family: "Open Sans";
  src: local("OpenSans Regular"), local("OpenSans-Regular"),
       url("/fonts/OpenSans-Regular.ttf") format("truetype");
  font-style: normal; font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("/fonts/OpenSans-Bold.ttf") format("truetype");
  font-style: normal; font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/Poppins-SemiBold.ttf") format("truetype");
  font-style: normal; font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/OpenSans-Regular.ttf") format("truetype");
  font-style: normal; font-weight: 400; font-display: swap;
}

/* =========================
   Modal + Signature styles
   ========================= */

/* Utilities */
.hidden{display:none}
.disabled{opacity:.6;pointer-events:none}
.err-inline{color:#b00020;margin-top:8px}
.locked-note{color:#b00020;font-weight:700}

/* Backdrop and modal (custom, not Bootstrap's .modal) */
#sig-modal.modal-backdrop {
  display: none; /* JS sets to flex when open */
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#sig-modal .modal {
  background:#fff;
  border-radius:10px;
  width:min(640px,96%);
  max-height: 94vh;
  padding:16px;
  box-shadow:0 12px 44px rgba(0,0,0,.25);
  overflow:auto;
}

/* Agreement area */
.sig-agreement{
  max-height: 52vh;
  overflow:auto;
  padding:0;
  margin-bottom:12px;
  border-bottom:1px solid #eee;
  -webkit-overflow-scrolling: touch;
}
.sig-agreement h4{ margin:12px 0 6px; font-size:15px; }
.sig-agreement p{ margin:0 0 10px; line-height:1.45; }

/* Consent row: flush-left checkbox + text */
.sig-consent{
  display:flex;
  align-items:center;
  gap:10px;
  margin:8px 0 0;
  padding:0 !important;
  position: static !important;
}
.sig-consent input[type="checkbox"]{
  margin:0 !important;
  width:16px; height:16px; flex-shrink:0;
}
.sig-consent span{ font-weight:600; }

/* Signature block: timestamp + hint above canvas; canvas bordered */
.sig-wrap{ padding:0; background:transparent; border:0; }
.sig-meta{
  display:flex; justify-content:space-between; align-items:center;
  margin:0 0 8px 0; font-size:14px;
}
.sig-hint{
  position:static; margin:0 0 6px 2px; color:#6a7c75; font-size:12px; pointer-events:none;
}
#sig-canvas{
  width:100%; height:120px;
  display:block; background:#fff;
  border:1px dashed #3b7a57; border-radius:8px;
  touch-action:none;
}

/* Action buttons row */
.actions{ display:flex; gap:8px; justify-content:flex-end; margin-top:12px; }

/* Lock page scroll when modal is open (desktop + iOS) */
body.modal-open {
  overflow: hidden;
  position: relative;
  width: 100%;
}
@supports (-webkit-touch-callout: none) {
  body.modal-open { height: 100vh; }
}

/* Prevent background scroll chaining when modal open */
#sig-modal { overscroll-behavior: contain; }
#sig-modal .modal { overscroll-behavior: contain; }

/* =========================
   Mobile optimizations
   ========================= */
@media (max-width: 700px) {

  #sig-modal .modal {
    width: 95%;
    max-height: 92vh;
    padding: 14px;
    overflow: hidden;          /* modal itself doesn't scroll; inner areas do */
    display: flex;
    flex-direction: column;
  }

  /* Only the agreement scrolls on small screens */
  .sig-agreement {
    flex: 1 1 auto;
    max-height: 45vh;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 6px;
  }

  .sig-consent { align-items:flex-start; }
  .sig-consent span {
    white-space: normal;       /* allow wrapping on phones */
    font-size: 14px;
    line-height: 1.3;
  }
  .sig-consent input[type="checkbox"] { width:18px; height:18px; margin-top: 3px !important; }

  .sig-meta { font-size: 13px; margin-bottom: 6px; }
  .sig-hint { font-size: 12px; margin-bottom: 6px; }

  #sig-canvas { height: 135px; }

  .actions { flex-wrap: wrap; gap: 8px; }
  .actions button { flex: 1 1 auto; min-width: 110px; }
}

@media (max-width: 600px) {
  #sig-canvas { height: 120px; }
}

/* Desktop: keep consent text to one line if there's space */
@media (min-width: 601px) {
  .sig-consent span { white-space: nowrap; }
}

/* MAKE OUR MODAL VISIBLE ABOVE BOOTSTRAP */
#sig-modal .modal {
  display: block !important;   /* override Bootstrap's display:none */
  position: relative;          /* not fixed; we center via the parent flex */
  margin: 0;                   /* no stray margins */
  z-index: 10000;              /* above the backdrop */
}

/* Reduce signature modal title size by ~50% */
#sig-modal .modal h3#sigTitle {
    font-size: 1.6rem;   /* down from ~1.8rem → half-size */
    line-height: 1.2;
    font-weight: 700;    /* keep it crisp */
    margin-bottom: 8px;
}

/* Remove inner scrollbars entirely */
.sig-agreement {
  max-height: none !important;
  overflow: visible !important;
}

/* Signature block never scrolls independently */
.sig-wrap {
  overflow: visible !important;
}

/* Allow the entire modal to scroll if needed */
#sig-modal .modal {
  max-height: 90vh;        /* modal fits on screen */
  overflow-y: auto;        /* only scrollbar we want */
  -webkit-overflow-scrolling: touch;
}

/* Keep hint, canvas, and timestamp clean */
.sig-meta {
  margin-bottom: 8px;
}
.sig-hint {
  top: 14px;
}
