/* ==========================================================================
   Local PDF Sign & Stamp — Iniziativa Studio Workbench Styles
   Built on css/styles.css Liquid Glass design tokens (dark & light themes)
   ========================================================================== */

.signer-container {
  max-width: 1420px;
  margin: 0 auto;
  padding: 0 20px;
}

.signer-hero {
  margin-bottom: 18px;
}

.offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 700;
}

.offline-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 8px var(--brand);
}

/* Dropzone Landing State */
.pdf-dropzone {
  position: relative;
  border: 2px dashed var(--glass-border-strong);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 70% 60% at 50% 0%, rgba(16, 185, 129, 0.14), transparent 65%),
    var(--surface);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: var(--shadow-lg);
  padding: clamp(36px, 6vw, 68px) 24px;
  text-align: center;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  cursor: pointer;
}

.pdf-dropzone:hover,
.pdf-dropzone.drag-active {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 24px 60px -12px rgba(16, 185, 129, 0.28), var(--shadow-lg);
}

.dropzone-icon-wrap {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand);
  box-shadow: var(--glass-specular);
}

.pdf-dropzone h2 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.dropzone-sub {
  margin: 0 auto 24px;
  max-width: 560px;
  color: var(--text-secondary);
  font-size: 0.96rem;
}

.dropzone-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dropzone-trust-row {
  margin: 26px auto 0;
  max-width: 780px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.trust-chip {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  text-align: left;
}

.trust-chip strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 2px;
}

.trust-chip span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Workbench Toolbar */
.signer-toolbar {
  position: sticky;
  top: 66px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  background: rgba(14, 20, 33, 0.86);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
}

[data-theme="light"] .signer-toolbar {
  background: rgba(255, 255, 255, 0.9);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
  margin: 0 2px;
}

.tool-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tool-pill-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--glass-border-strong);
  background: var(--glass-bg-hover);
  transform: translateY(-1px);
}

.tool-pill-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.tool-pill-btn.active {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand);
}

.tool-pill-btn.icon-only {
  min-width: 36px;
  padding: 0 9px;
  justify-content: center;
}

.zoom-readout,
.page-readout {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  padding: 0 6px;
  white-space: nowrap;
}

/* 3-Column Editor Grid */
.signer-grid {
  display: grid;
  grid-template-columns: 174px minmax(0, 1fr) 318px;
  gap: 16px;
  align-items: start;
}

.signer-grid.thumbs-collapsed {
  grid-template-columns: minmax(0, 1fr) 318px;
}

.signer-grid.thumbs-collapsed .signer-thumbs {
  display: none;
}

/* Left Page Thumbnail Rail */
.signer-thumbs {
  position: sticky;
  top: 132px;
  max-height: calc(100vh - 152px);
  overflow-y: auto;
  padding: 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thumb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 2px 4px;
}

.thumb-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: var(--surface-subtle);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  width: 100%;
  color: inherit;
}

.thumb-item:hover {
  border-color: var(--glass-border-strong);
}

.thumb-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.thumb-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.thumb-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.thumb-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--brand);
  color: #032219;
}

/* Center PDF Stage */
.signer-stage-wrap {
  min-width: 0;
  border-radius: var(--radius-lg);
  background: rgba(9, 13, 22, 0.75);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), var(--shadow-md);
  padding: 20px 16px;
  overflow-x: auto;
  min-height: 640px;
}

[data-theme="light"] .signer-stage-wrap {
  background: #e2e8f0;
}

.signer-stage-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.pdf-page-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pdf-page-caption {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-page-stage {
  position: relative;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  overflow: visible;
  user-select: none;
  touch-action: pan-y;
}

.pdf-page-stage.place-armed {
  cursor: crosshair;
}

.pdf-render-canvas {
  display: block;
  border-radius: 4px;
}

.pdf-overlay-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4px;
}

/* Draggable / Resizable Overlays */
.overlay-item {
  position: absolute;
  box-sizing: border-box;
  cursor: move;
  touch-action: none;
  border: 1.5px dashed transparent;
  border-radius: 4px;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.overlay-item:hover {
  border-color: rgba(16, 185, 129, 0.65);
  background-color: rgba(16, 185, 129, 0.05);
}

.overlay-item.selected {
  border: 1.5px solid var(--brand);
  background-color: rgba(16, 185, 129, 0.08);
  z-index: 20;
}

.overlay-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}

