/* ==========================================================================
   SmartDocify - AI Background Remover Tool Stylesheet
   ========================================================================== */

/* Main Container & Layout */
.bg-tool-wrapper {
  margin-bottom: 3.5rem;
}

/* Privacy & Security Banner */
.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.75rem;
  font-size: 0.925rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

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

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

.bg-dropzone-card:hover,
.bg-dropzone-card.dragover {
  border-color: var(--primary);
  background: var(--primary-light, rgba(37, 99, 235, 0.04));
  transform: translateY(-2px);
}

.bg-dropzone-icon-box {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary-light, rgba(37, 99, 235, 0.1));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem auto;
}

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

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

.bg-dropzone-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 1.5rem auto;
  line-height: 1.5;
}

.bg-dropzone-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-top: 1.25rem;
}

.bg-dropzone-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Workspace (Shown after image upload) */
.bg-workspace {
  display: none;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.9fr);
  gap: 2rem;
  align-items: start;
}

.bg-workspace.active {
  display: grid;
}

@media (max-width: 960px) {
  .bg-workspace {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* Card Containers */
.bg-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: 1.5rem;
}

.bg-card:last-child {
  margin-bottom: 0;
}

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

.bg-card-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.bg-card-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

/* Before / After View Toggle Buttons */
.view-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.view-toggle-group {
  display: inline-flex;
  background: var(--bg-main, #ffffff);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.view-btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn:hover {
  color: var(--text-primary);
}

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

/* Interactive Before / After Split Comparison Stage */
.comparison-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 520px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  user-select: none;
  touch-action: pan-y;
  background: #f1f5f9;
}

/* Checkerboard Background for Transparency */
.checkerboard-pattern {
  background: repeating-conic-gradient(#f8fafc 0% 25%, #e2e8f0 0% 50%) 50% / 20px 20px;
}

[data-theme="dark"] .checkerboard-pattern {
  background: repeating-conic-gradient(#1e293b 0% 25%, #0f172a 0% 50%) 50% / 20px 20px;
}

.comparison-after-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-after-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.comparison-before-layer {
  position: absolute;
  inset: 0;
  width: 50%;
  height: 100%;
  overflow: hidden;
  border-right: 2px solid #ffffff;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.25);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.comparison-before-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Comparison Draggable Divider */
.comparison-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #ffffff;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.comparison-handle-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  pointer-events: auto;
  color: var(--primary);
}

.comparison-handle-btn svg {
  width: 20px;
  height: 20px;
}

/* Comparison Badges */
.comparison-badge {
  position: absolute;
  top: 12px;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 5;
}

.badge-before {
  left: 12px;
}

.badge-after {
  right: 12px;
}

/* Single View Mode (When toggle switches to Before or After) */
.comparison-stage.view-after-only .comparison-before-layer,
.comparison-stage.view-after-only .comparison-divider-line,
.comparison-stage.view-after-only .badge-before {
  display: none;
}

.comparison-stage.view-before-only .comparison-before-layer {
  width: 100% !important;
  border-right: none;
}

.comparison-stage.view-before-only .comparison-divider-line,
.comparison-stage.view-before-only .badge-after {
  display: none;
}

/* Stage Info Bar */
.stage-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.85rem;
}

.stage-resolution-badge {
  font-weight: 600;
  color: var(--text-primary);
}

/* Background Replacement Options */
.bg-types-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
  .bg-types-nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

.bg-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  background: var(--bg-main, #ffffff);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.bg-type-btn svg {
  width: 20px;
  height: 20px;
}

.bg-type-btn:hover {
  border-color: var(--primary);
  color: var(--text-primary);
}

.bg-type-btn.active {
  background: var(--primary-light, rgba(37, 99, 235, 0.08));
  border-color: var(--primary);
  color: var(--primary);
}

/* Color Presets & Pickers */
.color-presets-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.color-swatch-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
}

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

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

.custom-color-input-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-main, #ffffff);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.5rem;
}

.color-input-native {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border: none;
  cursor: pointer;
  background: none;
  border-radius: var(--radius-sm);
  padding: 0;
}

.color-input-native::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input-native::-webkit-color-swatch {
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 4px;
}

.color-hex-text {
  flex: 1;
  border: none;
  background: transparent;
  font-family: monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  text-transform: uppercase;
}

