/* ==========================================================================
   BuyerForesight eSign — Main Stylesheet
   Purple-branded DocuSign-like eSignature application
   ========================================================================== */

/* -----------------------------------------------------------------------
   1. RESET & CUSTOM PROPERTIES
   ----------------------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* BuyerForesight purple palette */
  --primary: #5B21B6;
  --primary-dark: #4C1D95;
  --primary-light: #7C3AED;
  --primary-bg: #ede9fe;
  --primary-ring: rgba(91, 33, 182, 0.12);

  /* Semantic colours */
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #ea580c;
  --warning-bg: #fff7ed;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --blue: #2563eb;
  --blue-bg: #eff6ff;

  /* Neutrals */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Radii & shadows */
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -----------------------------------------------------------------------
   2. HEADER & NAVIGATION
   ----------------------------------------------------------------------- */
header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
  white-space: nowrap;
  text-decoration: none;
}
.logo em { font-style: normal; color: var(--primary); }
.logo-icon { flex-shrink: 0; }
.logo-icon svg { display: block; }

nav { display: flex; gap: 4px; }

.nav-btn {
  background: none;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-500);
  font-family: var(--font);
  transition: color 0.15s, background 0.15s;
}
.nav-btn:hover { color: var(--gray-900); background: var(--gray-100); }
.nav-btn.active { color: var(--primary); background: var(--primary-bg); font-weight: 500; }

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--gray-500);
}

/* -----------------------------------------------------------------------
   3. BUTTONS
   ----------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--gray-700);
  line-height: 1.4;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn:active { transform: translateY(1px); }

.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-full { width: 100%; }

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

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

/* -----------------------------------------------------------------------
   4. FORM INPUTS
   ----------------------------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
.sig-input,
.select-input {
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  width: 100%;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus,
textarea:focus,
.sig-input:focus,
.select-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.input-lg { padding: 14px 16px; font-size: 16px; }
.select-input { appearance: none; cursor: pointer; }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; }
.help-text { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
label { font-size: 14px; font-weight: 500; color: var(--gray-700); display: block; margin-bottom: 4px; }

/* -----------------------------------------------------------------------
   5. AUTH VIEW
   ----------------------------------------------------------------------- */
.auth-container {
  max-width: 420px;
  margin: 80px auto;
  padding: 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-logo { margin-bottom: 16px; }
.auth-container h1 { font-size: 24px; color: var(--gray-900); margin-bottom: 4px; }
.auth-container h1 em { font-style: normal; color: var(--primary); }
.subtitle { color: var(--gray-500); margin-bottom: 24px; font-size: 14px; }

.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
}
.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.invite-only-notice {
  text-align: center;
  padding: 12px;
  background: var(--primary-bg);
  border: 1px solid #c4b5fd;
  border-radius: var(--radius);
  color: var(--primary-dark);
  font-size: 13px;
  margin-top: 12px;
}

/* -----------------------------------------------------------------------
   6. LAYOUT CONTAINERS
   ----------------------------------------------------------------------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.section-header h2 { font-size: 22px; font-weight: 700; }
.view-subtitle { color: var(--gray-500); font-size: 14px; margin-top: 2px; }

/* -----------------------------------------------------------------------
   7. DASHBOARD — FILTERS & ENVELOPE LIST
   ----------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-btn,
.filter-bar .pill {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--gray-300);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--gray-700);
  font-family: var(--font);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-btn:hover,
.filter-bar .pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active,
.filter-bar .pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.envelope-list {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}

.envelope-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  gap: 16px;
  transition: background 0.1s;
}
.envelope-row:last-child { border-bottom: none; }
.envelope-row:hover { background: var(--gray-50); }

.envelope-row .envelope-title {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.envelope-row .envelope-recipients {
  font-size: 13px;
  color: var(--gray-500);
  width: 120px;
  flex-shrink: 0;
}
.envelope-row .envelope-meta {
  font-size: 13px;
  color: var(--gray-500);
  flex-shrink: 0;
}
.envelope-row .envelope-date {
  font-size: 13px;
  color: var(--gray-500);
  width: 130px;
  flex-shrink: 0;
  text-align: right;
}

/* -----------------------------------------------------------------------
   8. STATUS BADGES
   ----------------------------------------------------------------------- */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
  flex-shrink: 0;
}
.status-draft    { background: var(--gray-100); color: var(--gray-700); }
.status-sent     { background: var(--blue-bg);  color: var(--blue); }
.status-pending  { background: var(--primary-bg); color: var(--primary-light); }
.status-completed { background: var(--success-bg); color: var(--success); }
.status-signed   { background: var(--success-bg); color: var(--success); }
.status-declined { background: var(--danger-bg); color: var(--danger); }
.status-voided   { background: var(--gray-100); color: var(--gray-500); text-decoration: line-through; }

