/* ==========================================================================
   Tool Workspace & Processing Styles (css/tool.css)
   ========================================================================== */

/* Breadcrumb Bar */
.tool-breadcrumb {
  max-width: var(--container-max);
  margin: 18px auto 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tool-breadcrumb a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.tool-breadcrumb a:hover {
  color: var(--brand-primary);
}

.tool-breadcrumb svg {
  width: 14px;
  height: 14px;
}

/* Tool Header Hero */
.tool-hero {
  padding: 32px 24px 20px;
  text-align: center;
  max-width: 820px;
  margin: 0 auto;
}

.tool-hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.tool-hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Workspace Container */
.tool-workspace {
  max-width: 1040px;
  margin: 24px auto 48px;
  padding: 0 24px;
  min-height: 380px;
}

/* Dropzone (Initial State) */
.dropzone-container {
  background: var(--bg-surface);
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.dropzone-container:hover, .dropzone-container.drag-over {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
  transform: scale(1.005);
}

.dropzone-icon-badge {
  width: 72px;
  height: 72px;
  background: var(--brand-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px var(--brand-glow);
  transition: transform var(--transition-normal);
}

.dropzone-container:hover .dropzone-icon-badge {
  transform: translateY(-4px) scale(1.05);
}

.dropzone-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.dropzone-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.btn-upload {
  padding: 14px 36px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 18px var(--brand-glow);
}

.dropzone-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  font-size: 0.82rem;
  color: var(--accent-green);
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

/* Tool Workbench (When files are chosen) */
.workbench-container,
.tool-workbench {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.workbench-container.active {
  display: flex;
  flex-direction: column;
}

.tool-workbench.active {
  display: block;
  padding: 24px;
}

.workbench-container.single-column,
.workbench-container.single-column.active {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
}

@media (min-width: 860px) {
  .workbench-container.active:not(.single-column) {
    display: grid;
    grid-template-columns: 1fr 340px;
  }
}

/* Tool Workbench Components */
.workbench-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.workbench-file-info {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

@media (min-width: 860px) {
  .workbench-layout {
    grid-template-columns: 1fr 340px;
  }
}

.workbench-preview-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.options-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: fit-content;
}

.options-title {
  font-size: 1.1rem;
  font-weight: 750;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.options-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.options-select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.workbench-files-area {
  padding: 28px;
  background: var(--bg-primary);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.workbench-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.files-count-badge {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  flex-grow: 1;
  align-content: start;
}

/* File Card Component */
.file-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.file-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
}

.file-card-preview {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--bg-surface-hover);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
  position: relative;
  border: 1px solid var(--border-subtle);
}

.file-card-preview canvas, .file-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.file-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-size {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.file-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
}

.file-card-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.65);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.file-card-btn:hover {
  background: var(--brand-primary);
}

/* Workbench Settings Sidebar */
.workbench-sidebar {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 28px;
  display: flex;
  flex-direction: column;
}

.sidebar-heading {
  font-size: 1.15rem;
  font-weight: 750;
  margin-bottom: 20px;
}

.options-group {
  margin-bottom: 24px;
}

.options-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.options-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.92rem;
}

.options-input:focus {
  outline: none;
  border-color: var(--brand-primary);
}

.compression-levels {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compression-option {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.compression-option:hover, .compression-option.selected {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.sidebar-actions {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-process {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Processing Overlay State */
.processing-state,
.tool-processing-state {
  display: none;
  padding: 64px 24px;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.processing-state.active,
.tool-processing-state.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 54px;
  height: 54px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 24px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.processing-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.processing-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.progress-bar-container {
  width: 100%;
  max-width: 380px;
  height: 8px;
  background: var(--bg-surface-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-gradient);
  transition: width 0.3s ease;
}

/* Success / Download State */
.download-state,
.tool-download-state {
  display: none;
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.download-state.active,
.tool-download-state.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
}

.download-icon-badge {
  width: 64px;
  height: 64px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.success-checkmark {
  width: 64px;
  height: 64px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 20px;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.download-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.download-stats-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: var(--radius-full);
  margin-bottom: 24px;
}

.download-btn-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 28px;
}

.btn-download-big {
  padding: 16px 42px;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px var(--brand-glow);
}

/* ==========================================================================
   Advanced Drag & Drop Reordering
   ========================================================================== */
.file-card[draggable="true"] {
  cursor: grab;
  user-select: none;
}

.file-card[draggable="true"]:active {
  cursor: grabbing;
}

.file-card.dragging {
  opacity: 0.35;
  transform: scale(0.95);
  border: 2px dashed var(--brand-primary);
}

.file-card.drag-target {
  border: 2px solid var(--accent-blue);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.4);
}

/* ==========================================================================
   e-Sign Studio Components (sign-pdf.html)
   ========================================================================== */
.sign-canvas-wrapper {
  position: relative;
  display: inline-block;
  background: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  border-radius: var(--radius-sm);
  overflow: visible;
  max-width: 100%;
  user-select: none;
  -webkit-user-select: none;
}

#signPdfCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.sign-stamp-overlay {
  position: absolute;
  top: 100px;
  left: 100px;
  width: 160px;
  height: 70px;
  border: 2px dashed #EF4444;
  background: rgba(239, 68, 68, 0.06);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  z-index: 50;
  box-sizing: border-box;
}

.sign-stamp-overlay:hover {
  border-color: #2563EB;
  background: rgba(37, 99, 235, 0.08);
}

.sign-stamp-overlay.is-dragging {
  cursor: grabbing !important;
  border-color: #2563EB;
  background: rgba(37, 99, 235, 0.14);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
}

.sign-stamp-overlay.is-resizing {
  border-color: #10B981;
  background: rgba(16, 185, 129, 0.1);
}

.sign-stamp-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  display: block;
}

/* Drag Pill Badge */
.stamp-drag-pill {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1E293B;
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  letter-spacing: 0.02em;
  opacity: 0.9;
}

/* Corner Resize Handles */
.stamp-resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #EF4444;
  border: 2.5px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 60;
  touch-action: none;
}

.stamp-resize-handle::after {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  cursor: inherit;
}

.stamp-resize-handle.se {
  bottom: -8px;
  right: -8px;
  cursor: nwse-resize;
}

.stamp-resize-handle.sw {
  bottom: -8px;
  left: -8px;
  cursor: nesw-resize;
}

.stamp-resize-handle.ne {
  top: -8px;
  right: -8px;
  cursor: nesw-resize;
}

.stamp-resize-handle.nw {
  top: -8px;
  left: -8px;
  cursor: nwse-resize;
}

.stamp-resize-handle:hover,
.stamp-resize-handle:active {
  background: #2563EB;
  transform: scale(1.2);
}

.sign-pad-container {
  background: #FFFFFF;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.sign-pad-container::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 32px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.45);
  pointer-events: none;
}

#signatureDrawingCanvas {
  width: 100%;
  height: 180px;
  background: #FFFFFF;
  cursor: crosshair;
  display: block;
  touch-action: none;
}

.sign-color-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.color-dot.active {
  border-color: var(--brand-primary);
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Text Extractor & Inspector (pdf-to-text.html)
   ========================================================================== */
.text-stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: var(--bg-surface-hover);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.text-stat-badge {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.text-stat-badge span {
  color: var(--brand-primary);
  font-size: 0.95rem;
}

.text-display-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  height: 480px;
  overflow-y: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-primary);
}

/* ==========================================================================
   Metadata Inspector & Sanitizer (pdf-metadata.html)
   ========================================================================== */
.metadata-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.metadata-table th, .metadata-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
}

.metadata-table th {
  color: var(--text-muted);
  font-weight: 600;
  width: 35%;
}

.metadata-table td input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-primary);
}

