/**
 * EsignViewer CSS - Unified Document Viewer Styles
 * Supports single-page and multi-page modes
 */

/* Base container */
.esign-viewer-container {
  position: relative;
  width: 100%;
  min-height: 200px;
  background: #f8f9fa;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
}

.esign-viewer-container canvas {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.esign-viewer-container img {
  max-width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  background: #fff;
}

.esign-viewer-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  color: #0d6efd;
  font-weight: 600;
}

.esign-viewer-error {
  padding: 16px;
  width: 100%;
  border: 1px solid #dc3545;
  background: rgba(220, 53, 69, 0.08);
  color: #842029;
  border-radius: 8px;
  text-align: left;
}

/* Multi-page mode */
.esign-viewer-multipage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 0;
}

.esign-viewer-multipage .pdf-page {
  position: relative;
  margin-bottom: 30px;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 100%;
}

.esign-viewer-multipage .pdf-page:last-child {
  margin-bottom: 0;
}

.esign-viewer-multipage .pdf-canvas {
  display: block;
  width: 100%;
  height: auto; /* Let height be determined by canvas attribute */
  user-select: none;
  pointer-events: none;
}

.esign-viewer-multipage .fieldsContainer,
.esign-viewer-multipage .esign-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  /* pointer-events set dynamically by JS based on renderMode */
}

.esign-viewer-multipage .page-indicator {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #666;
  background: #f8f9fa;
  padding: 2px 10px;
  border-radius: 10px;
}

/* Page separator line */
.esign-viewer-multipage .pdf-page::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #dee2e6, transparent);
}

.esign-viewer-multipage .pdf-page:last-child::after {
  display: none;
}

/* Thumbnail rail */
.esign-thumbnail-rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  overflow-y: auto;
  padding: 10px 5px;
  z-index: 10;
}

.esign-thumbnail {
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 4px;
  margin-bottom: 8px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  font-size: 11px;
  color: #666;
  transition: all 0.2s;
}

.esign-thumbnail:hover {
  border-color: #0d6efd;
  background: #e7f3ff;
}

.esign-thumbnail.active {
  border-color: #0d6efd;
  background: #cfe2ff;
  color: #084298;
  font-weight: 600;
}

/* Builder mode - with thumbnail rail */
.esign-viewer-container.with-thumbnails {
  padding-left: 90px;
}

/* Placed fields (builder mode) */
.placed-field {
  position: absolute;
  border: 2px dashed #0d6efd;
  background: rgba(13, 110, 253, 0.1);
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #0d6efd;
  z-index: 10;
  min-width: 50px;
  min-height: 30px;
  pointer-events: auto;
  transition: background 0.2s, border-color 0.2s;
}

.placed-field:hover {
  background: rgba(13, 110, 253, 0.2);
  border-color: #0842a0;
}

.placed-field.selected {
  border-color: #198754;
  background: rgba(25, 135, 84, 0.15);
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.3);
}

.placed-field .field-label {
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
}

/* Signing mode - interactive fields */
.field-overlay {
  position: absolute;
  border: 2px solid #667eea;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #667eea;
  transition: all 0.2s;
  pointer-events: auto;
}

.field-overlay:hover {
  background: rgba(102, 126, 234, 0.2);
}

.field-overlay.filled {
  background: rgba(25, 135, 84, 0.1);
  border-color: #198754;
  color: #198754;
}

.field-overlay.required::before {
  content: '*';
  position: absolute;
  top: -8px;
  right: -8px;
  color: #dc3545;
  font-size: 16px;
  font-weight: bold;
}

.field-overlay input,
.field-overlay textarea {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 4px;
  font-size: inherit;
}

.field-overlay input:focus,
.field-overlay textarea:focus {
  outline: none;
  background: white;
}

.field-overlay.signature-field,
.field-overlay.initials-field {
  font-family: 'Brush Script MT', cursive;
  font-size: 18px;
}

.field-overlay.checkbox-field {
  justify-content: center;
}

.field-overlay.checkbox-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Resize handle */
.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #0d6efd;
  border: 1px solid white;
  border-radius: 50%;
}

.resize-handle.se {
  bottom: -5px;
  right: -5px;
  cursor: se-resize;
}
