/**
 * Sityn Enhancer for Bricks Builder – BEM Generator Styles
 *
 * Modern UI inspired by Apple, Shadcn, and Framer design principles.
 * Uses CSS custom properties, smooth transitions, backdrop-blur,
 * and refined micro-animations throughout.
 *
 * @package SitynEnhancer
 */

/* ── Variables ──────────────────────────────────────────────────────── */

:root {
	--brxe-bg-primary: #0f1114;
	--brxe-bg-secondary: #181b20;
	--brxe-bg-elevated: #1e2228;
	--brxe-bg-input: #252a31;
	--brxe-bg-hover: rgba(255, 255, 255, 0.04);
	--brxe-border-subtle: rgba(255, 255, 255, 0.08);
	--brxe-border-default: rgba(255, 255, 255, 0.12);
	--brxe-border-focus: rgba(99, 179, 237, 0.6);
	--brxe-text-primary: #f0f0f0;
	--brxe-text-secondary: #a0a4ab;
	--brxe-text-tertiary: #6b7280;
	--brxe-accent: #63b3ed;
	--brxe-accent-soft: rgba(99, 179, 237, 0.15);
	--brxe-accent-hover: #7cc4f5;
	--brxe-error: #f87171;
	--brxe-error-soft: rgba(248, 113, 113, 0.1);
	--brxe-skip: rgba(255, 255, 255, 0.03);
	--brxe-radius-sm: 6px;
	--brxe-radius-md: 8px;
	--brxe-radius-lg: 12px;
	--brxe-radius-xl: 16px;
	--brxe-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
	--brxe-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
	--brxe-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.55);
	--brxe-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
	--brxe-transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
	--brxe-transition-smooth: 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── BEM Trigger Button in Structure Panel ──────────────────────────── */

.brxe-bem-trigger-btn {
	display: inline-flex;
	align-items: center;
	margin: 0 4px;
	color: var(--brxe-text-tertiary);
	font-size: 9px;
	font-weight: 700;
	border-radius: 3px;
	cursor: pointer;
	letter-spacing: 0.5px;
	transition: color var(--brxe-transition-fast),
		transform var(--brxe-transition-fast);
}

.brxe-bem-trigger-btn:hover {
	color: var(--brxe-accent);
	transform: scale(1.05);
}

/* When Element Actions are off, position the button inside the li */
.brxe-bem-trigger-btn--no-actions {
	position: absolute;
	right: 8px;
	top: 8px;
	z-index: 1;
}

li[data-id]:hover>.brxe-bem-trigger-btn--no-actions {
	opacity: 1;
}

/* ── Draggable Panel ────────────────────────────────────────────────── */

.brxe-bem-panel {
	position: fixed;
	width: 460px;
	max-width: 92vw;
	z-index: 100000;
	background: var(--brxe-bg-primary);
	border: 1px solid var(--brxe-border-subtle);
	border-radius: var(--brxe-radius-xl);
	box-shadow: var(--brxe-shadow-lg);
	display: flex;
	flex-direction: column;
	font-family: -apple-system, "SF Pro Display", "Inter", BlinkMacSystemFont,
		"Segoe UI", sans-serif;
	color: var(--brxe-text-primary);
	font-size: 13px;
	opacity: 0;
	transform: translateY(8px) scale(0.98);
	transition: opacity var(--brxe-transition-smooth),
		transform var(--brxe-transition-smooth);
	resize: both;
	overflow: hidden;
	min-width: 380px;
	min-height: 250px;
	max-height: 85vh;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.brxe-bem-panel[style*="opacity: 1"] {
	transform: translateY(0) scale(1);
}

/* ── Header ─────────────────────────────────────────────────────────── */

.brxe-bem-header {
	padding: 14px 18px;
	background: var(--brxe-bg-secondary);
	border-bottom: 1px solid var(--brxe-border-subtle);
	display: flex;
	justify-content: space-between;
	align-items: center;
	cursor: grab;
	user-select: none;
	height: 48px;
	border-radius: var(--brxe-radius-xl) var(--brxe-radius-xl) 0 0;
}

.brxe-bem-header:active {
	cursor: grabbing;
}

.brxe-bem-header h2 {
	margin: 0;
	font-size: 13px;
	font-weight: 600;
	color: var(--brxe-text-primary);
	letter-spacing: -0.01em;
	pointer-events: none;
}

.brxe-bem-close {
	background: none;
	border: none;
	font-size: 18px;
	color: var(--brxe-text-tertiary);
	cursor: pointer;
	padding: 4px;
	line-height: 1;
	border-radius: var(--brxe-radius-sm);
	transition: color var(--brxe-transition-fast),
		background var(--brxe-transition-fast);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
}

.brxe-bem-close:hover {
	color: var(--brxe-text-primary);
	background: var(--brxe-bg-hover);
}

/* ── Body ───────────────────────────────────────────────────────────── */

.brxe-bem-body {
	padding: 16px 18px;
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--brxe-bg-primary);
}

