/* BG Remover Pro — front-end styles (v1.1 premium refresh)
 * All selectors are scoped under .bgr-wrapper so the plugin never leaks
 * styles into (or inherits conflicting styles from) the active theme.
 */
.bgr-wrapper {
	--bgr-primary: #4f46e5;
	--bgr-primary-hover: #4338ca;
	--bgr-primary-soft: #eef2ff;
	--bgr-success: #16a34a;
	--bgr-success-hover: #128a3e;
	--bgr-secondary: #64748b;
	--bgr-secondary-hover: #52616f;
	--bgr-card-bg: #ffffff;
	--bgr-border: #e6e8ef;
	--bgr-text: #0f172a;
	--bgr-muted: #667085;
	--bgr-radius: 20px;
	--bgr-danger: #dc2626;

	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
	color: var(--bgr-text);
	max-width: 1200px;
	margin: 40px auto;
	padding: 0 16px;
	-webkit-font-smoothing: antialiased;
}

.bgr-wrapper *,
.bgr-wrapper *::before,
.bgr-wrapper *::after {
	box-sizing: border-box;
}

.bgr-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
	gap: 28px;
	align-items: start;
}

.bgr-grid--single {
	grid-template-columns: minmax(320px, 580px);
	justify-content: center;
}

.bgr-card {
	position: relative;
	background: var(--bgr-card-bg);
	border-radius: var(--bgr-radius);
	border: 1px solid var(--bgr-border);
	padding: 34px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 20px 40px -12px rgba(16, 24, 40, 0.08);
	overflow: hidden;
}

.bgr-card::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: linear-gradient(90deg, var(--bgr-primary), #818cf8 45%, var(--bgr-success));
	opacity: 0.9;
}

.bgr-title {
	text-align: center;
	margin: 6px 0 10px;
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.3;
}

.bgr-subtitle {
	text-align: center;
	color: var(--bgr-muted);
	margin: 0 0 22px;
	font-size: 0.96rem;
	line-height: 1.55;
}

