/* eSign Processor Styles */
.esign-processor {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Upload Section */
.upload-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.upload-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.upload-header h2 {
  margin: 0;
  color: var(--title-color);
  font-size: 1.5rem;
}

.file-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.file-tag {
  background: var(--accent);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-tag .remove-tag {
  cursor: pointer;
  font-weight: bold;
}

/* Drop Area */
.drop-area {
  border: 2px dashed #ccc;
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  background: #fafafa;
}

.drop-area:hover,
.drop-area.drag-over {
  border-color: var(--accent);
  background: #f0f8ff;
}

.drop-area.drag-over {
  transform: scale(1.02);
}

.drop-content {
  pointer-events: none;
}

.file-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.file-info {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 500;
}

.browse-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  pointer-events: all;
}

.upload-footer {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.merge-button, .primary-btn, .download-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1rem; /* smaller button */
  border-radius: var(--radius);
  font-size: 0.95rem; /* slightly smaller font */
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.merge-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.merge-button:not(:disabled):hover,
.primary-btn:hover,
.download-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.merge-button svg,
.primary-btn svg,
.download-button svg {
  width: 18px; /* slightly smaller icon */
  height: 18px;
}

/* Signature Configuration Section */
.signature-config-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.signature-config-section h2 {
  margin: 0 0 1.5rem 0;
  color: var(--title-color);
  font-size: 1.5rem;
}

.config-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.signer-management h3,
.signature-options h3 {
  margin: 0 0 1rem 0;
  color: var(--text);
  font-size: 1.2rem;
}

.signer-form {
  margin-bottom: 1.5rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(38, 105, 105, 0.2);
}

.add-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.add-btn:hover {
  background: var(--accent-strong);
}

.add-btn svg {
  width: 16px;
  height: 16px;
}

.signers-list {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 1rem;
  min-height: 100px;
}

.signer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.signer-info {
  display: flex;
  flex-direction: column;
}

.signer-name {
  font-weight: 600;
  color: var(--text);
}

.signer-email {
  font-size: 0.9rem;
  color: var(--muted);
}

.remove-signer {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.remove-signer:hover {
  background: #c82333;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 1rem;
}

.checkbox-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.config-footer {
  display: flex;
  justify-content: center;
}

/* Send Section */
.send-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.send-section h2 {
  margin: 0 0 1.5rem 0;
  color: var(--title-color);
  font-size: 1.5rem;
}

.send-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.message-section h3,
.send-summary h3 {
  margin: 0 0 1rem 0;
  color: var(--text);
  font-size: 1.2rem;
}

.message-textarea {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

.message-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(38, 105, 105, 0.2);
}

.summary-content {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 6px;
  min-height: 120px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.summary-label {
  font-weight: 600;
  color: var(--text);
}

.summary-value {
  color: var(--muted);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  width: 90%;
  max-width: 1200px;
  max-height: 90%;
  display: flex;
  flex-direction: column;
}

.signature-modal {
  max-width: 960px; /* 20px narrower */
  max-height: 94%;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem; /* tighter header padding */
  border-bottom: 1px solid #eee;
}

.modal-title-section {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.modal-title-section h2 {
  margin: 0;
  color: var(--title-color);
  font-size: 1.1rem; /* slightly smaller title */
}

.field-toolbar {
  display: flex;
  gap: 0.5rem;
  background: var(--surface-light);
  padding: 0.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* zoom-controls removed for fixed scale */
.zoom-controls { display: none; }

.zoom-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:hover {
  background: var(--accent);
  color: white;
}

.zoom-btn svg {
  width: 16px;
  height: 16px;
}

/* zoom-level removed for fixed scale */
.zoom-level { display: none; }

.toolbar-btn {
  background: #f8f9fa;
  border: 1px solid #ddd;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: #e9ecef;
}

.toolbar-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem; /* smaller close icon */
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: var(--text);
}

.modal-body {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

.preview-info { display: none; }

.current-signer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.signer-select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.document-canvas-container {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  background: white;
  display: flex;
  justify-content: center;
}

.document-canvas {
  max-width: 100%;
  height: auto;
  cursor: crosshair;
}

.signature-fields-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/*
.signature-field {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(38, 105, 105, 0.1);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  color: var(--accent);
  cursor: move;
  pointer-events: all;
  min-width: 150px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
*/

.signature-field:hover {
  background: rgba(38, 105, 105, 0.2);
}

.signature-field.selected {
  border-color: var(--accent-strong);
  background: rgba(0, 120, 215, 0.1);
}

.modal-footer {
  padding: 0.75rem 1rem; /* tighter footer padding */
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-content {
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-content h3 {
  margin: 0 0 0.5rem 0;
  color: var(--title-color);
}

.loading-content p {
  margin: 0;
  color: var(--muted);
}

/* Toast Styles */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.5rem;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left-color: #28a745;
}

.toast.error {
  border-left-color: #dc3545;
}

.toast.warning {
  border-left-color: #ffc107;
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .config-content,
  .send-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .form-row {
    flex-direction: column;
  }
  
  .modal-content {
    width: 95%;
    margin: 1rem;
  }
  
  .field-toolbar {
    flex-wrap: wrap;
  }
  
  .preview-info {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .esign-processor {
    padding: 0 0.5rem;
  }
  
  .upload-section,
  .signature-config-section,
  .send-section {
    padding: 1.5rem 1rem;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 1rem;
  }
}

/* Multi-page PDF display styles */
.document-pages-container {
  position: relative;
  max-height: calc(70vh + 20px); /* 20px taller cap */
  overflow: auto;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-page-wrapper {
  position: relative;
  margin-bottom: 2rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 1rem;
}

.pdf-page-wrapper:last-child {
  margin-bottom: 0;
}

.page-number {
  position: absolute;
  top: 8px; /* keep inside wrapper so it never hides under header */
  left: 8px;
  background: var(--accent);
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 20; /* above overlays */
  pointer-events: none;
}

.pdf-page-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 4px;
  cursor: crosshair;
}

.page-signature-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
}

/* Enhanced signature field styles for multi-page */
.signature-field .field-label {
  background: white;
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 0.75rem;
  border: 1px solid currentColor;
}

.signature-field .delete-field {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.signature-field .delete-field:hover {
  background: #c82333;
}

/* Field type specific colors for multi-page */
.signature-field[data-field-type="signature"] {
  border-color: var(--accent);
  background: rgba(38, 105, 105, 0.1);
  color: var(--accent);
}

.signature-field[data-field-type="date"] {
  border-color: #28a745;
  background: rgba(40, 167, 69, 0.1);
  color: #28a745;
}

.signature-field[data-field-type="text"] {
  border-color: #6f42c1;
  background: rgba(111, 66, 193, 0.1);
  color: #6f42c1;
}

/* Responsive styles for zoom controls */
@media (max-width: 768px) {
  .modal-title-section {
    gap: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .field-toolbar,
  .zoom-controls {
    width: 100%;
    justify-content: center;
  }
  
  .zoom-level {
    min-width: 50px;
  }
}