/* -----------------------------------------------------------------------
   9. ENVELOPE DETAIL
   ----------------------------------------------------------------------- */
.back-btn { margin-bottom: 20px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 24px;
  gap: 16px;
}
.detail-header h2 { font-size: 22px; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
}
.detail-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--gray-700);
}
.detail-section.full-width { grid-column: 1 / -1; }

.signer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.signer-item:last-child { border-bottom: none; }
.signer-info { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.signer-info small { color: var(--gray-500); display: block; }
.signer-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.signer-link { font-size: 13px; color: var(--primary); word-break: break-all; }

.audit-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.audit-item:last-child { border-bottom: none; }
.audit-item .action { font-weight: 500; }
.audit-item .time { color: var(--gray-500); font-size: 12px; }

/* -----------------------------------------------------------------------
   10. WIZARD VIEW — STEPPER
   ----------------------------------------------------------------------- */
.wizard-header {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 24px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  min-width: 120px;
}

/* Connecting line between steps */
.wizard-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 20px);
  width: calc(100% - 40px);
  height: 2px;
  background: var(--gray-300);
  transition: background 0.3s;
}
.wizard-step.completed:not(:last-child)::after {
  background: var(--success);
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  position: relative;
  z-index: 1;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
}

/* Active step: purple circle */
.wizard-step.active .step-circle {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--primary-ring);
}

/* Completed step: green circle (checkmark provided by HTML) */
.wizard-step.completed .step-circle {
  background: var(--success);
  color: #fff;
}

.step-label {
  font-size: 12px;
  color: var(--gray-500);
  text-align: center;
  font-weight: 500;
}
.wizard-step.active .step-label { color: var(--primary); font-weight: 600; }
.wizard-step.completed .step-label { color: var(--success); }

.wizard-panel {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.wizard-form {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* -----------------------------------------------------------------------
   11. WIZARD — FILE DROP ZONE
   ----------------------------------------------------------------------- */
.file-drop {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--primary);
  background: rgba(91, 33, 182, 0.03);
}
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-drop p { color: var(--gray-500); font-size: 14px; }
.file-drop .drop-icon { font-size: 32px; margin-bottom: 8px; color: var(--gray-400); }

/* -----------------------------------------------------------------------
   12. WIZARD — DOCUMENT & RECIPIENT LISTS
   ----------------------------------------------------------------------- */
.doc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.doc-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
}
.doc-list-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.doc-list-name { font-weight: 500; }
.doc-list-pages { font-size: 12px; color: var(--gray-500); }
.doc-list-item .remove-doc,
.doc-list-item .btn {
  flex-shrink: 0;
}
.doc-list-item .remove-doc {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
}
.doc-list-item .remove-doc:hover { color: var(--danger); }

.recipients-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
/* -----------------------------------------------------------------------
   13. FIELD EDITOR (Step 3) — LAYOUT
   ----------------------------------------------------------------------- */
.field-editor {
  display: flex;
  height: calc(100vh - 170px);
  min-height: 500px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Left sidebar — 260px */
.field-sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.field-sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.field-sidebar-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 10px;
}

/* Recipient selector buttons */
.field-recipient-selector {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recipient-select-btn,
.field-recipient-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  text-align: left;
  color: var(--gray-700);
  transition: background 0.1s, border-color 0.1s;
}
.recipient-select-btn:hover,
.field-recipient-btn:hover { background: var(--gray-50); }
.recipient-select-btn.active,
.field-recipient-btn.active {
  background: var(--gray-50);
  border-color: var(--gray-300);
  font-weight: 600;
}