.bgr-how-image {
	max-width: 100%;
	height: auto;
	display: block;
	margin: 0 auto 20px;
	border-radius: 16px;
	box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

.bgr-video-box {
	position: relative;
	padding-top: 56.25%;
	border-radius: 16px;
	overflow: hidden;
	border: 1px solid var(--bgr-border);
	background: #000;
}

.bgr-video-box video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ===== Upload area ===== */
.bgr-upload-area {
	background: linear-gradient(180deg, #fbfcff 0%, #ffffff 100%);
	border-radius: 22px;
	padding: 42px 20px;
	text-align: center;
	border: 1.5px dashed #d6d9e6;
	transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.bgr-upload-area.is-dragover {
	border-color: var(--bgr-primary);
	background: var(--bgr-primary-soft);
	box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}

.bgr-upload-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 30px;
	background: linear-gradient(180deg, #6366f1 0%, var(--bgr-primary) 100%);
	color: #fff;
	border-radius: 14px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
	user-select: none;
	box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.bgr-upload-icon {
	display: inline-flex;
	line-height: 0;
}

.bgr-upload-btn:hover {
	filter: brightness(1.05);
	transform: translateY(-2px);
	box-shadow: 0 12px 26px rgba(79, 70, 229, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.bgr-upload-btn:active {
	transform: translateY(0);
}

.bgr-upload-btn:focus-within {
	outline: 3px solid rgba(79, 70, 229, 0.35);
	outline-offset: 2px;
}

.bgr-upload-help {
	margin-top: 16px;
	font-size: 0.9rem;
	color: var(--bgr-muted);
}

.bgr-kbd {
	background: #f1f2f9;
	padding: 4px 8px;
	border-radius: 6px;
	font-weight: 600;
	color: #3f3f6b;
	font-size: 0.85em;
	border: 1px solid #e5e6f2;
}

.bgr-file-name {
	margin-top: 12px;
	font-size: 0.85rem;
	color: var(--bgr-primary);
	font-weight: 600;
	word-break: break-all;
	min-height: 1em;
}

.bgr-wrapper input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.bgr-controls {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-top: 24px;
}

.bgr-message {
	text-align: center;
	color: var(--bgr-muted);
	font-size: 0.95rem;
	margin: 0;
	min-height: 1.3em;
	transition: color 0.2s ease;
}

.bgr-message.is-error {
	color: var(--bgr-danger);
	font-weight: 600;
}

.bgr-message.is-success {
	color: var(--bgr-success);
	font-weight: 600;
}

.bgr-btn {
	position: relative;
	width: 100%;
	padding: 15px;
	font-size: 16px;
	font-weight: 650;
	border-radius: 14px;
	border: none;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
	font-family: inherit;
	letter-spacing: 0.01em;
}

.bgr-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none !important;
	box-shadow: none !important;
}

.bgr-btn:not(:disabled):hover {
	transform: translateY(-2px);
	filter: brightness(1.04);
}

.bgr-btn:not(:disabled):active {
	transform: translateY(0);
}

.bgr-btn--primary {
	background: linear-gradient(180deg, #6366f1 0%, var(--bgr-primary) 100%);
	color: #fff;
	box-shadow: 0 8px 18px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.bgr-btn--success {
	background: linear-gradient(180deg, #22c55e 0%, var(--bgr-success) 100%);
	color: #fff;
	box-shadow: 0 8px 18px rgba(22, 163, 74, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.bgr-btn--secondary {
	background: #fff;
	color: var(--bgr-text);
	border: 1.5px solid var(--bgr-border);
	box-shadow: none;
}
.bgr-btn--secondary:not(:disabled):hover {
	border-color: #c7cad9;
	background: #fafafd;
}

.bgr-btn.is-loading {
	color: transparent !important;
	pointer-events: none;
}
.bgr-btn.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border: 2.5px solid rgba(255, 255, 255, 0.4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: bgr-spin 0.8s linear infinite;
}

/* ===== Preview ===== */
.bgr-preview {
	margin-top: 28px;
	text-align: center;
}

.bgr-preview-label {
	margin: 0 0 12px;
	font-size: 0.9rem;
	color: var(--bgr-muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 700;
}

.bgr-canvas-wrap {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 60px;
	background-image:
		linear-gradient(45deg, #f1f3f9 25%, transparent 25%),
		linear-gradient(-45deg, #f1f3f9 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #f1f3f9 75%),
		linear-gradient(-45deg, transparent 75%, #f1f3f9 75%);
	background-size: 20px 20px;
	background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
	border-radius: 16px;
	border: 1px solid var(--bgr-border);
	overflow: hidden;
}

.bgr-wrapper canvas {
	max-width: 100%;
	height: auto;
	display: block;
	animation: bgr-fade-in 0.35s ease;
}

/* Processing overlay — sits above the canvas, centered, with its own
   backdrop so it never gets lost behind the checkerboard preview, and
   never lingers: it is only ever toggled by the is-visible class, which
   the script always clears in a finally block regardless of success or
   failure. */
.bgr-loader-overlay {
	display: none;
	position: absolute;
	inset: 0;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(255, 255, 255, 0.78);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	z-index: 5;
}

.bgr-loader-overlay.is-visible {
	display: flex;
}

.bgr-loader-spinner {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	border: 4px solid rgba(79, 70, 229, 0.15);
	border-top-color: var(--bgr-primary);
	animation: bgr-spin 0.9s linear infinite;
}

.bgr-loader-text {
	margin: 0;
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--bgr-primary);
}

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

@keyframes bgr-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* ===== Background picker (shown after a successful removal) ===== */
.bgr-bg-options {
	display: none;
	margin-top: 22px;
	padding-top: 20px;
	border-top: 1px solid var(--bgr-border);
	animation: bgr-fade-in 0.3s ease;
}

.bgr-bg-options.is-visible {
	display: block;
}

.bgr-bg-options-label {
	margin: 0 0 12px;
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--bgr-text);
	text-align: left;
}

.bgr-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
}

.bgr-swatch {
	position: relative;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 2px solid #fff;
	box-shadow: 0 0 0 1.5px var(--bgr-border);
	cursor: pointer;
	padding: 0;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	overflow: hidden;
}

.bgr-swatch:hover {
	transform: translateY(-2px) scale(1.06);
}

.bgr-swatch.is-active {
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--bgr-primary);
}

.bgr-swatch--transparent {
	background-image:
		linear-gradient(45deg, #d8dae4 25%, transparent 25%),
		linear-gradient(-45deg, #d8dae4 25%, transparent 25%),
		linear-gradient(45deg, transparent 75%, #d8dae4 75%),
		linear-gradient(-45deg, transparent 75%, #d8dae4 75%);
	background-size: 10px 10px;
	background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
	background-color: #fff;
}

.bgr-swatch--custom {
	display: flex;
	align-items: center;
	justify-content: center;
	background: conic-gradient(from 180deg, #ef4444, #f59e0b, #22c55e, #0ea5e9, #6366f1, #ef4444);
}

.bgr-swatch--custom input[type="color"] {
	opacity: 0;
	width: 100%;
	height: 100%;
	cursor: pointer;
	border: none;
	padding: 0;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
	.bgr-grid {
		gap: 22px;
	}
}

@media (max-width: 782px) {
	.bgr-wrapper {
		margin: 24px auto;
	}
	.bgr-card {
		padding: 24px;
		border-radius: 16px;
	}
	.bgr-title {
		font-size: 1.3rem;
	}
	.bgr-upload-area {
		padding: 30px 14px;
	}
	.bgr-upload-btn {
		width: 100%;
		justify-content: center;
	}
	.bgr-swatch {
		width: 32px;
		height: 32px;
	}
}

@media (max-width: 480px) {
	.bgr-wrapper {
		padding: 0 10px;
	}
	.bgr-card {
		padding: 18px;
	}
	.bgr-btn {
		padding: 13px;
		font-size: 15px;
	}
	.bgr-loader-spinner {
		width: 38px;
		height: 38px;
	}
	.bgr-swatches {
		gap: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bgr-wrapper * {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}
