/* ==========================================================================
   AI Background Remover - Tool Interface Stylesheet (tool.css)
   Interactive Workspace, Drag-and-Drop, Dual-View Preview & Color Customizer
   ========================================================================== */

.tool-workspace-wrapper {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 3rem auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  position: relative;
  transition: all var(--transition-normal);
}

/* Upload Dropzone State */
.dropzone-container {
  padding: 4rem 2rem;
  text-align: center;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  margin: 1.5rem;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

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

.dropzone-icon-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-subtle);
}

.dropzone-icon-ring svg {
  width: 36px;
  height: 36px;
}

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

.dropzone-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.dropzone-hidden-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.paste-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

.paste-hint kbd {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Sample Images Row */
.sample-presets {
  margin-top: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.sample-presets-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sample-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

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

/* Processing Overlay & Progress */
.processing-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #ffffff;
  text-align: center;
}

.processing-overlay.active {
  display: flex;
}

.spinner-pulse {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-right-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  margin-bottom: 1.25rem;
}

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

.progress-bar-container {
  width: 100%;
  max-width: 320px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 1rem 0 0.5rem 0;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.2s ease;
}

.progress-status-text {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

/* Active Editing Workspace View */
.editor-workspace {
  display: none;
  flex-direction: column;
}

.editor-workspace.active {
  display: flex;
}

/* Top Toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--bg-subtle);
  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;
}

.view-mode-tabs {
  display: flex;
  background: var(--bg-surface);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.view-tab-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.view-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* Canvas Viewport Stage */
.canvas-stage-wrapper {
  position: relative;
  width: 100%;
  height: 480px;
  background: var(--checkerboard-1);
  background-image: 
    linear-gradient(45deg, var(--checkerboard-2) 25%, transparent 25%), 
    linear-gradient(-45deg, var(--checkerboard-2) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, var(--checkerboard-2) 75%), 
    linear-gradient(-45deg, transparent 75%, var(--checkerboard-2) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.canvas-viewport {
  position: relative;
  max-width: 95%;
  max-height: 95%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out;
}

.main-preview-canvas {
  display: block;
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
}

/* Split Slider in Editor */
.editor-split-container {
  position: relative;
  display: none;
  max-width: 100%;
  max-height: 440px;
  overflow: hidden;
}

.editor-split-container.active {
  display: block;
}

.split-layer-processed {
  position: relative;
}

.split-layer-original {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: hidden;
  border-right: 2px solid #ffffff;
  z-index: 10;
}

.split-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #ffffff;
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

.split-handle-pill {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  font-size: 10px;
  border: 2px solid #ffffff;
}

/* Floating Zoom / Pan Controls */
.floating-stage-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  z-index: 30;
}

.stage-btn {
  background: none;
  border: none;
  color: #ffffff;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.stage-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.stage-zoom-level {
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
  min-width: 42px;
  text-align: center;
}

/* Bottom Control Deck (Backgrounds, Touch-up, Export) */
.editor-controls-deck {
  padding: 1.5rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.deck-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.bg-customizer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.color-swatch-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-subtle);
  cursor: pointer;
  position: relative;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.color-swatch-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.swatch-transparent {
  background: var(--checkerboard-1);
  background-image: 
    linear-gradient(45deg, var(--checkerboard-2) 25%, transparent 25%), 
    linear-gradient(-45deg, var(--checkerboard-2) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, var(--checkerboard-2) 75%), 
    linear-gradient(-45deg, transparent 75%, var(--checkerboard-2) 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.custom-color-input-wrapper {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border-subtle);
  cursor: pointer;
}

.custom-color-input {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 60px;
  height: 60px;
  cursor: pointer;
  border: none;
}

/* Touchup Brush Drawer */
.touchup-panel {
  display: none;
  background: var(--bg-subtle);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.touchup-panel.active {
  display: flex;
}

.brush-slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.brush-slider-group input[type="range"] {
  accent-color: var(--primary);
}

/* Action Export Bar */
.editor-export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.export-meta-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 500;
}

.export-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Tool Error Banner */
.tool-error-banner {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem;
  text-align: center;
  color: #991b1b;
}

[data-theme="dark"] .tool-error-banner {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.tool-error-banner.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.tool-error-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: inherit;
}

.tool-error-desc {
  font-size: 0.9rem;
  margin: 0;
  max-width: 500px;
  opacity: 0.9;
  line-height: 1.5;
}

.export-btn-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Toast Message */
.tool-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-normal);
  z-index: 10000;
}

.tool-toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 768px) {
  .canvas-stage-wrapper {
    height: 340px;
  }
  
  .editor-export-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .export-btn-group {
    flex-direction: column;
    width: 100%;
  }
  
  .export-btn-group .btn {
    width: 100%;
  }
}
