/* Document Signer - Sanders Markets inspired front-end theme. */

.ds-wrap {
  --ds-red: #cf171f;
  --ds-red-dark: #a90f17;
  --ds-red-soft: #fff0f1;
  --ds-ink: #171717;
  --ds-text: #2f3237;
  --ds-muted: #6d737c;
  --ds-line: #dde1e5;
  --ds-line-strong: #b9c0c8;
  --ds-shell: #f4f5f2;
  --ds-surface: #ffffff;
  --ds-fresh: #227a3b;
  --ds-fresh-soft: #e9f6ed;
  --ds-warning: #a90f17;
  --ds-warning-soft: #fff0f1;
  --ds-radius: 8px;
  --ds-radius-sm: 5px;
  --ds-shadow: 0 10px 30px rgba(19, 24, 32, .08);

  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px);
  color: var(--ds-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  box-sizing: border-box;
}

.ds-wrap.ds-is-signing {
  width: min(1240px, calc(100vw - 32px));
  max-width: none;
  margin-right: auto;
  margin-left: auto;
  padding: clamp(10px, 2vw, 24px);
  background: var(--ds-shell);
}

.ds-wrap,
.ds-wrap * {
  box-sizing: border-box;
}

.ds-wrap button,
.ds-wrap input {
  font: inherit;
}

.ds-section-title {
  margin: 0 0 18px;
  padding: 0 0 12px;
  color: var(--ds-ink);
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 800;
  line-height: 1.15;
  border-bottom: 3px solid var(--ds-red);
}

.ds-empty {
  margin: 0;
  padding: 22px;
  color: var(--ds-muted);
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius);
}

.ds-doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 14px;
}

.ds-doc-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  min-height: 150px;
  padding: 18px;
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow);
}

.ds-doc-card::before {
  content: "";
  grid-column: 1 / -1;
  height: 4px;
  margin: -18px -18px 0;
  background: var(--ds-red);
  border-radius: var(--ds-radius) var(--ds-radius) 0 0;
}

.ds-doc-card--no-file {
  opacity: .6;
}

.ds-doc-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--ds-red);
  background: var(--ds-red-soft);
  border-radius: 999px;
}

.ds-doc-info h3 {
  margin: 0 0 4px;
  color: var(--ds-ink);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.25;
}

.ds-doc-info p {
  margin: 0;
  color: var(--ds-muted);
  font-size: 14px;
}

.ds-doc-card .ds-btn,
.ds-no-file {
  grid-column: 1 / -1;
  align-self: end;
}

.ds-no-file {
  color: var(--ds-muted);
  font-size: 13px;
  font-style: italic;
}

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  color: var(--ds-ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  background: var(--ds-surface);
  border: 1px solid var(--ds-line-strong);
  border-radius: var(--ds-radius-sm);
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.ds-btn:hover {
  border-color: var(--ds-red);
}

.ds-btn:focus-visible {
  outline: 3px solid rgba(207, 23, 31, .24);
  outline-offset: 2px;
}

.ds-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.ds-btn-primary {
  color: #fff;
  background: var(--ds-red);
  border-color: var(--ds-red);
}

.ds-btn-primary:hover {
  color: #fff;
  background: var(--ds-red-dark);
  border-color: var(--ds-red-dark);
}

.ds-btn-ghost {
  color: var(--ds-red);
  background: #fff;
}

.ds-btn-sm {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 13px;
}

.ds-viewer-header {
  position: sticky;
  top: var(--wp-admin--admin-bar--height, 0);
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--ds-line);
  border-top: 4px solid var(--ds-red);
  border-radius: var(--ds-radius);
  box-shadow: 0 8px 24px rgba(19, 24, 32, .08);
  backdrop-filter: blur(8px);
}

.ds-viewer-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: end;
  padding: 4px;
  background: var(--ds-shell);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-sm);
}

.ds-viewer-tools .ds-btn {
  width: 36px;
  min-width: 36px;
  padding-right: 0;
  padding-left: 0;
  font-size: 17px;
}

#ds-zoom-label {
  min-width: 48px;
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.ds-viewer-title {
  min-width: 0;
  margin: 0;
  color: var(--ds-ink);
  font-size: clamp(17px, 2vw, 22px);
  font-weight: 800;
  line-height: 1.2;
}

.ds-pdf-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  height: min(780px, calc(100svh - var(--wp-admin--admin-bar--height, 0px) - 138px));
  min-height: 520px;
  margin-bottom: 18px;
  padding: 12px;
  overflow: auto;
  background: linear-gradient(180deg, #edf0f2 0%, var(--ds-shell) 100%);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius);
}

.ds-is-signing .ds-pdf-wrap {
  height: min(800px, calc(100svh - var(--wp-admin--admin-bar--height, 0px) - 138px));
  min-height: 520px;
}

.ds-pdf-loading {
  align-self: stretch;
  padding: 44px 18px;
  color: var(--ds-muted);
  font-size: 15px;
  text-align: center;
}

.ds-pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.ds-pdf-page {
  display: flex;
  justify-content: center;
  width: 100%;
}

.ds-pdf-page-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #cfd5dc;
  border-radius: 3px;
  box-shadow: 0 12px 28px rgba(19, 24, 32, .16);
}