/* ==========================================================================
   Tool Workspace Mobile & Tablet Optimization
   ========================================================================== */
@media (max-width: 860px) {
  .tool-hero {
    padding: 24px 16px 14px;
  }
  .tool-hero h1 {
    font-size: clamp(1.65rem, 5.5vw, 2.25rem);
  }
  .tool-hero p {
    font-size: 0.92rem;
    line-height: 1.5;
  }
  .tool-breadcrumb {
    padding: 0 16px;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }
  .tool-workspace {
    padding: 0 16px 36px;
    margin: 16px auto 32px;
    min-height: auto;
  }
  .dropzone-container {
    padding: 36px 16px;
  }
  .dropzone-icon-badge {
    width: 60px;
    height: 60px;
    margin-bottom: 18px;
  }
  .dropzone-title {
    font-size: 1.25rem;
  }
  .dropzone-subtitle {
    font-size: 0.88rem;
    margin-bottom: 20px;
  }
  .btn-upload {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
  }
  .workbench-container,
  .tool-workbench {
    padding: 16px;
  }
  .workbench-layout {
    grid-template-columns: 1fr !important;
    gap: 18px;
  }
  .workbench-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .workbench-files-area {
    padding: 16px;
    min-height: auto;
  }
  .workbench-sidebar {
    padding: 16px;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }
  .files-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .file-card {
    padding: 10px;
  }
  .options-card {
    padding: 18px 14px;
  }
  .options-select,
  .options-input {
    font-size: 16px; /* Prevents auto zoom on iOS */
    padding: 12px 14px;
  }
  .btn-process {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
  }
  .tool-processing-state,
  .processing-state {
    padding: 40px 16px;
  }
  .tool-download-state,
  .download-state {
    padding: 36px 16px;
  }
  .download-title {
    font-size: 1.4rem;
  }
  .download-btn-group {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .btn-download-big,
  .btn-download {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
  }
  #docPreviewContainer,
  #excelTablePreview {
    max-height: 320px !important;
    padding: 14px !important;
  }
}