/* Field type buttons in grid */
.field-types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.field-type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  cursor: grab;
  font-size: 12px;
  font-family: var(--font);
  color: var(--gray-700);
  user-select: none;
  transition: border-color 0.1s, color 0.1s, box-shadow 0.1s;
}
.field-type-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.field-type-btn:active { cursor: grabbing; }
.field-type-btn.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}
.field-type-btn .icon,
.field-type-btn .ft-icon { font-size: 14px; flex-shrink: 0; display: flex; align-items: center; }

.field-sidebar-actions {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
}
.field-sidebar-actions .btn { flex: 1; }

/* -----------------------------------------------------------------------
   14. FIELD EDITOR — PDF CANVAS AREA
   ----------------------------------------------------------------------- */
.field-canvas-area {
  flex: 1;
  overflow-y: auto;
  background: var(--gray-100);
}

.pdf-pages {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.pdf-page-wrapper {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-md);
  border-radius: 2px;
  max-width: 900px;
  width: 100%;
  overflow: visible;
}
.pdf-page-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* -----------------------------------------------------------------------
   15. PLACED FIELDS (editor — absolute inside pdf-page-wrapper)
   ----------------------------------------------------------------------- */
.placed-field {
  position: absolute;
  border: 2px solid var(--primary);
  border-radius: 3px;
  background: rgba(91, 33, 182, 0.06);
  cursor: move;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  min-width: 30px;
  min-height: 20px;
  transition: box-shadow 0.1s, border-color 0.1s;
}
.placed-field:hover {
  box-shadow: 0 0 0 2px rgba(91, 33, 182, 0.2);
}
.placed-field.selected {
  border-width: 3px;
  box-shadow: 0 0 0 3px rgba(91, 33, 182, 0.15);
}

/* Label tag above the field */
.placed-field .field-label {
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 9px;
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px 3px 0 0;
  white-space: nowrap;
  pointer-events: none;
}

/* Delete button — shown on hover */
.placed-field .field-delete {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
}
.placed-field:hover .field-delete { display: flex; }

/* Resize handle — shown when selected */
.placed-field .resize-handle {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 2px;
  cursor: nwse-resize;
  display: none;
}
.placed-field.selected .resize-handle { display: block; }

/* Field type variants */
.placed-field.type-signature,
.placed-field.type-initials { border-style: dashed; }
.placed-field.type-text { border-width: 1px; }
.placed-field.type-checkbox {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border-radius: 3px;
}

/* -----------------------------------------------------------------------
   16. SIGNING VIEW
   ----------------------------------------------------------------------- */
.signing-chrome {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--gray-100);
}

/* Topbar */
.signing-topbar {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  gap: 16px;
  flex-shrink: 0;
}
.signing-topbar .logo { font-size: 15px; }
.signing-topbar .doc-info {
  flex: 1;
  font-size: 14px;
  color: var(--gray-700);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signing-topbar .signing-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Progress bar */
.signing-progress {
  height: 3px;
  background: var(--gray-200);
  flex-shrink: 0;
}
.signing-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* Scrollable PDF area */
.signing-pdf-pages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.signing-page-wrapper {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-md);
  border-radius: 2px;
  max-width: 900px;
  width: 100%;
}
.signing-page-wrapper canvas { display: block; width: 100%; height: auto; }

/* -----------------------------------------------------------------------
   17. SIGNING FIELDS
   ----------------------------------------------------------------------- */
.signing-field {
  position: absolute;
  border: 2px solid var(--primary-light);
  border-radius: 4px;
  background: rgba(124, 58, 237, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--primary);
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.signing-field:hover { background: rgba(124, 58, 237, 0.14); }

/* Unfilled — pulsing animation */
.signing-field.unfilled {
  animation: fieldPulse 2s ease-in-out infinite;
}
@keyframes fieldPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.3); }
  50%      { box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.08); }
}

.signing-field.signature,
.signing-field.initials { border-style: dashed; }

.signing-field .placeholder-text {
  font-size: 11px;
  color: var(--primary-light);
  font-weight: 500;
}

/* Filled / completed — green border */
.signing-field.filled,
.signing-field.completed {
  border-style: solid;
  border-color: var(--success);
  background: rgba(22, 163, 74, 0.05);
  cursor: default;
  animation: none;
}
.signing-field.completed img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.signing-field.completed .field-value {
  font-size: 13px;
  color: var(--gray-900);
}

