/*
 * bg-tool.css: Styling for client-side AI Background Remover.
 * Matches design system of ImageSize tools.
 */
/* the display:flex rules below would otherwise override the hidden attribute */
.bg-tool [hidden] {
  display: none !important;
}
.bg-tool {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
}

.bg-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 44px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.bg-drop:hover, .bg-drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.bg-drop input[type="file"] {
  display: none;
}

.bg-drop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 14px;
}

.bg-drop strong {
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 6px;
}

.bg-muted {
  font-size: 0.88rem;
  color: var(--muted);
}

.bg-privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 14px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* Error message */
.bg-err {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Progress indicator */
.bg-progress-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bg-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.bg-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.bg-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

/* Controls & Background Replacement */
.bg-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.bg-bg-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bg-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.bg-color-swatches {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bg-color-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.bg-color-btn:hover {
  border-color: var(--accent);
}

.bg-color-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.bg-color-sample {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: inline-block;
}

.bg-color-sample.checker {
  background: repeating-conic-gradient(#bbb 0% 25%, #fff 0% 50%) 50% / 8px 8px;
}

.bg-color-sample.white {
  background: #ffffff;
}

.bg-color-sample.black {
  background: #000000;
}

.bg-custom-color-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bg-color-picker-input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  background: none;
  vertical-align: middle;
}

/* Comparison slider & preview */
.bg-preview-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  background: repeating-conic-gradient(#ddd 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

.bg-slider-container {
  position: relative;
  width: 100%;
  height: 100%;
  user-select: none;
  touch-action: none;
}

.bg-canvas-display {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.bg-overlay-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  clip-path: inset(0 50% 0 0);
  pointer-events: none;
}

.bg-overlay-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bg-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(0,0,0,0.4);
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 10;
}

.bg-handle-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  cursor: ew-resize;
}

.bg-badge {
  position: absolute;
  top: 12px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  z-index: 5;
  pointer-events: none;
}

.bg-badge-before {
  left: 12px;
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
}

.bg-badge-after {
  right: 12px;
  background: rgba(15, 110, 86, 0.85);
  color: #ffffff;
}

/* Actions bar */
.bg-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bg-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.bg-btn-primary:hover {
  opacity: 0.9;
}

.bg-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.bg-btn-secondary:hover {
  background: var(--bg);
}

.bg-stats {
  display: flex;
  gap: 16px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Contextual Cross-Tool Callout Box */
.cross-tool-box {
  margin: 24px 0;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cross-tool-box h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--text);
}
.cross-tool-box p {
  margin: 0 0 14px;
  font-size: 0.95rem;
  color: var(--muted);
}
.cross-tool-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.cross-tool-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.15s;
}
.cross-tool-link:hover {
  opacity: 0.85;
}