/* Smooth scrollbar */
.brxe-bem-body::-webkit-scrollbar {
	width: 5px;
}

.brxe-bem-body::-webkit-scrollbar-track {
	background: transparent;
}

.brxe-bem-body::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.1);
	border-radius: 10px;
}

.brxe-bem-body::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.18);
}

/* ── Label Group (animated show/hide) ──────────────────────────────── */

.brxe-bem-label-group {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 11px;
	color: var(--brxe-text-tertiary);
	padding-right: 5px;
	overflow: hidden;
	max-height: 24px;
	opacity: 1;
	margin-bottom: 4px;
	transition: max-height var(--brxe-transition-smooth),
		opacity var(--brxe-transition-normal),
		margin-bottom var(--brxe-transition-smooth);
}

.brxe-bem-body.hide-labels .brxe-bem-label-group {
	max-height: 0;
	opacity: 0;
	margin-bottom: 0;
}

.brxe-bem-body.hide-labels {
	gap: 6px;
}

/* ── Row ────────────────────────────────────────────────────────────── */

.brxe-bem-row {
	display: flex;
	flex-direction: row;
	position: relative;
	align-items: flex-start;
	gap: 8px;
	border-radius: var(--brxe-radius-md);
	transition: opacity var(--brxe-transition-normal),
		transform var(--brxe-transition-normal);
}

/* Skipped row styling */
.brxe-bem-row.brxe-bem-row--skipped {
	opacity: 0.35;
}

.brxe-bem-row.brxe-bem-row--skipped .brxe-bem-class-wrapper {
	background: var(--brxe-skip);
	border-style: dashed;
}

.brxe-bem-row.brxe-bem-row--skipped .brxe-bem-inner-input {
	text-decoration: line-through;
	text-decoration-color: var(--brxe-text-tertiary);
	pointer-events: none;
}

/* ── Indent Wrappers (tree hierarchy) ───────────────────────────────── */

.brxe-bem-indent-wrapper {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0;
	min-width: 0;
}

.brxe-bem-indent-1 {
	padding-left: 16px;
	border-left: 1px solid var(--brxe-border-subtle);
}

.brxe-bem-indent-2 {
	padding-left: 16px;
	border-left: 1px solid var(--brxe-border-subtle);
	margin-left: 16px;
}

.brxe-bem-indent-3 {
	padding-left: 16px;
	border-left: 1px solid var(--brxe-border-subtle);
	margin-left: 32px;
}

.brxe-bem-indent-4 {
	padding-left: 16px;
	border-left: 1px solid var(--brxe-border-subtle);
	margin-left: 48px;
}

/* ── Label Group (inside rows) ─────────────────────────────────────── */

.brxe-bem-original-name {
	font-weight: 500;
	color: var(--brxe-text-secondary);
	font-size: 11px;
}

.brxe-bem-tag {
	font-size: 9px;
	text-transform: uppercase;
	font-weight: 600;
	letter-spacing: 0.5px;
	background: var(--brxe-bg-elevated);
	padding: 2px 6px;
	border-radius: 4px;
	color: var(--brxe-text-tertiary);
	border: 1px solid var(--brxe-border-subtle);
}

/* ── Input Group ────────────────────────────────────────────────────── */

.brxe-bem-input-group {
	display: flex;
	gap: 6px;
	width: 100%;
}

.brxe-bem-class-wrapper {
	flex: 1;
	display: flex;
	align-items: center;
	padding: 0 10px;
	height: 34px;
	background: var(--brxe-bg-input);
	border: 1px solid var(--brxe-border-default);
	border-radius: var(--brxe-radius-md);
	transition: border-color var(--brxe-transition-fast),
		background-color var(--brxe-transition-fast),
		box-shadow var(--brxe-transition-fast);
	overflow: hidden;
	cursor: text;
	position: relative;
}