/* -----------------------------------------------------------------------
   18. SIGNATURE MODAL
   ----------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.2s ease;
}
@keyframes modalSlideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-lg { max-width: 640px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--gray-900); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

/* Signature tabs */
.sig-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.sig-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--gray-300);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sig-tab:hover { border-color: var(--primary); }
.sig-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Signature canvas with crosshair */
#signature-canvas {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  cursor: crosshair;
  display: block;
  width: 100%;
  height: 150px;
  margin-bottom: 8px;
  background: #fff;
}

.typed-preview {
  font-family: 'Brush Script MT', 'Segoe Script', cursive;
  font-size: 32px;
  padding: 20px;
  text-align: center;
  min-height: 80px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  margin-top: 12px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sig-actions { margin-top: 24px; display: flex; gap: 8px; }

/* -----------------------------------------------------------------------
   19. ACCESS CODE & SIGNING DONE VIEWS
   ----------------------------------------------------------------------- */
.access-code-container {
  max-width: 400px;
  margin: 120px auto;
  padding: 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.access-code-container h2 { margin-bottom: 8px; }
.access-code-container p { color: var(--gray-500); margin-bottom: 24px; font-size: 14px; }
.access-code-container input {
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 4px;
  font-size: 20px;
}

.signing-done {
  max-width: 480px;
  margin: 120px auto;
  padding: 48px 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.signing-done .checkmark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 20px;
  border: 3px solid var(--success);
}
.signing-done h2 { font-size: 22px; margin-bottom: 8px; color: var(--gray-900); }
.signing-done p { color: var(--gray-500); font-size: 15px; }

/* -----------------------------------------------------------------------
   20. ADMIN PANEL
   ----------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray-200);
}
.admin-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.admin-tab:hover { color: var(--gray-700); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table td { padding: 12px 16px; border-top: 1px solid var(--gray-100); }
.admin-table tr:hover td { background: var(--gray-50); }

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.role-admin { background: var(--primary-bg); color: var(--primary-light); }
.role-user  { background: var(--gray-100); color: var(--gray-700); }

.status-active   { color: var(--success); }
.status-inactive { color: var(--danger); }

/* -----------------------------------------------------------------------
   21. DOCUMENTS GRID (legacy cards)
   ----------------------------------------------------------------------- */
.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.doc-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.doc-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.doc-card h3 { font-size: 16px; font-weight: 600; word-break: break-word; }
.doc-card .meta { font-size: 13px; color: var(--gray-500); margin-top: 8px; }

.progress-bar { height: 4px; background: var(--gray-200); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }

/* -----------------------------------------------------------------------
   22. SIGNING LINKS & COPY
   ----------------------------------------------------------------------- */
.signing-links { margin-top: 16px; }
.signing-link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
}
.signing-link-item a { color: var(--primary); word-break: break-all; }
.copy-btn {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  flex-shrink: 0;
  margin-left: 8px;
}
.copy-btn:hover { text-decoration: underline; }

.signer-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.signer-row input { flex: 1; }
.remove-signer {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------
   23. TOAST NOTIFICATIONS
   ----------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-width: 400px;
  animation: toastSlideIn 0.3s ease;
}
.toast.error   { background: var(--danger); }
.toast.success { background: var(--success); }

@keyframes toastSlideIn {
  from { transform: translateX(100%) translateY(0); opacity: 0; }
  to   { transform: translateX(0) translateY(0); opacity: 1; }
}

/* -----------------------------------------------------------------------
   24. UTILITIES
   ----------------------------------------------------------------------- */
.hidden { display: none !important; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
  font-size: 15px;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; color: var(--gray-300); }

.file-name { font-size: 13px; color: var(--gray-700); margin-bottom: 12px; }

/* -- Toast fade out -- */
.toast.fade-out {
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
}

/* -- Loading indicator -- */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  color: var(--gray-500);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -- Drop target highlight on PDF pages -- */
.pdf-page-wrapper.drop-target {
  outline: 3px dashed var(--primary);
  outline-offset: 2px;
}

/* -- Page label above each PDF page -- */
.page-label {
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
  padding: 8px 0 4px;
  font-weight: 500;
}

/* -- Field inner label (shown inside the field) -- */
.placed-field .field-inner-label {
  font-size: 10px;
  color: inherit;
  opacity: 0.7;
  pointer-events: none;
}

/* -- Recipient dot in selector -- */
.recipient-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* -- Field count badge -- */
.field-count {
  margin-left: auto;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* -- Button outline-danger variant -- */
.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}
.btn-outline-danger:hover {
  background: var(--danger-bg);
}

/* -- Modal backdrop -- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}
.modal .modal-content {
  position: relative;
  z-index: 1;
}

/* -- Review card -- */
.review-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.review-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}
.review-header h4 { font-size: 18px; margin-bottom: 4px; }
.review-message { color: var(--gray-500); font-size: 14px; margin-top: 4px; }
.review-section {
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-100);
}
.review-section:last-child { border-bottom: none; }
.review-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 10px;
}
.review-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
}
.review-signer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.review-order {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.review-signer-info { font-size: 14px; }
.review-field-count {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 1px 8px;
  border-radius: 10px;
}
.review-summary-stats {
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: var(--gray-50);
}
.review-stat { font-size: 14px; color: var(--gray-600); }

/* -- Invite success + link box -- */
.invite-success p { color: var(--success); font-weight: 500; margin-bottom: 12px; }
.invite-link-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.invite-link-box input {
  flex: 1;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gray-700);
}

