/* EasySite Visual Editor – front-end overlay UI */

body.easysite-visual-editing {
	padding-top: 56px !important;
}

body.easysite-visual-editing .easysite-header,
body.easysite-visual-editing #wpadminbar {
	pointer-events: none;
}

body.easysite-visual-editing #wpadminbar {
	opacity: 0.5;
}

/* Toolbar */
.esb-ve-toolbar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0 1.25rem;
	height: 56px;
	background: linear-gradient(135deg, #1e1b4b, #312e81);
	color: #fff;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
	font-family: system-ui, -apple-system, sans-serif;
}

.esb-ve-toolbar__brand {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.95rem;
}

.esb-ve-toolbar__brand .dashicons {
	color: #a78bfa;
}

.esb-ve-status {
	font-size: 0.8rem;
	opacity: 0.85;
	margin-left: 0.5rem;
	color: #fbbf24;
}

.esb-ve-toolbar__actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.esb-ve-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.5rem 1rem;
	border-radius: 8px;
	border: 0;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	color: inherit;
	line-height: 1.2;
	transition: transform 0.12s, opacity 0.12s;
}

.esb-ve-btn .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

.esb-ve-btn--ghost {
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
}

.esb-ve-btn--ghost:hover {
	background: rgba(255, 255, 255, 0.2);
}

.esb-ve-btn--primary {
	background: linear-gradient(135deg, #7c3aed, #06b6d4);
	color: #fff;
}

.esb-ve-btn--primary:hover {
	opacity: 0.92;
	transform: translateY(-1px);
}

.esb-ve-btn--exit {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.35);
	color: #fff;
}

.esb-ve-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Section blocks */
.esb-ve-block {
	position: relative;
	outline: 2px solid transparent;
	outline-offset: -2px;
	transition: outline-color 0.15s;
}

.esb-ve-block:hover {
	outline-color: #7c3aed;
}

.esb-ve-block-toolbar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.35rem 0.5rem;
	background: rgba(30, 27, 75, 0.92);
	color: #fff;
	font-size: 0.8rem;
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity 0.15s, transform 0.15s;
	pointer-events: none;
}

.esb-ve-block:hover .esb-ve-block-toolbar {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.esb-ve-block-label {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	cursor: grab;
	font-weight: 600;
}

.esb-ve-block-actions {
	display: flex;
	gap: 0.15rem;
}

.esb-ve-icon-btn {
	background: rgba(255, 255, 255, 0.1);
	border: 0;
	color: #fff;
	width: 28px;
	height: 28px;
	border-radius: 6px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.esb-ve-icon-btn:hover {
	background: rgba(255, 255, 255, 0.22);
}

.esb-ve-icon-btn--danger:hover {
	background: #dc2626;
}

.esb-ve-icon-btn .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

.esb-ve-sort-placeholder {
	height: 80px;
	background: rgba(124, 58, 237, 0.15);
	border: 2px dashed #7c3aed;
	border-radius: 8px;
	margin: 0.5rem 0;
}

/* Editable text */
[contenteditable="true"] {
	outline: none;
	cursor: text;
	border-radius: 4px;
	transition: box-shadow 0.15s;
}

[contenteditable="true"]:hover,
[contenteditable="true"]:focus {
	box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.45);
}

[contenteditable="true"].esb-placeholder {
	opacity: 0.55;
	font-style: italic;
}

/* Editable images */
.esb-editable-image {
	position: relative;
	cursor: pointer;
}

.esb-editable-image::after,
.esb-ve-change-bg {
	content: none;
}

.esb-editable-image:hover::before {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(124, 58, 237, 0.35);
	border-radius: inherit;
	pointer-events: none;
}

.esb-editable-image .esb-ve-img-overlay,
.esb-ve-change-bg {
	position: absolute;
	bottom: 1rem;
	left: 50%;
	transform: translateX(-50%);
	z-index: 10;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.6rem 1.1rem;
	background: #fff;
	color: #1e1b4b;
	border: 0;
	border-radius: 999px;
	font-weight: 700;
	font-size: 0.85rem;
	cursor: pointer;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
	opacity: 0;
	transition: opacity 0.15s;
}

.esb-editable-image:hover .esb-ve-img-overlay,
.easysite-pb-hero:hover .esb-ve-change-bg,
.esb-ve-block:hover .esb-ve-change-bg {
	opacity: 1;
}

.esb-ve-change-bg .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/* Side panels */
.esb-ve-panel {
	position: fixed;
	top: 56px;
	right: 0;
	width: min(360px, 100vw);
	height: calc(100vh - 56px);
	z-index: 99999;
	background: #fff;
	box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
	display: flex;
	flex-direction: column;
	font-family: system-ui, -apple-system, sans-serif;
}

.esb-ve-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid #e5e7eb;
}

