/**
 * ONE RESIZER — Tool 05: Background Remover Stylesheet
 * AI-Powered Client-Side Foreground Isolation Studio
 * Checkerboard Transparency Stage, Background Color Switcher,
 * Real-Time Progress Bar, and Honest 4-Stat Output Card.
 */

/* ========================================================
   CONTAINER & WORKSPACE VIEWS
   ======================================================== */
.bgrem-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.bgrem-view {
  display: block;
  width: 100%;
  box-sizing: border-box;
}
.bgrem-view.hidden {
  display: none !important;
}

/* ========================================================
   INITIAL UPLOAD HERO SCREEN
   ======================================================== */
.upload-hero-card {
  background: var(--bg-card);
  border: 2px dashed var(--primary-cyan);
  border-radius: var(--radius-xl);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}
.upload-hero-card:hover, .upload-hero-card.dragover {
  background: rgba(22, 135, 245, 0.08);
  border-color: var(--primary-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.upload-icon-wrapper {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(22, 135, 245, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-cyan);
}
.upload-icon-wrapper svg {
  width: 36px;
  height: 36px;
  stroke: currentColor;
  fill: none;
}

.upload-heading {
  font-size: 20px;
  font-weight: 850;
  color: var(--text-heading);
  margin-bottom: 6px;
}
.upload-subheading {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.upload-btn-fake {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-cyan);
  color: #fff;
  font-weight: 800;
  font-size: 13.5px;
  padding: 9px 22px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 14px var(--primary-glow);
  margin-bottom: 14px;
}
.upload-formats-badge {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  max-width: 100%;
}

/* ========================================================
   STUDIO LAYOUT: PREVIEWS (LEFT) + CONTROLS (RIGHT)
   ======================================================== */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 24px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

/* LEFT COLUMN: PREVIEWS PANEL */
.previews-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
}

.preview-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
  flex-wrap: wrap;
}
.file-info-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.file-info-badge .file-name {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-heading);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-info-badge .file-size-orig {
  font-size: 11.5px;
  font-weight: 750;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

/* DUAL PREVIEW COMPARISON GRID */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
}

.compare-card {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.compare-header .tag {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 10.5px;
}
.compare-header .tag-orig {
  background: var(--bg-card);
  color: var(--text-muted);
}
.compare-header .tag-res {
  background: rgba(22, 135, 245, 0.15);
  color: var(--primary-cyan);
}

.compare-stage {
  position: relative;
  width: 100%;
  height: 260px;
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  box-sizing: border-box;
}

/* CHECKERBOARD TRANSPARENCY PATTERN */
.stage-checkerboard {
  background-image: 
    linear-gradient(45deg, rgba(0,0,0,0.08) 25%, transparent 25%), 
    linear-gradient(-45deg, rgba(0,0,0,0.08) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.08) 75%), 
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.08) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #ffffff;
}
html[data-theme="dark"] .stage-checkerboard {
  background-image: 
    linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%), 
    linear-gradient(-45deg, rgba(255,255,255,0.06) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.06) 75%), 
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.06) 75%);
  background-color: #121926;
}

.compare-stage img, .compare-stage canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.compare-meta {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 750;
  color: var(--text-muted);
}
.compare-meta strong {
  font-size: 12.5px;
  font-weight: 850;
  color: var(--text-heading);
}

/* PROGRESS BAR */
.progress-card {
  background: var(--bg-subtle);
  border: 1.5px solid var(--primary-cyan);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-top: 14px;
  box-sizing: border-box;
}
.progress-status-text {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-cyan), var(--primary-blue));
  border-radius: var(--radius-full);
  transition: width 0.2s ease;
}

/* RIGHT COLUMN: CONTROLS PANEL */
.controls-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  width: 100%;
}

.control-section-header {
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

/* BACKGROUND OPTIONS GRID */
.bg-options-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.bg-option-btn {
  background: var(--bg-subtle);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 4px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  text-align: center;
}
.bg-option-btn:hover {
  border-color: var(--primary-cyan);
}
.bg-option-btn.active {
  background: rgba(22, 135, 245, 0.12);
  border-color: var(--primary-cyan);
  color: var(--primary-cyan);
  box-shadow: 0 2px 8px var(--primary-glow);
}
.bg-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
}
.bg-swatch-trans {
  background-image: 
    linear-gradient(45deg, #ccc 25%, transparent 25%), 
    linear-gradient(-45deg, #ccc 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #ccc 75%), 
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  background-color: #fff;
}
.bg-swatch-white { background: #ffffff; }
.bg-swatch-black { background: #000000; }
.bg-swatch-custom {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

/* CUSTOM COLOR PICKER ROW */
.custom-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-top: 8px;
}
.custom-color-row input[type="color"] {
  -webkit-appearance: none;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  padding: 0;
}
.custom-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.custom-color-row input[type="color"]::-webkit-color-swatch {
  border: 1.5px solid var(--line);
  border-radius: 50%;
}

/* ACTION BUTTONS */
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
}
.btn-remove-execute {
  width: 100%;
  height: 48px;
  background: var(--primary-cyan);
  border: 0;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--primary-glow);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-remove-execute:hover:not(:disabled) {
  background: var(--primary-blue);
  transform: translateY(-1px);
}
.btn-remove-execute:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-secondary-action {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  padding: 5px 10px;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-secondary-action:hover {
  background: var(--bg-subtle);
  color: var(--text-heading);
  border-color: var(--line-light);
}

/* ========================================================
   RESULT & DOWNLOAD CARD
   ======================================================== */
.result-card {
  background: var(--bg-card);
  border: 2px solid rgba(16, 168, 88, 0.4);
  border-radius: var(--radius-xl);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  width: 100%;
}
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 168, 88, 0.12);
  color: #10a858;
  border: 1px solid rgba(16, 168, 88, 0.3);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 800;
  margin-bottom: 14px;
}
.result-heading {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-heading);
  margin-bottom: 4px;
}
.result-subheading {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.result-preview-box {
  width: 100%;
  max-height: 260px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  margin-bottom: 18px;
  overflow: hidden;
  box-sizing: border-box;
}
.result-preview-box img {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
}
.result-stat-item {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 4px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}
.result-stat-item span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
}
.result-stat-item strong {
  display: block;
  font-size: 13px;
  font-weight: 850;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-download-final {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: #10a858;
  border: 0;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 168, 88, 0.35);
  transition: var(--transition);
  margin-bottom: 10px;
}
.btn-download-final:hover {
  background: #0d8a47;
  transform: translateY(-1px);
}

/* ========================================================
   RESPONSIVE MEDIA QUERIES
   ======================================================== */
@media (max-width: 992px) {
  .editor-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}
@media (max-width: 768px) {
  .previews-panel, .controls-panel, .result-card {
    padding: 16px 14px;
  }
  .comparison-grid {
    grid-template-columns: 1fr;
  }
  .compare-stage {
    height: 220px;
  }
  .result-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .bg-options-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
