/* =========================================================================
 * Kips Template — Remove Background UI
 *
 * Holds: visual styling for the topbar Hapus BG button, the centred
 * circular progress popup, and the soft data-empty state shared with
 * Undo / Redo.
 *
 * Goal: zero impact on the existing topbar layout. Only adds states.
 * ========================================================================= */

/* ---- Topbar button ---- */
.kips-bgremove-btn { position: relative; }
.kips-bgremove-btn[data-empty] svg { opacity: 0.42; }
.kips-bgremove-btn:hover svg { opacity: 1; }

/* Subtle gradient tint below the icon to differentiate from undo/redo. */
.kips-bgremove-btn::after {
  content: '';
  position: absolute; inset: auto 4px 3px;
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, #6E5BFF, #00DCC8);
  opacity: 0.6;
  pointer-events: none;
}
.kips-bgremove-btn.is-running { background: var(--kt-surface-2); }
.kips-bgremove-btn.is-running::after {
  opacity: 1;
  animation: kips-bgremove-pulse 1.6s ease-in-out infinite;
}
@keyframes kips-bgremove-pulse {
  0%, 100% { transform: scaleX(0.55); transform-origin: 0% 50%; }
  50%      { transform: scaleX(1);    transform-origin: 0% 50%; }
}

/* ---- Generic flash for Undo / Redo / BG remove on success ---- */
.kips-iconbtn.kips-flash { animation: kips-iconbtn-flash 380ms ease-out; }
@keyframes kips-iconbtn-flash {
  0%   { background: color-mix(in oklab, var(--kt-accent, #6E5BFF) 36%, transparent); transform: scale(1.06); }
  60%  { background: color-mix(in oklab, var(--kt-accent, #6E5BFF) 18%, transparent); transform: scale(1.0); }
  100% { background: transparent; transform: scale(1.0); }
}

/* ---- Soft-empty state for undo / redo / bg-remove ----
 * Replaces the older [disabled] hard-block with a friendlier dim that
 * still lets the user click — the click handler then shows a toast so
 * the user knows the click registered. */
.kips-iconbtn[data-empty] svg { opacity: 0.42; }
.kips-iconbtn[data-empty]:hover svg { opacity: 0.7; }

/* ---- Centered circular progress popup ---- */
.kips-bgremove-overlay {
  position: fixed; inset: 0;
  z-index: 220;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.kips-bgremove-overlay.is-open { opacity: 1; pointer-events: auto; }

.kips-bgremove-ring {
  position: relative;
  width: 168px; height: 168px;
  /* Subtle scale-in entrance */
  transform: scale(0.94);
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.kips-bgremove-overlay.is-open .kips-bgremove-ring { transform: scale(1); }

.kips-bgremove-ring svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);                  /* progress starts at 12 o'clock */
  filter: drop-shadow(0 8px 24px rgba(110, 91, 255, 0.45));
}

.kips-bgremove-ring__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 8;
}
.kips-bgremove-ring__bar {
  fill: none;
  stroke: url(#kipsBgGradient);
  stroke-width: 8;
  stroke-linecap: round;
  /* stroke-dasharray + stroke-dashoffset are set inline via JS so the
     SVG does not depend on a hard-coded circumference. */
  transition: stroke-dashoffset 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.kips-bgremove-ring__pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font: 700 32px / 1 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  /* The number must read crisply in both themes — white on a 60% black
     backdrop reads well in either case. */
  font-variant-numeric: tabular-nums;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .kips-bgremove-overlay,
  .kips-bgremove-ring,
  .kips-bgremove-ring__bar { transition: none; }
}
