/* ==========================================================================
   SmartDocify - Shipping Label Cropper Stylesheet
   ========================================================================== */

/* Main Tool Containers */
.cropper-app-wrapper {
  margin-bottom: 3.5rem;
}

/* Privacy Notice Banner */
.cropper-privacy-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.875rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.925rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.cropper-privacy-icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

/* Upload Dropzone */
.cropper-dropzone {
  background: var(--bg-surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 3.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  outline: none;
  margin-bottom: 1.75rem;
}

.cropper-dropzone:hover,
.cropper-dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.cropper-dropzone.dragover {
  border-style: solid;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.cropper-dropzone-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem auto;
  transition: transform 0.2s ease;
}

.cropper-dropzone:hover .cropper-dropzone-icon {
  transform: scale(1.08);
}

.cropper-dropzone-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.cropper-dropzone-sub {
  font-size: 0.925rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.cropper-dropzone-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.cropper-dropzone-hints {
  font-size: 0.825rem;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.cropper-hint-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Page Selector Strip (for Multi-Page PDFs) */
.pdf-page-selector-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.page-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-selector-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-selector-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdf-thumbnails-strip {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.35rem 0.15rem 0.75rem 0.15rem;
  scrollbar-width: thin;
}

.pdf-thumb-card {
  flex: 0 0 90px;
  text-align: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 0.35rem;
  border: 2px solid var(--border-subtle);
  background: var(--bg-body);
  transition: all 0.15s ease;
  user-select: none;
}

.pdf-thumb-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.pdf-thumb-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
  background: var(--primary-light);
}

.pdf-thumb-img-wrap {
  width: 100%;
  height: 110px;
  background: #ffffff;
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.35rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pdf-thumb-img-wrap canvas,
.pdf-thumb-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.pdf-thumb-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.pdf-thumb-card.active .pdf-thumb-label {
  color: var(--primary);
  font-weight: 700;
}

/* Crop Editor Workspace */
.cropper-workspace-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.75rem;
  align-items: start;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .cropper-workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Canvas Viewport Card */
.crop-canvas-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.crop-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.crop-viewport-wrapper {
  min-height: 480px;
  max-height: 680px;
  overflow: auto;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background-color: #f1f5f9;
  user-select: none;
}

[data-theme="dark"] .crop-viewport-wrapper {
  background-color: #0f172a;
}

.canvas-crop-stage {
  position: relative;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: inline-block;
  background: #ffffff;
  line-height: 0;
}

#document-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Overlay & Draggable Crop Boxes */
.crop-overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  cursor: crosshair;
}

.crop-box-element {
  position: absolute;
  border: 2px solid #2563eb;
  background: rgba(37, 99, 235, 0.15);
  box-sizing: border-box;
  cursor: move;
  z-index: 10;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.crop-box-element.active {
  border-color: #1d4ed8;
  background: rgba(37, 99, 235, 0.22);
  box-shadow: 0 0 0 1px #ffffff, 0 4px 12px rgba(37, 99, 235, 0.25);
  z-index: 20;
}

.crop-box-badge {
  position: absolute;
  top: -24px;
  left: -2px;
  background: #2563eb;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px 4px 0 0;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.2;
}

.crop-box-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 3px;
  z-index: 30;
}

.crop-box-btn {
  background: rgba(15, 23, 42, 0.85);
  color: #ffffff;
  border: none;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.crop-box-btn:hover {
  background: #ef4444;
}

.crop-box-btn.btn-dup:hover {
  background: #2563eb;
}

/* Resize Handles */
.crop-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border: 2px solid #2563eb;
  border-radius: 2px;
  box-sizing: border-box;
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-w  { left: -5px; top: calc(50% - 5px); cursor: ew-resize; }
.handle-e  { right: -5px; top: calc(50% - 5px); cursor: ew-resize; }

/* Crop Editor Controls Sidebar */
.crop-sidebar-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.preset-grid-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn-preset {
  padding: 0.6rem 0.5rem;
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-preset.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.coord-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.coord-field {
  position: relative;
}

.coord-field span {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-weight: 700;
}

.coord-field input {
  padding-left: 1.5rem;
  padding-right: 0.4rem;
  font-size: 0.85rem;
}

/* Extracted Labels Management Tray */
.extracted-labels-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.labels-tray-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.labels-tray-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.labels-tray-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.labels-tray-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Extracted Labels Grid */
.extracted-labels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.label-card-item {
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.label-card-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.label-card-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.label-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.label-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}

.label-preview-wrap {
  width: 100%;
  height: 220px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.65rem;
  position: relative;
}

.label-preview-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.label-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.label-card-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.5rem;
}

.card-action-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.card-action-btn:hover:not(:disabled) {
  background: var(--bg-surface);
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.card-action-btn.btn-del:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #dc2626;
}

/* Output Layout & Download Section */
.output-options-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.output-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.output-actions-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.btn-primary-action {
  flex: 1;
  min-width: 220px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
}

/* Progress Overlay */
.cropper-progress-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cropper-progress-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.progress-dialog-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-width: 420px;
  width: 100%;
  padding: 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.progress-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.25rem auto;
}

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

.progress-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.progress-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Dedicated Print Layout */
#print-output-container {
  display: none;
}

@media print {
  /* Hide all site UI in print */
  body * {
    visibility: hidden;
  }

  .site-header,
  .site-footer,
  .cropper-privacy-banner,
  .cropper-dropzone,
  .pdf-page-selector-card,
  .cropper-workspace-grid,
  .output-options-card,
  .tool-seo-section,
  .tool-howto-section,
  .faq-section,
  #visual-seo-mount,
  #related-tools-container,
  #support-smartdocify-mount,
  nav,
  header,
  footer,
  aside {
    display: none !important;
  }

  #print-output-container,
  #print-output-container * {
    visibility: visible;
    display: block !important;
  }

  #print-output-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
  }

  .print-page-sheet {
    page-break-after: always;
    break-after: page;
    box-sizing: border-box;
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .print-label-item {
    box-sizing: border-box;
    display: flex !important;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
  }

  .print-label-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block !important;
  }

  @page {
    margin: 0;
    size: auto;
  }
}