.esb-ve-panel__head h3 {
	margin: 0;
	font-size: 1rem;
}

.esb-ve-panel__close {
	background: none;
	border: 0;
	font-size: 1.5rem;
	cursor: pointer;
	line-height: 1;
	color: #6b7280;
}

.esb-ve-panel__body {
	padding: 1rem 1.25rem;
	overflow-y: auto;
	flex: 1;
}

.esb-ve-library-item {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.25rem;
	width: 100%;
	text-align: left;
	padding: 1rem;
	margin-bottom: 0.5rem;
	border: 2px solid #e5e7eb;
	border-radius: 10px;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}

.esb-ve-library-item:hover {
	border-color: #7c3aed;
	background: #f5f3ff;
}

.esb-ve-library-item .dashicons {
	color: #7c3aed;
	font-size: 24px;
	width: 24px;
	height: 24px;
}

.esb-ve-library-item strong {
	font-size: 0.95rem;
}

.esb-ve-library-item span:last-child {
	font-size: 0.8rem;
	color: #6b7280;
}

.esb-ve-field-row {
	margin-bottom: 1rem;
}

.esb-ve-field-row label {
	display: block;
	font-weight: 600;
	font-size: 0.85rem;
	margin-bottom: 0.35rem;
}

.esb-ve-input,
.esb-ve-field-row select,
.esb-ve-field-row textarea {
	width: 100%;
	padding: 0.5rem 0.65rem;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 0.9rem;
}

.esb-ve-img-preview {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	margin-bottom: 0.5rem;
	display: block;
}

/* Modal */
.esb-ve-modal {
	position: fixed;
	inset: 0;
	z-index: 100001;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.esb-ve-modal[hidden] {
	display: none !important;
}

.esb-ve-modal__box {
	background: #fff;
	border-radius: 12px;
	padding: 1.5rem;
	width: min(400px, 100%);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.esb-ve-modal__box h3 {
	margin: 0 0 1rem;
}

.esb-ve-modal__actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 1rem;
}

.esb-editable-button {
	position: relative;
}

.esb-spin {
	animation: esb-spin 0.8s linear infinite;
}

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

@media (max-width: 640px) {
	.esb-ve-toolbar {
		flex-wrap: wrap;
		height: auto;
		padding: 0.5rem;
	}

	body.easysite-visual-editing {
		padding-top: 100px !important;
	}

	.esb-ve-panel {
		top: 100px;
		height: calc(100vh - 100px);
		width: 100%;
	}
}

/* Responsive viewport preview */
#esb-ve-viewport {
	transition: max-width 0.3s ease, box-shadow 0.3s ease;
	margin: 0 auto;
}

.esb-ve-viewport--desktop {
	max-width: 100%;
}

.esb-ve-viewport--tablet {
	max-width: 768px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 12px 48px rgba(0, 0, 0, 0.12);
}

.esb-ve-viewport--mobile {
	max-width: 390px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 12px 48px rgba(0, 0, 0, 0.12);
}

.esb-ve-responsive {
	display: flex;
	gap: 0.15rem;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 8px;
	padding: 0.15rem;
}

.esb-ve-device.is-active {
	background: rgba(255, 255, 255, 0.25) !important;
}

/* Rich text toolbar */
.esb-ve-rte-toolbar {
	position: absolute;
	z-index: 100002;
	display: flex;
	gap: 0.15rem;
	padding: 0.35rem;
	background: #1e1b4b;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.esb-ve-rte-toolbar button {
	background: rgba(255, 255, 255, 0.12);
	border: 0;
	color: #fff;
	width: 32px;
	height: 32px;
	border-radius: 6px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 0.85rem;
}

.esb-ve-rte-toolbar button:hover {
	background: rgba(255, 255, 255, 0.25);
}

.esb-ve-rte-toolbar .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	color: #fff;
}

[contenteditable="true"].esb-richtext ul,
.esb-ve-rte-toolbar + * {
	margin: 0;
}

/* Region editing (header/footer) */
.esb-ve-region {
	position: relative;
}