.ds-pdf-page-loading {
  width: min(100%, 720px);
  min-height: 480px;
  display: grid;
  place-items: center;
  color: var(--ds-muted);
  background: #fff;
  border: 1px solid #cfd5dc;
  border-radius: 3px;
}

.ds-docx-viewer {
  width: min(100%, 920px);
  max-height: 72vh;
  overflow: auto;
  padding: clamp(20px, 5vw, 54px);
  color: #111;
  background: #fff;
  border: 1px solid #cfd5dc;
  border-radius: 3px;
  box-shadow: 0 12px 28px rgba(19, 24, 32, .16);
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  text-align: left;
}

.ds-docx-viewer h1,
.ds-docx-viewer h2,
.ds-docx-viewer h3 {
  margin: 1em 0 .45em;
  color: #111;
  line-height: 1.2;
}

.ds-docx-viewer p {
  margin: 0 0 .75em;
}

.ds-docx-viewer table {
  width: 100%;
  margin: 1em 0;
  border-collapse: collapse;
}

.ds-docx-viewer td,
.ds-docx-viewer th {
  padding: 7px 10px;
  vertical-align: top;
  border: 1px solid #cfd5dc;
}

.ds-docx-viewer img {
  max-width: 100%;
  height: auto;
}

.ds-pdf-nav {
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  padding: 8px;
  color: var(--ds-muted);
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--ds-line);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(19, 24, 32, .10);
  backdrop-filter: blur(8px);
}

#ds-page-info {
  min-width: 92px;
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.ds-sign-section {
  padding: clamp(18px, 3vw, 28px);
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow);
}

.ds-sign-section h3 {
  margin: 0 0 6px;
  color: var(--ds-ink);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.ds-sign-intro {
  margin: 0 0 20px;
  padding-bottom: 16px;
  color: var(--ds-muted);
  font-size: 14px;
  border-bottom: 1px solid var(--ds-line);
}

.ds-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ds-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.ds-field label {
  color: var(--ds-ink);
  font-size: 13px;
  font-weight: 750;
}

.ds-req {
  color: var(--ds-red);
}

.ds-field input[type="text"],
.ds-field input[type="email"] {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ds-ink);
  background: #fff;
  border: 1px solid var(--ds-line-strong);
  border-radius: var(--ds-radius-sm);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.ds-field input:focus {
  border-color: var(--ds-red);
  box-shadow: 0 0 0 3px rgba(207, 23, 31, .14);
}

.ds-sig-wrap {
  position: relative;
  width: 100%;
  height: 170px;
  overflow: hidden;
  background: #fff;
  border: 1px dashed var(--ds-line-strong);
  border-radius: var(--ds-radius-sm);
  cursor: crosshair;
}

.ds-sig-wrap::after {
  content: "Sign here";
  position: absolute;
  right: 14px;
  bottom: 10px;
  color: #a8adb4;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

#ds-sig-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#ds-sig-clear {
  width: fit-content;
  margin-top: 8px;
}

.ds-error {
  margin: 0 0 14px;
  padding: 11px 13px;
  color: var(--ds-warning);
  background: var(--ds-warning-soft);
  border: 1px solid rgba(207, 23, 31, .28);
  border-radius: var(--ds-radius-sm);
  font-size: 14px;
  font-weight: 700;
}

#ds-submit-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
}

.ds-success-card {
  padding: 34px 18px;
  text-align: center;
}

.ds-success-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  color: var(--ds-fresh);
  background: var(--ds-fresh-soft);
  border: 2px solid var(--ds-fresh);
  border-radius: 999px;
  font-size: 28px;
  font-weight: 800;
}

.ds-success-card h3 {
  color: var(--ds-fresh);
}

.ds-success-card p {
  margin: 0 auto 20px;
  max-width: 520px;
  color: var(--ds-muted);
}

@media (max-width: 760px) {
  .ds-wrap,
  .ds-wrap.ds-is-signing {
    width: 100vw;
    max-width: none;
    margin-right: calc(50% - 50vw);
    margin-left: calc(50% - 50vw);
    padding: 0 0 32px;
    background: var(--ds-shell);
  }

  #ds-view-list {
    padding: 18px 14px 28px;
  }

  .ds-section-title {
    font-size: 24px;
  }

  .ds-doc-card {
    min-height: 0;
  }

  .ds-viewer-header {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .ds-viewer-tools {
    justify-self: stretch;
    width: 100%;
    justify-content: space-between;
  }

  .ds-viewer-header .ds-btn {
    width: fit-content;
    max-width: 100%;
  }

  .ds-viewer-title {
    font-size: 18px;
  }

  .ds-pdf-wrap {
    height: calc(100svh - var(--wp-admin--admin-bar--height, 0px) - 158px);
    min-height: 440px;
    margin-bottom: 12px;
    padding: 8px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .ds-docx-viewer {
    width: 100%;
    max-height: none;
    min-height: calc(100svh - 126px);
    padding: 20px 16px;
  }

  .ds-pdf-nav {
    width: calc(100vw - 16px);
    justify-content: space-between;
    border-radius: var(--ds-radius);
  }

  #ds-page-info {
    flex: 1;
  }

  .ds-sign-section {
    margin: 0 10px;
    padding: 18px 14px;
  }

  .ds-field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .ds-sig-wrap {
    height: 150px;
  }

  .ds-btn {
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  .ds-pdf-nav .ds-btn {
    min-width: 76px;
    padding-inline: 10px;
  }
}