/* Animations */
.hero-shipping-anim {
  width: 100%;
  max-width: 540px;
  margin: 1.5rem auto 0 auto;
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: var(--shadow-sm);
}

.anim-sheet {
  width: 90px;
  height: 120px;
  border: 2px dashed var(--border-strong);
  border-radius: 4px;
  background: #ffffff;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 4px;
}

[data-theme="dark"] .anim-sheet {
  background: #1e293b;
}

.anim-label-box {
  flex: 1;
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: 2px;
  animation: pulseBox 2.5s infinite ease-in-out;
}

.anim-arrow {
  color: var(--primary);
  animation: bounceRight 2.5s infinite ease-in-out;
}

.anim-output-labels {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.anim-single-label {
  width: 75px;
  height: 48px;
  background: var(--bg-surface-elevated, #ffffff);
  border: 1.5px solid var(--primary);
  border-radius: 3px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  padding: 4px;
  gap: 3px;
}

.anim-barcode-line {
  height: 8px;
  background: repeating-linear-gradient(90deg, #0f172a 0px, #0f172a 2px, transparent 2px, transparent 4px);
  border-radius: 1px;
}

[data-theme="dark"] .anim-barcode-line {
  background: repeating-linear-gradient(90deg, #e2e8f0 0px, #e2e8f0 2px, transparent 2px, transparent 4px);
}

.anim-text-line {
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
}

@keyframes pulseBox {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.04); opacity: 1; }
}

@keyframes bounceRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
  .anim-label-box,
  .anim-arrow {
    animation: none !important;
  }
}