/* ==========================================================================
   Advanced Visual PDF Editor Studio Styles
   ========================================================================== */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

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

.editor-divider {
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.edit-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.edit-tool-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.edit-tool-btn.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.editor-canvas-stage {
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  background: #FFFFFF;
  margin: 0 auto;
  user-select: none;
}

#interactiveOverlayLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.interactive-box {
  position: absolute;
  pointer-events: auto;
  box-sizing: border-box;
  touch-action: none;
  border: 1px dashed transparent;
  border-radius: 3px;
  padding: 0 2px;
  margin: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  min-width: 30px;
  min-height: 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
  z-index: 10;
}

.interactive-box:hover {
  border-color: #2563EB;
  background: rgba(37, 99, 235, 0.05);
}

.interactive-box.selected {
  border: 1.5px solid #2563EB;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
  z-index: 50;
}

.interactive-box .box-text-content {
  outline: none;
  min-width: 20px;
  min-height: 14px;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: text;
  line-height: 1.15;
  padding: 0;
  margin: 0;
}

.interactive-box.whiteout-box {
  background: #FFFFFF !important;
  border: 1px dashed #94A3B8;
  cursor: move;
  z-index: 8;
}

.interactive-box.whiteout-box:hover,
.interactive-box.whiteout-box.selected {
  border-color: #EF4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

.interactive-box.image-box {
  padding: 0;
  border: 1.5px dashed #8B5CF6;
  cursor: move;
}

.interactive-box.image-box img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

/* Floating Actions Bar with Drag Handle & Live Styling */
.box-actions-bar {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 0;
  display: none;
  align-items: center;
  gap: 4px;
  background: #0F172A;
  color: white;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 0.75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.2);
  z-index: 120;
  white-space: nowrap;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Invisible bridge preventing hover dropoff */
.box-actions-bar::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 10px;
  background: transparent;
}

.interactive-box:hover .box-actions-bar,
.interactive-box.selected .box-actions-bar {
  display: flex;
}

.box-drag-handle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #2563EB, #1D4ED8);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.72rem;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.1s, background 0.15s;
}

.box-drag-handle:hover {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  transform: translateY(-1px);
}

.box-drag-handle:active {
  cursor: grabbing;
}

.box-action-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  min-width: 22px;
  height: 22px;
}

.box-action-btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.3);
}

.box-action-btn.active {
  background: #2563EB;
  border-color: #60A5FA;
}

.box-action-btn.delete-btn:hover {
  background: #DC2626;
  border-color: #EF4444;
  color: white;
}

.box-action-btn.btn-text-on-whiteout {
  background: #059669;
  border-color: #10B981;
  color: white;
  font-weight: 700;
  padding: 3px 8px;
  gap: 3px;
}

.box-action-btn.btn-text-on-whiteout:hover {
  background: #047857;
}

.box-fs-val {
  font-size: 0.7rem;
  font-weight: 700;
  color: #CBD5E1;
  padding: 0 2px;
  min-width: 26px;
  text-align: center;
}