.brxe-bem-class-wrapper:focus-within {
	border-color: var(--brxe-border-focus);
	background: var(--brxe-bg-elevated);
	box-shadow: 0 0 0 3px var(--brxe-accent-soft);
}

.brxe-bem-block-prefix {
	color: var(--brxe-accent);
	font-family: "SF Mono", "Fira Code", "JetBrains Mono", "Consolas", monospace;
	font-size: 12px;
	white-space: nowrap;
	user-select: none;
	pointer-events: none;
	margin-right: 1px;
	opacity: 0.8;
}

.brxe-bem-inner-input {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--brxe-text-primary);
	font-family: "SF Mono", "Fira Code", "JetBrains Mono", "Consolas", monospace;
	font-size: 12px;
	outline: none;
	padding: 0;
	min-width: 0;
	transition: color var(--brxe-transition-fast);
}

.brxe-bem-inner-input::placeholder {
	color: var(--brxe-text-tertiary);
}

.brxe-bem-inner-input[data-is-block="true"] {
	color: var(--brxe-accent);
	font-weight: 600;
}

/* Skip toggle button (replaces clear button) */
.brxe-bem-skip-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	background: transparent;
	border: 1px solid var(--brxe-border-subtle);
	border-radius: var(--brxe-radius-sm);
	color: var(--brxe-text-tertiary);
	font-size: 11px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	flex-shrink: 0;
	transition: all var(--brxe-transition-fast);
}

.brxe-bem-skip-toggle:hover {
	background: rgba(248, 113, 113, 0.1);
	border-color: rgba(248, 113, 113, 0.3);
	color: var(--brxe-error);
}

/* When row is skipped, show "+" to re-enable */
.brxe-bem-row--skipped .brxe-bem-skip-toggle {
	background: var(--brxe-accent-soft);
	border-color: rgba(99, 179, 237, 0.3);
	color: var(--brxe-accent);
}

.brxe-bem-row--skipped .brxe-bem-skip-toggle:hover {
	background: rgba(99, 179, 237, 0.25);
	border-color: var(--brxe-accent);
	color: var(--brxe-accent-hover);
}

/* ── Toggle Switches ────────────────────────────────────────────────── */

.brxe-bem-toggle-group {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	margin-bottom: 0;
}

.brxe-bem-toggle-text {
	font-size: 11px;
	color: var(--brxe-text-tertiary);
	font-weight: 500;
	user-select: none;
	padding-top: 1px;
	white-space: nowrap;
	transition: color var(--brxe-transition-fast);
}

.brxe-bem-toggle-group:hover .brxe-bem-toggle-text {
	color: var(--brxe-text-secondary);
}

.brxe-bem-switch {
	position: relative;
	display: inline-block;
	width: 32px;
	height: 18px;
}

.brxe-bem-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.brxe-bem-slider {
	position: absolute;
	cursor: pointer;
	inset: 0;
	background-color: var(--brxe-bg-elevated);
	border: 1px solid var(--brxe-border-default);
	transition: background-color var(--brxe-transition-normal),
		border-color var(--brxe-transition-normal);
	border-radius: 18px;
}

.brxe-bem-slider::before {
	content: "";
	position: absolute;
	height: 12px;
	width: 12px;
	left: 2px;
	bottom: 2px;
	background-color: var(--brxe-text-tertiary);
	transition: transform var(--brxe-transition-normal),
		background-color var(--brxe-transition-normal);
	border-radius: 50%;
}

.brxe-bem-switch input:checked+.brxe-bem-slider {
	background-color: var(--brxe-accent);
	border-color: var(--brxe-accent);
}

.brxe-bem-switch input:checked+.brxe-bem-slider::before {
	transform: translateX(14px);
	background-color: var(--brxe-bg-primary);
}

/* ── Footer ─────────────────────────────────────────────────────────── */

.brxe-bem-footer {
	padding: 14px 18px;
	background: var(--brxe-bg-secondary);
	border-top: 1px solid var(--brxe-border-subtle);
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	border-radius: 0 0 var(--brxe-radius-xl) var(--brxe-radius-xl);
}