/* Gradient Presets Grid */
.gradients-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.gradient-swatch-btn {
  height: 38px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gradient-swatch-btn:hover {
  transform: translateY(-1px);
}

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

/* Custom Background Image Upload Box */
.custom-bg-upload-box {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg-main, #ffffff);
  transition: all 0.2s ease;
}

.custom-bg-upload-box:hover {
  border-color: var(--primary);
  background: var(--bg-subtle, rgba(0,0,0,0.02));
}

.custom-bg-upload-box svg {
  width: 26px;
  height: 26px;
  color: var(--text-subtle);
  margin-bottom: 0.35rem;
}

.custom-bg-active-card {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle, rgba(0,0,0,0.03));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.custom-bg-active-card.visible {
  display: flex;
}

.custom-bg-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Cutout Position & Transformation */
.control-slider-group {
  margin-bottom: 1rem;
}

.control-slider-group:last-child {
  margin-bottom: 0;
}

.control-slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.control-slider-input {
  width: 100%;
  accent-color: var(--primary);
}

/* Toggle Switches */
.switch-control-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.switch-toggle-track {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.switch-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input[type="checkbox"]:checked + .switch-toggle-track {
  background: var(--primary);
}

input[type="checkbox"]:checked + .switch-toggle-track::after {
  transform: translateX(20px);
}

/* Download Actions Card */
.download-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.btn-bg-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border: none;
  box-sizing: border-box;
}

.btn-bg-primary {
  background: var(--primary);
  color: #ffffff;
  grid-column: span 2;
}

.btn-bg-primary:hover {
  background: var(--primary-hover, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transform: translateY(-1px);
}

.btn-bg-secondary {
  background: var(--bg-main, #ffffff);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.btn-bg-secondary:hover {
  background: var(--bg-subtle, rgba(0,0,0,0.03));
  border-color: var(--primary);
  color: var(--primary);
}

.secondary-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-action-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-main, #ffffff);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-action-mini:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-subtle, rgba(0,0,0,0.03));
}

.btn-action-mini svg {
  width: 14px;
  height: 14px;
}

/* Processing Overlay */
.processing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
}

[data-theme="dark"] .processing-overlay {
  background: rgba(15, 23, 42, 0.88);
}

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

.processing-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--primary-light, rgba(37,99,235,0.2));
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: bgSpin 1s linear infinite;
  margin-bottom: 1.25rem;
}

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

.processing-status-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.processing-status-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 320px;
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.btn-cancel-process {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cancel-process:hover {
  color: #ef4444;
  border-color: #ef4444;
}

/* Hero Section & Visual Animation */
.bg-hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 280px;
  gap: 2rem;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 820px) {
  .bg-hero-card {
    grid-template-columns: 1fr;
  }
}

.bg-hero-anim-box {
  width: 100%;
  max-width: 250px;
  aspect-ratio: 1;
  margin: 0 auto;
  position: relative;
  background: var(--bg-main, #ffffff);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.bg-anim-stage {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: repeating-conic-gradient(#f8fafc 0% 25%, #e2e8f0 0% 50%) 50% / 14px 14px;
}

.bg-anim-backdrop {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  animation: bgFadeInOut 4s ease-in-out infinite alternate;
}

@keyframes bgFadeInOut {
  0% { opacity: 0.95; }
  35% { opacity: 0.95; }
  65% { opacity: 0; }
  100% { opacity: 0; }
}

.bg-anim-subject {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 65%;
  height: 80%;
  color: var(--primary);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bg-anim-subject svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.25));
}

@media (prefers-reduced-motion: reduce) {
  .bg-anim-backdrop {
    animation: none;
    opacity: 0;
  }
}

/* Visual SEO Flow Cards */
.bg-flow-section {
  margin: 3.5rem 0;
}

.bg-flow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.bg-flow-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.bg-flow-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light, rgba(37,99,235,0.1));
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.bg-flow-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.bg-flow-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Toast Feedback */
.bg-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

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

/* Confirmation Modal */
.bg-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 1rem;
}

.bg-modal-backdrop.show {
  display: flex;
}

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

.bg-modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.bg-modal-desc {
  font-size: 0.925rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.bg-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}


/* Image type selector (Auto / Photo / Signature) */
.bg-mode-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.bg-mode-nav .bg-type-btn {
  min-height: 44px;
  text-align: center;
  overflow-wrap: anywhere;
}
.bg-mode-hint {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.bg-card [hidden] {
  display: none !important;
}
.bg-type-btn:focus-visible,
.bg-mode-nav .bg-type-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (max-width: 480px) {
  .bg-mode-nav {
    grid-template-columns: 1fr;
  }
}