.esb-ve-region-bar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.25rem 0.75rem;
	background: rgba(124, 58, 237, 0.92);
	color: #fff;
	font-size: 0.75rem;
	opacity: 0;
	transition: opacity 0.15s;
	pointer-events: none;
}

.esb-ve-region:hover .esb-ve-region-bar {
	opacity: 1;
	pointer-events: auto;
}

.esb-ve-logo-wrap {
	position: relative;
	display: inline-block;
}

.esb-ve-change-logo {
	position: absolute;
	bottom: -2rem;
	left: 0;
	white-space: nowrap;
	padding: 0.35rem 0.65rem;
	font-size: 0.75rem;
	background: #fff;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	opacity: 0;
	transition: opacity 0.15s;
}

.esb-ve-logo-wrap:hover .esb-ve-change-logo {
	opacity: 1;
}

/* Settings tabs */
.esb-ve-panel__tabs {
	display: flex;
	border-bottom: 1px solid #e5e7eb;
}

.esb-ve-tab {
	flex: 1;
	padding: 0.65rem;
	border: 0;
	background: #f9fafb;
	cursor: pointer;
	font-weight: 600;
	font-size: 0.8rem;
}

.esb-ve-tab.is-active {
	background: #fff;
	color: #7c3aed;
	box-shadow: inset 0 -2px 0 #7c3aed;
}

.esb-ve-sort-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.esb-ve-sort-list li {
	padding: 0.65rem 0.75rem;
	margin-bottom: 0.35rem;
	background: #f3f4f6;
	border-radius: 8px;
	cursor: grab;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.esb-ve-sort-list .dashicons {
	color: #9ca3af;
}

.esb-ve-panel--header,
.esb-ve-panel--footer {
	top: 56px;
}

/* Tour overlay */
.esb-ve-tour {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	z-index: 100000;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 2rem;
}

.esb-ve-tour__box {
	background: #fff;
	border-radius: 12px;
	padding: 1.25rem 1.5rem;
	max-width: 420px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.esb-ve-tour__box p {
	margin: 0 0 1rem;
	font-size: 1rem;
	line-height: 1.5;
}

.esb-ve-tour-skip {
	margin-left: 0.5rem;
	background: transparent;
	border: 0;
	color: #6b7280;
	cursor: pointer;
}

/* Toast notifications */
.esb-ve-toast {
	position: fixed;
	bottom: 1.5rem;
	right: 1.5rem;
	padding: 0.75rem 1.25rem;
	border-radius: 8px;
	background: #1f2937;
	color: #fff;
	font-weight: 600;
	font-size: 0.9rem;
	z-index: 100001;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.25s, transform 0.25s;
}

.esb-ve-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.esb-ve-toast--success { background: #059669; }
.esb-ve-toast--error { background: #dc2626; }
.esb-ve-toast--info { background: #2563eb; }

/* AI write button */
.esb-ve-field-wrap {
	position: relative;
}

.esb-ve-ai-write {
	display: inline-block;
	margin-top: 0.35rem;
	padding: 0.25rem 0.6rem;
	font-size: 0.75rem;
	border: 1px solid #c4b5fd;
	background: #f5f3ff;
	color: #6d28d9;
	border-radius: 6px;
	cursor: pointer;
}

.esb-ve-ai-write:hover {
	background: #ede9fe;
}

.esb-ve-history {
	display: flex;
	gap: 0.25rem;
	margin-right: 0.5rem;
}

.esb-ve-library-heading {
	grid-column: 1 / -1;
	font-weight: 700;
	margin: 0.5rem 0 0;
	color: #6b7280;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.esb-ve-revision-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.75rem;
	margin-bottom: 0.5rem;
	background: #f9fafb;
	border-radius: 8px;
}

.esb-ve-suggest-alt {
	position: absolute;
	bottom: 0.35rem;
	left: 0.35rem;
	padding: 0.2rem 0.5rem;
	font-size: 0.7rem;
	border: 0;
	border-radius: 4px;
	background: rgba(255,255,255,0.95);
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s;
}
.esb-editable-image:hover .esb-ve-suggest-alt { opacity: 1; }

.esb-ve-ai-group {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	margin-top: 0.35rem;
}

.esb-ve-ai-group button {
	padding: 0.15rem 0.45rem;
	font-size: 0.7rem;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	background: #fff;
	cursor: pointer;
}

.esb-ve-library-heading {
	grid-column: 1 / -1;
	font-weight: 600;
	margin: 0.75rem 0 0.25rem;
}