.overlay-content img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
}

.overlay-text-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  line-height: 1.24;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
}

/* Handles on Selected Overlay */
.overlay-handle {
  display: none;
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--brand);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

.overlay-item.selected .overlay-handle,
.overlay-item.selected .overlay-rotate-handle,
.overlay-item.selected .overlay-quick-bar {
  display: flex;
}

.overlay-handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.overlay-handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.overlay-handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.overlay-handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

.overlay-rotate-handle {
  display: none;
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.overlay-quick-bar {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  gap: 4px;
  padding: 4px 6px;
  border-radius: var(--radius-pill);
  background: #0b1120;
  border: 1px solid var(--glass-border-strong);
  box-shadow: var(--shadow-lg);
  z-index: 40;
}

.overlay-quick-btn {
  border: none;
  background: transparent;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}

.overlay-quick-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.overlay-quick-btn.danger {
  color: #f87171;
}

/* Right Inspector & Vault Rail */
.signer-inspector {
  position: sticky;
  top: 132px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 152px);
  overflow-y: auto;
  padding-right: 2px;
}

.inspector-card {
  padding: 16px;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  padding: 0;
}

[data-theme="light"] .swatch-btn {
  border-color: rgba(15, 23, 42, 0.22);
}

.swatch-btn:hover {
  transform: scale(1.1);
}

.swatch-btn.active {
  box-shadow: 0 0 0 2.5px var(--surface-solid), 0 0 0 4.5px var(--brand);
}

/* Vault Items List */
.vault-mini-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.vault-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.vault-card-row:hover {
  border-color: var(--brand-border);
}

.vault-thumb-box {
  width: 72px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
  cursor: pointer;
}

.vault-thumb-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.vault-meta {
  min-width: 0;
  flex: 1;
}

.vault-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vault-kind {
  font-size: 0.71rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Quick Stamp Chips */
.stamp-preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.stamp-chip-btn {
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.stamp-chip-btn:hover {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

/* Signature & Stamp Modals */
.modal-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-subtle);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.modal-tab-btn {
  flex: 1;
  min-height: 36px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-tab-btn.active {
  background: var(--brand);
  color: #032219;
}

.sig-pad-wrap {
  position: relative;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--glass-border-strong);
  background: #ffffff;
  overflow: hidden;
  margin-bottom: 12px;
}

.sig-pad-canvas {
  display: block;
  width: 100%;
  height: 200px;
  cursor: crosshair;
  touch-action: none;
}

.sig-pad-baseline {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 42px;
  border-bottom: 1.5px dashed #cbd5e1;
  pointer-events: none;
}

.sig-pad-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.74rem;
  font-weight: 600;
  color: #94a3b8;
  pointer-events: none;
}

.type-font-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.type-font-card {
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: #ffffff;
  color: #0f172a;
  text-align: center;
  cursor: pointer;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.type-font-card:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
}

.type-font-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2.5px rgba(16, 185, 129, 0.3);
}

.type-font-sample {
  font-size: 1.55rem;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-font-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.checker-preview-box {
  margin-top: 12px;
  min-height: 120px;
  max-height: 180px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

.checker-preview-box img {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
}

.pro-inline-gate {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
}

.flatten-option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flatten-radio-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  cursor: pointer;
  margin-bottom: 0;
}

.flatten-radio-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--brand);
  width: auto;
  min-height: auto;
}

.flatten-radio-card strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text);
}

.flatten-radio-card span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 400;
}

input[type="password"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: rgba(5, 8, 15, 0.55);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
}

[data-theme="light"] input[type="password"] {
  background: #ffffff;
}

input[type="file"] {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.84rem;
}

/* Responsive Breakpoints */
@media (max-width: 1180px) {
  .signer-grid {
    grid-template-columns: 148px minmax(0, 1fr) 290px;
  }
}

@media (max-width: 980px) {
  .signer-grid,
  .signer-grid.thumbs-collapsed {
    grid-template-columns: 1fr;
  }
  .signer-thumbs {
    position: static;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
  }
  .thumb-item {
    min-width: 108px;
    max-width: 108px;
  }
  .signer-inspector {
    position: static;
    max-height: none;
  }
  .dropzone-trust-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .signer-toolbar {
    position: static;
  }
  .type-font-grid {
    grid-template-columns: 1fr;
  }
}