.box-color-input {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  vertical-align: middle;
}

.box-type-badge {
  font-weight: 700;
  font-size: 0.68rem;
  color: #94A3B8;
  letter-spacing: 0.03em;
  margin-right: 2px;
}

.box-resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  background: #2563EB;
  border: 2px solid white;
  border-radius: 50%;
  cursor: se-resize;
  display: none;
  z-index: 60;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.interactive-box:hover .box-resize-handle,
.interactive-box.selected .box-resize-handle {
  display: block;
}

.interactive-box.is-dragging {
  opacity: 0.88;
  cursor: grabbing !important;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3) !important;
  border-color: #2563EB !important;
}

/* Drawing Mode: disable pointer events on overlay text zones so pen & highlighter flow with 0 obstruction */
.drawing-mode .existing-text-zone,
.drawing-mode #existingTextZonesLayer .existing-text-zone,
.drawing-mode .interactive-box {
  pointer-events: none !important;
}

/* Move Tool Mode: cursor is grab everywhere on elements, text zones don't block clicks */
.move-tool-active .interactive-box {
  cursor: grab !important;
}

.move-tool-active .interactive-box.is-dragging {
  cursor: grabbing !important;
}

.move-tool-active .interactive-box .box-text-content {
  cursor: grab !important;
}

.move-tool-active #existingTextZonesLayer .existing-text-zone {
  pointer-events: none !important;
}

/* Pick & Place / Relocate Mode */
.interactive-box.is-picked-up {
  cursor: move !important;
  box-shadow: 0 0 0 3px #2563EB, 0 10px 30px rgba(37, 99, 235, 0.45) !important;
  border: 2px dashed #2563EB !important;
  opacity: 0.94;
  z-index: 200 !important;
  animation: pulseBoxRing 1.5s infinite ease-in-out;
}

@keyframes pulseBoxRing {
  0%, 100% { box-shadow: 0 0 0 3px #2563EB, 0 8px 24px rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 0 0 5px #3B82F6, 0 12px 32px rgba(59, 130, 246, 0.6); }
}

.box-pick-badge {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #1D4ED8;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Existing Text Zones Layer */
#existingTextZonesLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 6;
}

#existingTextZonesLayer .existing-text-zone {
  pointer-events: auto;
}

/* ==========================================================================
   Dual-Mode Switcher & MS Word Editor Styles
   ========================================================================== */
.editor-mode-switcher {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  background: var(--bg-surface);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.mode-tab-btn {
  flex: 1;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.mode-tab-btn:hover {
  background: var(--bg-subtle);
}

.mode-tab-btn.active {
  background: var(--bg-card);
  border-color: var(--brand-primary);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.mode-tab-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.1);
  border-radius: 8px;
  flex-shrink: 0;
}

.mode-tab-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
}

.mode-tab-text span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Fix input controls in editor toolbar */
.editor-select {
  width: auto !important;
  max-width: 150px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  height: 34px;
}

.editor-color-picker {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

/* Clickable Existing Text Zone on PDF */
.existing-text-zone {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border: 1px dashed transparent;
  border-radius: 2px;
  transition: all 0.12s ease;
  z-index: 5;
}

.existing-text-zone:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: #2563EB;
}

.existing-text-zone:hover::after {
  content: "✏️ Click to Edit";
  position: absolute;
  bottom: 100%;
  left: 0;
  background: #1E293B;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}

/* Word Mode Ribbon & Document */
.word-ribbon-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.ribbon-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.ribbon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 4px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ribbon-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.ribbon-btn.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.word-desk-container {
  background: #0F172A;
  padding: 36px 20px;
  border-radius: var(--radius-md);
  min-height: 600px;
  overflow-x: auto;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.word-page-sheet {
  width: 100%;
  max-width: 820px;
  min-height: 1050px;
  margin: 0 auto;
  background: #FFFFFF;
  color: #1E293B;
  padding: 60px 70px;
  box-shadow: 0 10px 35px rgba(0,0,0,0.4);
  border-radius: 2px;
  outline: none;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-word;
}

.word-page-sheet p {
  margin-bottom: 12px;
}

.word-page-sheet h1, .word-page-sheet h2, .word-page-sheet h3 {
  margin-top: 18px;
  margin-bottom: 10px;
  color: #0F172A;
}



