/* ==========================================================================
   AdeptwizBarcodes - Interactive Custom Label Designer Studio
   ========================================================================== */

.designer-app-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px);
  min-height: 700px;
  background: var(--bg-primary);
  overflow: hidden;
}

/* Designer Top Control Bar */
.designer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 20;
}

.designer-template-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.designer-add-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-tertiary);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.tool-btn:active {
  transform: scale(0.96);
}

.designer-history-tools {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.icon-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.icon-action-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
}

/* Custom Dimensions Bar */
.custom-dims-bar {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.4rem 1.25rem;
  animation: slideDown 150ms ease;
}

.custom-dims-fields {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.custom-dims-fields input {
  width: 70px;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Designer Workspace Layout */
.designer-workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 1000px) {
  .designer-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    overflow-y: auto;
  }
}

/* Canvas Viewport */
.canvas-viewport-area {
  background: var(--bg-primary);
  background-image: 
    radial-gradient(circle, var(--border-subtle) 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  overflow: auto;
  user-select: none;
}

.label-stage-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* Physical Label Stage (The Sticker Representation) */
.label-stage {
  position: relative;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transition: width 250ms ease, height 250ms ease, background-color 200ms;
}

/* Label Interactive Surface where elements live */
.label-interactive-surface {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Canvas Dimension Pill */
.canvas-dimension-tag {
  position: absolute;
  bottom: 1.25rem;
  left: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.3rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

/* ==========================================================================
   Canvas Interactive Elements
   ========================================================================== */
.canvas-el {
  position: absolute;
  cursor: move;
  user-select: none;
  box-sizing: border-box;
}

.canvas-el.selected {
  outline: 2px solid var(--brand-accent);
  outline-offset: 1px;
}

/* Transform Resize Handles */
.resize-handle {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #ffffff;
  border: 2px solid var(--brand-accent);
  border-radius: 2px;
  display: none;
  z-index: 10;
}

.canvas-el.selected .resize-handle {
  display: block;
}

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

/* Text Element */
.el-text-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  word-break: break-word;
  line-height: 1.2;
}

/* Barcode Element on Canvas */
.el-barcode-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.el-barcode-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* QR Element on Canvas */
.el-qr-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.el-qr-container svg, .el-qr-container canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Image Element on Canvas */
.el-image-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.el-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Badge Element on Canvas */
.el-badge-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ==========================================================================
   Inspector & Properties Panel Right
   ========================================================================== */
.designer-inspector-pane {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.inspector-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inspector-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-xs-link {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--brand-accent);
  cursor: pointer;
}

.btn-xs-link:hover {
  text-decoration: underline;
}

.inspector-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inspector-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.element-align-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.element-layer-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

/* ==========================================================================
   Presets Modal Styles
   ========================================================================== */
.presets-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.preset-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.preset-card:hover {
  border-color: var(--brand-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.preset-thumb-preview {
  height: 110px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 0.85rem;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.1);
  padding: 0.5rem;
}

.preset-thumb-preview img, .preset-thumb-preview svg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preset-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.preset-card-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.35;
}

.preset-card-meta {
  margin-top: auto;
  padding-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--brand-accent);
  font-weight: 600;
}

/* ==========================================================================
   Batch Sheet Modal Styles
   ========================================================================== */
.batch-modal-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.75rem;
}

@media (max-width: 900px) {
  .batch-modal-grid {
    grid-template-columns: 1fr;
  }
}

.batch-options-col {
  display: flex;
  flex-direction: column;
}

.batch-options-col .subhead {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}

.serial-options-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-top: 0.5rem;
}

.serial-preview-chip {
  background: var(--bg-input);
  border-radius: var(--radius-xs);
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.6rem;
}

.serial-preview-chip strong {
  color: var(--brand-accent);
  font-family: var(--font-mono);
}

.sheet-spec-summary {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 1rem;
}

/* Sheet Visual Preview */
.batch-preview-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.sheet-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sheet-page-badge {
  background: var(--bg-tertiary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-family: var(--font-mono);
}

.sheet-paper-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  max-height: 520px;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

/* Simulated Letter Size Sheet */
.sheet-paper {
  width: 595px; /* US Letter proportion ~ 8.5 x 11 at 70dpi */
  height: 770px;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  padding: 35px 13px; /* Avery 5160 top/bottom & side margins */
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 0 9px;
  box-sizing: border-box;
}

.sheet-label-cell {
  background: #fafafa;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}

.sheet-label-cell.empty {
  opacity: 0.35;
  background: #f1f5f9;
}

.sheet-label-cell-inner {
  transform-origin: center center;
  width: 100%;
  height: 100%;
  position: relative;
}

/* ==========================================================================
   Scanner & Verifier Styles
   ========================================================================== */
.scanner-page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

.scanner-hero {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 2.5rem;
}

.scanner-hero h1 {
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.scanner-hero p {
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

.scanner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 800px) {
  .scanner-grid {
    grid-template-columns: 1fr;
  }
}

.scanner-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

.dropzone-box {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-input);
  transition: all var(--transition-fast);
}

.dropzone-box:hover {
  border-color: var(--brand-accent);
  background: rgba(56, 189, 248, 0.04);
}

.drop-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.75rem;
}

.drop-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.camera-reader-box {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000000;
}

.camera-reader-box video {
  width: 100% !important;
  height: auto !important;
  border-radius: var(--radius-md);
}

.scanner-result-idle {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.idle-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.result-status-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.result-status-banner.success {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.result-table {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.row-label {
  color: var(--text-muted);
  font-weight: 500;
}

.row-val {
  color: var(--text-primary);
}

.row-val.strong {
  font-size: 1rem;
  color: var(--brand-accent);
}

/* ==========================================================================
   Designer Topbar & Batch PDF Export Actions
   ========================================================================== */
.designer-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#btnExportLabelPdf {
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
}

#btnExportLabelPdf:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #34d399;
}

.batch-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.btn-export-pdf-action {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  border: none;
  font-weight: 600;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
}

.btn-export-pdf-action:hover {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