.brxe-bem-footer-left,
.brxe-bem-footer-right {
	display: flex;
	align-items: center;
	gap: 14px;
}

/* ── Buttons ────────────────────────────────────────────────────────── */

.brxe-bem-btn {
	padding: 0 18px;
	height: 34px;
	border-radius: var(--brxe-radius-md);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	border: none;
	letter-spacing: -0.01em;
	transition: all var(--brxe-transition-fast);
	display: flex;
	align-items: center;
	justify-content: center;
}

.brxe-bem-btn-primary {
	background: var(--brxe-accent);
	color: var(--brxe-bg-primary);
}

.brxe-bem-btn-primary:hover {
	background: var(--brxe-accent-hover);
	box-shadow: 0 2px 12px rgba(99, 179, 237, 0.3);
	transform: translateY(-1px);
}

.brxe-bem-btn-primary:active {
	transform: translateY(0);
	box-shadow: none;
}

/* ── Validation States ──────────────────────────────────────────────── */

@keyframes brxeBemShake {

	0%,
	100% {
		transform: translateX(0);
	}

	20%,
	60% {
		transform: translateX(-3px);
	}

	40%,
	80% {
		transform: translateX(3px);
	}
}

.brxe-bem-input-error {
	border-color: var(--brxe-error) !important;
	background-color: var(--brxe-error-soft) !important;
	box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1) !important;
}

.brxe-bem-shake {
	animation: brxeBemShake 0.35s ease-in-out;
}

/* ── Mode Selector (re-entry) ───────────────────────────────────────── */

.brxe-bem-mode-section {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 6px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--brxe-border-subtle);
}

.brxe-bem-mode-label {
	font-size: 11px;
	font-weight: 500;
	color: var(--brxe-text-tertiary);
	letter-spacing: 0.01em;
}

.brxe-bem-select-wrapper {
	position: relative;
	width: 100%;
}

.brxe-bem-select {
	width: 100%;
	height: 36px;
	padding: 0 34px 0 12px;
	background: var(--brxe-bg-input);
	border: 1px solid var(--brxe-border-default);
	border-radius: var(--brxe-radius-md);
	color: var(--brxe-text-primary);
	font-family: -apple-system, "SF Pro Display", "Inter", sans-serif;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	outline: none;
	transition: border-color var(--brxe-transition-fast),
		box-shadow var(--brxe-transition-fast);
}

.brxe-bem-select:hover {
	border-color: var(--brxe-border-focus);
}

.brxe-bem-select:focus {
	border-color: var(--brxe-border-focus);
	box-shadow: 0 0 0 3px var(--brxe-accent-soft);
}

.brxe-bem-select option {
	background: var(--brxe-bg-elevated);
	color: var(--brxe-text-primary);
	padding: 8px 12px;
}

.brxe-bem-select-arrow {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--brxe-text-tertiary);
	font-size: 9px;
	pointer-events: none;
	transition: color var(--brxe-transition-fast);
}

.brxe-bem-select-wrapper:hover .brxe-bem-select-arrow {
	color: var(--brxe-accent);
}

/* ── Copy Styles Toggle (inside mode section) ──────────────────────── */

.brxe-bem-copy-styles-row {
	margin-top: 4px;
	padding: 10px 12px;
	background: var(--brxe-bg-elevated);
	border: 1px solid var(--brxe-border-subtle);
	border-radius: var(--brxe-radius-md);
	animation: brxeCopyStylesSlideIn var(--brxe-transition-smooth) forwards;
}

@keyframes brxeCopyStylesSlideIn {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ── Focus-Visible Accessibility ────────────────────────────────────── */

.brxe-bem-btn:focus-visible {
	outline: 2px solid var(--brxe-accent);
	outline-offset: 0.15em;
}

.brxe-bem-close:focus-visible {
	outline: 2px solid var(--brxe-accent);
	outline-offset: 0.15em;
}

.brxe-bem-switch input:focus-visible+.brxe-bem-slider {
	outline: 2px solid var(--brxe-accent);
	outline-offset: 0.15em;
}

.brxe-bem-select:focus-visible {
	outline: 2px solid var(--brxe-accent);
	outline-offset: 0.15em;
}

.brxe-bem-skip-toggle:focus-visible {
	outline: 2px solid var(--brxe-accent);
	outline-offset: 0.15em;
}