/* -- Status dot for admin table -- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--danger); }

/* -- Action buttons group -- */
.action-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* -- Typed signature display -- */
.typed-sig {
  font-family: 'Brush Script MT', 'Segoe Script', cursive;
  font-size: 18px;
  color: var(--primary-dark);
}

/* -- Signing info in topbar -- */
.signing-info {
  flex: 1;
  text-align: center;
  min-width: 0;
}
.signing-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.signing-sender {
  font-size: 12px;
  color: var(--gray-500);
}

/* -- Recipient role badges in wizard -- */
.recipient-role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}
.role-signer { background: var(--primary-bg); color: var(--primary); }
.role-cc { background: var(--gray-100); color: var(--gray-600); }

/* -- Recipient order badge -- */
.recipient-order {
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}

/* -- Recipient row improvements -- */
.recipient-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
}
.recipient-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.recipient-info { flex: 1; min-width: 0; }
.recipient-name { font-weight: 600; }
.recipient-email { font-size: 12px; color: var(--gray-500); }

/* -- Add recipient form -- */
.add-recipient-form {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.add-recipient-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.add-recipient-row input,
.add-recipient-row select { flex: 1; }

/* -- Document item in detail view -- */
.doc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
.doc-item:last-child { border-bottom: none; }

/* -- Detail message -- */
.detail-message {
  color: var(--gray-500);
  font-size: 14px;
  margin-top: 8px;
}

/* -- Done container -- */
.done-container {
  max-width: 480px;
  margin: 120px auto;
  padding: 48px 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.done-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto 20px;
}
.done-container h2 { font-size: 22px; margin-bottom: 8px; }
.done-container p { color: var(--gray-500); font-size: 15px; }

/* -- Empty state icon -- */
.empty-state svg {
  color: var(--gray-300);
  margin-bottom: 12px;
}

/* -- Signing field img -- */
.signing-field img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* -- Checkbox display -- */
.checkbox-display {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--success);
}

/* -- Drop hint text -- */
.drop-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* -----------------------------------------------------------------------
   25. RESPONSIVE — 1024px BREAKPOINT
   ----------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .field-editor { flex-direction: column; height: auto; min-height: 0; }
  .field-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
    max-height: 260px;
  }
  .field-canvas-area { min-height: 500px; }
  .pdf-pages { min-height: 400px; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* -----------------------------------------------------------------------
   26. RESPONSIVE — 768px BREAKPOINT
   ----------------------------------------------------------------------- */
@media (max-width: 768px) {
  .header-inner { gap: 16px; padding: 0 16px; }
  .container { padding: 16px; }

  .wizard-header { gap: 4px; padding: 16px; flex-wrap: wrap; }
  .wizard-step { min-width: 80px; }
  .wizard-step:not(:last-child)::after { display: none; }

  .documents-grid { grid-template-columns: 1fr; }

  .envelope-row { flex-wrap: wrap; gap: 8px; }
  .envelope-row .envelope-recipients,
  .envelope-row .envelope-date { width: auto; }

  .add-recipient-row { flex-wrap: wrap; }

  .signing-topbar { padding: 0 12px; }
  .signing-pdf-pages { padding: 12px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .modal-content { padding: 20px; width: 95%; }

  .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}
