/**
 * Enhanced Editor Styles for Modular Blocks
 * Improves the editing experience in Gutenberg
 */

/* ============================================
	BLOCK WRAPPER ENHANCEMENTS
	============================================ */

/* Main block container - Two column layout */
.wp-block[data-type^="modular-blocks/"] {
	max-width: 100% !important;
}

/* Main content controls wrapper - Two column layout (default) */
.mbcore-content-controls {
	display: grid;
	grid-template-columns: 400px 1fr;
	gap: 24px;
	background: transparent;
	border: none;
	padding: 0;
	margin: 60px 0 20px 0;
	position: relative;
}

/* Layout Toggle Buttons */
.mbcore-layout-toggle {
	position: absolute;
	top: -50px;
	right: 0;
	display: flex;
	gap: 8px;
	background: #ffffff;
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	padding: 4px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.mbcore-layout-toggle button {
	padding: 6px 12px;
	border: none;
	background: transparent;
	border-radius: 4px;
	cursor: pointer;
	font-size: 12px;
	font-weight: 600;
	color: #757575;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	gap: 6px;
}

.mbcore-layout-toggle button:hover {
	background: #f0f0f1;
	color: #1e1e1e;
}

.mbcore-layout-toggle button.active {
	background: linear-gradient(135deg, #5b6cf2 0%, #4f5bd5 100%);
	color: #ffffff;
	box-shadow: 0 2px 8px rgba(91, 108, 242, 0.3);
}

.mbcore-layout-toggle button::before {
	font-size: 14px;
}

.mbcore-layout-toggle button[data-layout="side-by-side"]::before {
	content: "⚏";
}

.mbcore-layout-toggle button[data-layout="stacked"]::before {
	content: "☰";
}

/* Stacked Layout Mode */
.mbcore-content-controls.layout-stacked {
	grid-template-columns: 1fr;
	max-width: 800px;
	margin-left: auto;
	margin-right: auto;
}

.mbcore-content-controls.layout-stacked .mbcore-controls-section {
	position: relative;
	top: 0;
	max-height: none;
}

.mbcore-content-controls.layout-stacked .mbcore-preview-wrapper {
	min-height: 500px;
}

/* Controls section - Left column */
.mbcore-controls-section {
	background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
	border: 1px solid #e0e0e0;
	border-radius: 16px;
	padding: 28px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
	transition: all 0.3s ease;
	position: sticky;
	top: 80px;
	max-height: calc(100vh - 120px);
	overflow-y: auto;
	overflow-x: hidden;
}

.mbcore-controls-section:hover {
	border-color: #5b6cf2;
	box-shadow: 0 6px 20px rgba(91, 108, 242, 0.12);
	transform: translateY(-2px);
}

/* Custom scrollbar for controls section */
.mbcore-controls-section::-webkit-scrollbar {
	width: 8px;
}

.mbcore-controls-section::-webkit-scrollbar-track {
	background: #f0f0f1;
	border-radius: 4px;
}

.mbcore-controls-section::-webkit-scrollbar-thumb {
	background: linear-gradient(135deg, #5b6cf2 0%, #4f5bd5 100%);
	border-radius: 4px;
}

.mbcore-controls-section::-webkit-scrollbar-thumb:hover {
	background: linear-gradient(135deg, #4f5bd5 0%, #3d4ab8 100%);
}

/* Controls header with tabs */
.mbcore-controls-header {
	margin-bottom: 0;
	padding: 0;
	border-bottom: none;
	position: relative;
}

/* Wrapper for tabs with indicators */
.mbcore-controls-header::before,
.mbcore-controls-header::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	width: 60px;
	pointer-events: none;
	z-index: 1;
	transition: opacity 0.3s ease;
}

.mbcore-controls-header::before {
	left: 0;
	background: linear-gradient(to right, rgba(248, 249, 250, 1) 0%, rgba(248, 249, 250, 0) 100%);
	opacity: 0;
}

.mbcore-controls-header::after {
	right: 0;
	background: linear-gradient(to left, rgba(248, 249, 250, 1) 0%, rgba(248, 249, 250, 0) 100%);
	opacity: 1;
}

.mbcore-controls-header.has-scroll-left::before {
	opacity: 1;
}

.mbcore-controls-header.at-scroll-end::after {
	opacity: 0;
}

/* Tabs navigation */
.mbcore-controls-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 20px;
	border-bottom: 2px solid #f0f0f1;
	padding: 0 20px 16px 20px;
	overflow-x: auto;
	overflow-y: hidden;
	flex-wrap: nowrap;
	scrollbar-width: thin;
	scrollbar-color: #5b6cf2 #f0f0f1;
	position: relative;
}



.mbcore-controls-tabs::-webkit-scrollbar {
	display: none;
}

.mbcore-controls-tabs {
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.mbcore-controls-tab {
	padding: 8px 16px;
	border: none;
	background: transparent;
	border-radius: 8px 8px 0 0;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	color: #757575;
	transition: all 0.2s ease;
	position: relative;
	display: flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	flex-shrink: 0;
	z-index: 2;
}

.mbcore-controls-tab:hover {
	background: #f8f9fa;
	color: #1e1e1e;
}

.mbcore-controls-tab.active {
	background: linear-gradient(135deg, #5b6cf2 0%, #4f5bd5 100%);
	color: #ffffff;
	box-shadow: 0 2px 8px rgba(91, 108, 242, 0.3);
}

.mbcore-controls-tab.active::after {
	content: '';
	position: absolute;
	bottom: -10px;
	left: 50%;
	transform: translateX(-50%);
	width: 6px;
	height: 6px;
	background: #5b6cf2;
	border-radius: 50%;
}

/* Tab indicator dot */
.mbcore-controls-tab::before {
	content: '';
	width: 6px;
	height: 6px;
	background: currentColor;
	border-radius: 50%;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.mbcore-controls-tab.active::before {
	opacity: 1;
}

/* Tab content */
.mbcore-tab-content {
	display: none;
}

.mbcore-tab-content.active {
	display: block;
}

.mbcore-controls-title {
	font-size: 14px;
	font-weight: 700;
	color: #1e1e1e;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
}

.mbcore-controls-title::before {
	content: "⚙️";
	font-size: 16px;
}

/* ============================================
	CONTROL SECTIONS
	============================================ */

/* Control groups with labels */
.mbcore-control-group {
	margin-bottom: 20px;
	padding-bottom: 20px;
	border-bottom: 1px solid #f0f0f1;
}

.mbcore-control-group:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.mbcore-control-group-label {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	color: #757575;
	margin-bottom: 12px;
	letter-spacing: 0.5px;
}

/* ============================================
	ENHANCED INPUT CONTROLS - Light Theme
	============================================ */

/* Text inputs - Light and clean */
.mbcore-content-controls .components-text-control__input,
.mbcore-content-controls .components-textarea-control__input,
.mbcore-controls-section .components-text-control__input,
.mbcore-controls-section .components-textarea-control__input {
	border: 2px solid #e8eaed;
	border-radius: 8px;
	padding: 12px 16px;
	font-size: 14px;
	transition: all 0.3s ease;
	background: #ffffff;
	color: #1e1e1e;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.mbcore-content-controls .components-text-control__input:hover,
.mbcore-content-controls .components-textarea-control__input:hover,
.mbcore-controls-section .components-text-control__input:hover,
.mbcore-controls-section .components-textarea-control__input:hover {
	border-color: #c8cef5;
	box-shadow: 0 2px 6px rgba(91, 108, 242, 0.08);
}

.mbcore-content-controls .components-text-control__input:focus,
.mbcore-content-controls .components-textarea-control__input:focus,
.mbcore-controls-section .components-text-control__input:focus,
.mbcore-controls-section .components-textarea-control__input:focus {
	background: #ffffff;
	border-color: #5b6cf2;
	box-shadow: 0 0 0 3px rgba(91, 108, 242, 0.1), 0 2px 8px rgba(91, 108, 242, 0.15);
	outline: none;
	transform: translateY(-1px);
}

/* Labels - Clear and readable */
.mbcore-content-controls .components-base-control__label,
.mbcore-controls-section .components-base-control__label {
	font-weight: 700;
	font-size: 13px;
	color: #1e1e1e;
	margin-bottom: 10px;
	display: block;
	letter-spacing: 0.3px;
}

/* Help text */
.mbcore-content-controls .components-base-control__help,
.mbcore-controls-section .components-base-control__help {
	font-size: 12px;
	color: #757575;
	margin-top: 8px;
	font-style: normal;
	line-height: 1.5;
}

/* Individual control spacing */
.mbcore-controls-section .components-base-control {
	margin-bottom: 24px;
	padding: 16px;
	background: rgba(255, 255, 255, 0.6);
	border-radius: 10px;
	transition: all 0.2s ease;
}

.mbcore-controls-section .components-base-control:hover {
	background: rgba(255, 255, 255, 0.9);
	box-shadow: 0 2px 8px rgba(91, 108, 242, 0.06);
}

.mbcore-controls-section .components-base-control:last-child {
	margin-bottom: 0;
}

/* ============================================
	RANGE CONTROLS (SLIDERS)
	============================================ */

.mbcore-content-controls .components-range-control__wrapper {
	background: #f8f9fa;
	padding: 12px;
	border-radius: 6px;
	margin-top: 8px;
}

.mbcore-content-controls .components-range-control__slider {
	background: linear-gradient(to right, #2271b1 0%, #2271b1 50%, #ddd 50%, #ddd 100%);
	height: 4px;
	border-radius: 2px;
}

.mbcore-content-controls .components-range-control__thumb {
	background: #2271b1;
	border: 2px solid #ffffff;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
	width: 16px;
	height: 16px;
}

.mbcore-content-controls .components-range-control__number {
	background: #ffffff;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 4px 8px;
	min-width: 50px;
	text-align: center;
}

/* ============================================
	TOGGLE CONTROLS
	============================================ */

.mbcore-content-controls .components-toggle-control {
	background: #f8f9fa;
	padding: 12px;
	border-radius: 6px;
	margin-bottom: 12px;
}

.mbcore-content-controls .components-toggle-control .components-base-control__field {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.mbcore-content-controls .components-form-toggle {
	margin: 0;
}

.mbcore-content-controls .components-form-toggle.is-checked .components-form-toggle__track {
	background-color: #2271b1;
}

/* ============================================
	SELECT & RADIO CONTROLS
	============================================ */

.mbcore-content-controls .components-select-control__input {
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 8px 32px 8px 12px;
	font-size: 14px;
	background: #fafafa url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="5"><path fill="%23555" d="M0 0l5 5 5-5z"/></svg>') no-repeat right 12px center;
	appearance: none;
}

.mbcore-content-controls .components-select-control__input:focus {
	background-color: #ffffff;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

.mbcore-content-controls .components-radio-control__option {
	background: #f8f9fa;
	padding: 10px 12px;
	border-radius: 4px;
	margin-bottom: 8px;
	transition: all 0.2s ease;
}

.mbcore-content-controls .components-radio-control__option:hover {
	background: #e8eaed;
}

.mbcore-content-controls .components-radio-control__input:checked+.components-radio-control__label {
	font-weight: 600;
	color: #2271b1;
}

/* ============================================
	COLOR PICKER
	============================================ */

.mbcore-content-controls .components-color-palette {
	padding: 12px;
	background: #f8f9fa;
	border-radius: 6px;
}

.mbcore-content-controls .components-color-palette__item {
	border-radius: 4px;
	transition: transform 0.2s ease;
}

.mbcore-content-controls .components-color-palette__item:hover {
	transform: scale(1.1);
}

.mbcore-content-controls .components-color-palette__custom-color {
	border: 2px dashed #ddd;
	border-radius: 4px;
}

/* ============================================
	PREVIEW SECTION - Right Column
	============================================ */

.mbcore-preview-wrapper {
	background: #f8f9fa;
	border: 1px solid #e0e0e0;
	border-radius: 12px;
	padding: 0;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
	display: flex;
	flex-direction: column;
	min-height: 400px;
}

.mbcore-preview-label {
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	color: #ffffff;
	background: linear-gradient(135deg, #5b6cf2 0%, #4f5bd5 100%);
	padding: 16px 20px;
	letter-spacing: 0.5px;
	display: flex;
	align-items: center;
	gap: 8px;
	border-bottom: 3px solid #4f5bd5;
}

.mbcore-preview-label::before {
	content: "👁";
	font-size: 16px;
}

.mbcore-preview-content {
	background: #ffffff;
	padding: 24px;
	flex: 1;
	overflow: auto;
}

/* Block Details Section */
.mbcore-block-details {
	background: #f8f9fa;
	border: 1px solid #e0e0e0;
	border-radius: 12px;
	padding: 0;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
	margin-top: 24px;
}

.mbcore-block-details-header {
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	color: #ffffff;
	background: linear-gradient(135deg, #5b6cf2 0%, #4f5bd5 100%);
	padding: 16px 20px;
	letter-spacing: 0.5px;
	border-bottom: 3px solid #4f5bd5;
}

.mbcore-block-details-content {
	background: #ffffff;
	padding: 20px;
}

.detail-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 0;
	border-bottom: 1px solid #f0f0f1;
}

.detail-item:last-child {
	border-bottom: none;
}

.detail-label {
	font-weight: 600;
	font-size: 13px;
	color: #1e1e1e;
}

.detail-value {
	font-size: 13px;
	color: #757575;
}

.detail-value.detail-code {
	font-family: 'Courier New', monospace;
	background: #f0f0f1;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 12px;
	color: #5b6cf2;
}

.detail-value.detail-number {
	background: linear-gradient(135deg, #5b6cf2 0%, #4f5bd5 100%);
	color: #ffffff;
	padding: 4px 12px;
	border-radius: 12px;
	font-weight: 700;
	font-size: 12px;
}


/* Loading state */
.mbcore-preview-content.is-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	color: #757575;
	font-size: 14px;
}

.mbcore-preview-content.is-loading::before {
	content: "⏳";
	margin-right: 8px;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}

/* Responsive - Stack on smaller screens */
@media (max-width: 1280px) {
	.mbcore-content-controls {
		grid-template-columns: 1fr;
	}

	.mbcore-controls-section {
		position: relative;
		top: 0;
		max-height: none;
	}

	.mbcore-preview-wrapper {
		min-height: 300px;
	}
}

/* ============================================
	INSPECTOR (SIDEBAR) ENHANCEMENTS
	============================================ */

.components-panel__body.is-opened .mbcore-inspector-control {
	padding: 12px 0;
	border-bottom: 1px solid #f0f0f1;
}

.components-panel__body.is-opened .mbcore-inspector-control:last-child {
	border-bottom: none;
}

/* ============================================
	RESPONSIVE HELPERS
	============================================ */

.mbcore-responsive-preview {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.mbcore-responsive-preview button {
	flex: 1;
	padding: 6px 12px;
	border: 1px solid #ddd;
	background: #ffffff;
	border-radius: 4px;
	font-size: 12px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.mbcore-responsive-preview button:hover {
	background: #f8f9fa;
	border-color: #2271b1;
}

.mbcore-responsive-preview button.is-active {
	background: #2271b1;
	color: #ffffff;
	border-color: #2271b1;
}

/* ============================================
	EMPTY STATE
	============================================ */

.mbcore-empty-state {
	text-align: center;
	padding: 40px 20px;
	color: #757575;
}

.mbcore-empty-state-icon {
	font-size: 48px;
	margin-bottom: 16px;
	opacity: 0.5;
}

.mbcore-empty-state-title {
	font-size: 16px;
	font-weight: 600;
	color: #1e1e1e;
	margin-bottom: 8px;
}

.mbcore-empty-state-description {
	font-size: 13px;
	color: #757575;
}

/* ============================================
	ANIMATIONS
	============================================ */

.mbcore-content-controls>* {
	animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ============================================
	ACCESSIBILITY ENHANCEMENTS
	============================================ */

.mbcore-content-controls *:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
	.mbcore-content-controls {
		border-width: 2px;
	}

	.mbcore-content-controls .components-text-control__input,
	.mbcore-content-controls .components-select-control__input {
		border-width: 2px;
	}
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

	.mbcore-content-controls,
	.mbcore-content-controls *,
	.mbcore-preview-content.is-loading::before {
		animation: none !important;
		transition: none !important;
	}
}

/* ============================================
	MEDIA CONTROL STYLES
	============================================ */
.mbcore-media-control {
	background: transparent;
}

.mbcore-media-upload-wrapper {
	margin-top: 10px;
}

.mbcore-media-preview img {
	border: 2px solid #e0e0e0;
	transition: all 0.2s ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
	display: block;
}

.mbcore-media-preview img:hover {
	border-color: #5b6cf2;
}

.mbcore-media-actions {
	margin-bottom: 15px;
}