/**
 * Page section builder – Shop Admin UI + frontend section spacing.
 */

/* ── Builder shell & preview ── */

.csb-page-builder-shell {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
	gap: 1rem;
	align-items: start;
}

.csb-page-builder-head-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.csb-page-builder-tabs {
	align-items: flex-end;
	gap: 0.75rem 1.5rem;
}

.csb-page-builder-tab-group {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0;
}

.csb-page-builder-tab-label {
	display: block;
	width: 100%;
	margin: 0 0 0.15rem 0.15rem;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--csb-muted, #6b7280);
}

.csb-content-page-editor {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	margin-bottom: 1.25rem;
}

.csb-content-page-title .csb-input,
.csb-content-page-body,
.csb-faq-editor {
	max-width: 100%;
}

.csb-page-builder-form .wp-editor-wrap,
.csb-section-field--editor .wp-editor-wrap {
	display: block;
	max-width: 100%;
}

.csb-page-builder-form .wp-editor-container,
.csb-section-field--editor .wp-editor-container {
	border: 1px solid var(--csb-border, #e5e7eb);
	border-radius: 0.5rem;
	overflow: visible;
}

.csb-page-builder-form .wp-editor-container textarea,
.csb-section-field--editor .wp-editor-container textarea {
	min-height: 220px;
}

.csb-faq-editor-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.85rem;
}

.csb-faq-items {
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
}

.csb-faq-item-editor {
	border: 1px solid var(--csb-border, #e5e7eb);
	border-radius: 10px;
	padding: 0.9rem 1rem 1rem;
	background: color-mix(in srgb, var(--csb-bg, #f9fafb) 70%, #fff);
}

.csb-faq-item-editor-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.csb-faq-item-actions {
	display: flex;
	gap: 0.35rem;
}

.csb-faq-answer {
	margin-top: 0.75rem;
}

.csb-page-section-body .csb-section-field--editor {
	grid-column: 1 / -1;
}

body.csb-shop-admin .csb-page-builder-form .mce-toolbar .mce-btn button,
body.csb-shop-admin .csb-page-builder-form .wp-editor-tools {
	box-sizing: border-box;
}

body.csb-shop-admin .csb-page-builder-form .wp-media-buttons .button {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	height: auto;
	padding: 0.35rem 0.7rem;
	font-size: 0.8125rem;
}

.csb-page-builder-reset-form {
	margin: 0;
}

.csb-page-builder-preview-wrap {
	position: sticky;
	top: 1rem;
}

.csb-page-builder-preview {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	min-height: 420px;
}

.csb-preview-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5rem;
}

.csb-preview-url-line {
	margin: 0.15rem 0 0;
	font-size: 0.75rem;
	font-weight: 400;
}

.csb-preview-url-line a {
	color: var(--csb-muted, #6b7280);
	text-decoration: none;
	word-break: break-all;
}

.csb-preview-url-line a:hover {
	color: var(--csb-primary, #2563eb);
	text-decoration: underline;
}

.csb-preview-toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	align-items: center;
}

.csb-preview-device-toggle {
	display: inline-flex;
	gap: 0.25rem;
}

.csb-preview-device-toggle .csb-btn.is-active {
	background: var(--csb-primary, #2563eb);
	border-color: var(--csb-primary, #2563eb);
	color: #fff;
}

.csb-preview-hint {
	margin: 0;
	font-size: 0.8125rem;
}

.csb-preview-frame-wrap {
	flex: 1;
	background: #f3f4f6;
	border: 1px solid var(--csb-border, #e5e7eb);
	border-radius: 10px;
	padding: 0.75rem;
	min-height: 360px;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	overflow: hidden;
}

.csb-preview-frame-wrap iframe {
	width: 100%;
	height: 520px;
	border: 0;
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
	transition: width 0.25s ease;
}

.csb-preview-frame-wrap[data-device="mobile"] iframe {
	width: 375px;
	max-width: 100%;
	height: 640px;
}

.csb-page-section.is-dragging {
	opacity: 0.55;
	border-color: var(--csb-primary, #2563eb);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--csb-primary, #2563eb) 25%, transparent);
}

.csb-page-section-handle {
	color: var(--csb-muted, #999);
	cursor: grab;
	user-select: none;
	font-size: 1.1rem;
	line-height: 1;
	padding: 0 0.15rem;
}

.csb-page-section-handle:active {
	cursor: grabbing;
}

.csb-section-i18n .csb-i18n-field-pair {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 0.75rem 1rem;
	align-items: start;
}

.csb-section-i18n-col {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	min-width: 0;
	margin: 0;
}

.csb-section-i18n-lang {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: var(--csb-muted, #6b6470);
}

.csb-section-i18n .csb-i18n-translate-btns {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
}

.csb-page-section-body .csb-section-field--full {
	grid-column: 1 / -1;
}

/* ── Styled selects (page builder) ── */

.csb-field-select {
	position: relative;
	display: block;
	width: 100%;
	max-width: 420px;
}

.csb-field-select--grow {
	max-width: none;
	flex: 1;
	min-width: 220px;
}

.csb-field-select .csb-select-styled,
.csb-field-select select {
	width: 100%;
	appearance: none;
	-webkit-appearance: none;
	padding: 0.55rem 2.25rem 0.55rem 0.75rem;
	font-size: 0.875rem;
	line-height: 1.35;
	border: 1px solid var(--csb-border, #d1d5db);
	border-radius: 0.5rem;
	background-color: var(--csb-white, #fff);
	color: var(--csb-heading, #111827);
	font-family: inherit;
	cursor: pointer;
	transition: border-color 0.2s, box-shadow 0.2s;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.65rem center;
	background-size: 16px;
}

.csb-field-select .csb-select-styled:hover,
.csb-field-select select:hover {
	border-color: color-mix(in srgb, var(--csb-primary, #2563eb) 35%, var(--csb-border, #d1d5db));
}

.csb-field-select .csb-select-styled:focus,
.csb-field-select select:focus {
	outline: none;
	border-color: var(--csb-primary, #2563eb);
	box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--csb-primary, #2563eb) 18%, transparent);
}

.csb-page-builder-add-row .csb-field-select {
	margin: 0;
}

/* ── Expertise cards editor ── */

.csb-expertise-cards-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.csb-expertise-cards-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.csb-expertise-card-editor {
	border: 1px solid var(--csb-border, #e5e7eb);
	border-radius: 8px;
	padding: 0.85rem;
	background: color-mix(in srgb, var(--csb-bg, #f9fafb) 70%, #fff);
}

.csb-expertise-card-editor-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.75rem;
}

.csb-expertise-card-editor-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 0.75rem;
}

.csb-expertise-card-editor-text {
	grid-column: 1 / -1;
}

.csb-contact-places-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.35rem;
}

.csb-section-field--contact-places .csb-field-hint {
	margin: 0 0 0.75rem;
}

.csb-contact-places-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.csb-contact-place-editor {
	border: 1px solid var(--csb-border, #e5e7eb);
	border-radius: 8px;
	padding: 0.85rem;
	background: color-mix(in srgb, var(--csb-bg, #f9fafb) 70%, #fff);
}

.csb-contact-place-editor-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}

.csb-contact-place-actions {
	display: flex;
	gap: 0.35rem;
}

.csb-contact-place-editor-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 0.75rem;
}

.csb-contact-place-map {
	grid-column: 1 / -1;
}

/* ── Builder list (existing) ── */

.csb-page-builder-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
}

.csb-page-builder-list {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	margin-bottom: 1.5rem;
}

.csb-page-section {
	border: 1px solid var(--csb-border, #e5e7eb);
	border-radius: 10px;
	background: #fff;
	overflow: hidden;
}

.csb-page-section-summary {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.85rem 1rem;
	cursor: pointer;
	list-style: none;
	font-weight: 600;
}

.csb-page-section-summary::-webkit-details-marker {
	display: none;
}

.csb-page-section-title {
	flex: 1;
	min-width: 0;
}

.csb-page-section-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-size: 0.75rem;
	font-weight: 700;
	margin: 0;
}

.csb-page-section-actions {
	display: flex;
	gap: 0.35rem;
}

.csb-page-section-actions .csb-btn {
	min-width: 2rem;
	padding: 0.25rem 0.5rem;
}

.csb-page-section-body {
	padding: 1rem;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: 1.75rem;
	row-gap: 1.35rem;
	align-items: start;
	border-top: 1px solid var(--csb-border, #eee);
}

.csb-page-section-body > input[type="hidden"] {
	display: none;
}

.csb-page-section-body .csb-section-field {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.4rem;
	min-width: 0;
	margin: 0;
}

.csb-page-section-body .csb-section-field > .csb-label,
.csb-page-section-body .csb-section-field > label {
	margin: 0;
	line-height: 1.3;
}

.csb-page-section-body .csb-section-field .csb-field-hint {
	margin: 0;
}

.csb-page-section-body .csb-section-field input[type="text"],
.csb-page-section-body .csb-section-field input[type="number"],
.csb-page-section-body .csb-section-field input[type="url"],
.csb-page-section-body .csb-section-field select,
.csb-page-section-body .csb-section-field textarea,
.csb-page-section-body .csb-section-field .csb-input,
.csb-page-section-body .csb-section-field .csb-field-select {
	width: 100%;
	max-width: none;
	box-sizing: border-box;
}

.csb-page-section-body .csb-section-field--textarea textarea,
.csb-page-section-body .csb-section-field .csb-textarea {
	min-height: 5.5rem;
	resize: vertical;
}

.csb-page-section-body .csb-section-field--image {
	grid-column: 1 / -1;
}

.csb-section-image-preview {
	margin-top: 0.5rem;
}

.csb-section-image-preview img {
	max-width: 160px;
	max-height: 100px;
	display: block;
	border-radius: 6px;
}

.csb-page-builder-add-row {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
}

@media (max-width: 1100px) {
	.csb-page-builder-shell {
		grid-template-columns: 1fr;
	}

	.csb-page-builder-preview-wrap {
		position: static;
	}
}

@media (max-width: 640px) {
	.csb-page-section-body {
		grid-template-columns: 1fr;
	}
}

/* ── Frontend section spacing ── */

.csb-section-spacing--compact {
	padding-top: 1rem;
	padding-bottom: 1rem;
}

.csb-section-spacing--normal {
	padding-top: 2rem;
	padding-bottom: 2rem;
}

.csb-section-spacing--large {
	padding-top: 3.5rem;
	padding-bottom: 3.5rem;
}

/* Uniform category grid (UX Editor) – overrides bento mosaic */

.csb-bento-grid--uniform {
	grid-template-columns: repeat(var(--csb-bento-cols, 3), minmax(0, 1fr));
	grid-auto-rows: auto;
	gap: clamp(0.65rem, 1.2vw, 1rem);
}

.csb-bento-grid--uniform .csb-bento-item,
.csb-bento-grid--uniform .csb-bento-item:nth-child(n) {
	grid-column: span 1 !important;
	grid-row: span 1 !important;
}

.csb-bento-grid--uniform .csb-bento-item-media,
.csb-bento-grid--uniform .csb-bento-item:nth-child(n) .csb-bento-item-media {
	min-height: 0 !important;
	max-height: none;
	aspect-ratio: var(--csb-featured-ratio, 3 / 4);
}

.csb-bento-grid--size-thumbnail.csb-bento-grid--uniform .csb-bento-item-media,
.csb-bento-grid--size-medium.csb-bento-grid--uniform .csb-bento-item-media,
.csb-bento-grid--size-large.csb-bento-grid--uniform .csb-bento-item-media {
	aspect-ratio: var(--csb-featured-ratio, 3 / 4);
	max-height: none;
}

.csb-bento-grid--uniform .csb-bento-item-media img,
.csb-bento-grid--uniform .csb-bento-item-media .csb-home-product-img {
	height: 100%;
	object-fit: cover;
}

.csb-bento-grid:not(.csb-bento-grid--uniform).csb-bento-grid--cols-2 .csb-bento-item {
	grid-column: span 6 !important;
	grid-row: span 1 !important;
}

.csb-bento-grid:not(.csb-bento-grid--uniform).csb-bento-grid--cols-3 .csb-bento-item {
	grid-column: span 4 !important;
	grid-row: span 1 !important;
}

.csb-bento-grid:not(.csb-bento-grid--uniform).csb-bento-grid--cols-4 .csb-bento-item {
	grid-column: span 3 !important;
	grid-row: span 1 !important;
}

@media (max-width: 767px) {
	.csb-bento-grid--uniform {
		--csb-bento-cols: 2;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.75rem;
	}

	.csb-bento-grid--size-thumbnail.csb-bento-grid--uniform .csb-bento-item-media {
		aspect-ratio: var(--csb-featured-ratio, 3 / 4);
		max-height: none;
		min-height: 0;
	}

	.csb-bento-grid--size-medium.csb-bento-grid--uniform .csb-bento-item-media,
	.csb-bento-grid--size-large.csb-bento-grid--uniform .csb-bento-item-media {
		max-height: none;
		min-height: 200px;
	}

	.csb-bento-grid.csb-home-products-bento .csb-bento-item,
	.csb-bento-grid.csb-home-products-bento .csb-bento-item:nth-child(n) {
		grid-column: span 1 !important;
		grid-row: span 1 !important;
	}

	.csb-home-category-bento-header {
		margin-bottom: 0.9rem;
		align-items: flex-start;
		gap: 0.4rem 0.75rem;
	}

	.csb-home-category-bento-title {
		font-size: 1.2rem;
	}

	.csb-home-category-bento .csb-bento-item {
		min-height: 0 !important;
	}

	.csb-home-category-bento .csb-bento-item-link {
		display: flex;
		flex-direction: column;
		height: 100%;
	}

	.csb-home-category-bento .csb-bento-item-media,
	.csb-home-category-bento .csb-bento-item-media:nth-child(n),
	.csb-home-category-bento .csb-bento-grid--uniform .csb-bento-item-media,
	.csb-home-category-bento .csb-bento-grid--size-thumbnail.csb-bento-grid--uniform .csb-bento-item-media,
	.csb-home-category-bento .csb-bento-grid--size-medium.csb-bento-grid--uniform .csb-bento-item-media,
	.csb-home-category-bento .csb-bento-grid--size-large.csb-bento-grid--uniform .csb-bento-item-media {
		display: flex;
		flex: 1;
		flex-direction: column;
		aspect-ratio: auto;
		height: auto;
		max-height: none;
		min-height: 0 !important;
	}

	.csb-home-category-bento .csb-bento-item-media img,
	.csb-home-category-bento .csb-bento-item-media .csb-home-product-img {
		aspect-ratio: var(--csb-featured-ratio, 3 / 4);
		width: 100%;
		height: auto;
		flex: none;
		object-fit: cover;
	}

	.csb-home-category-bento .csb-bento-item-overlay {
		position: static;
		inset: auto;
		display: flex;
		flex: 1;
		flex-direction: column;
		align-items: flex-start;
		justify-content: flex-start;
		gap: 0.2rem;
		padding: 0.55rem 0.65rem 0.7rem;
		background: var(--csb-card-bg, #fff);
		text-align: left;
	}

	.csb-home-category-bento .csb-bento-item-title {
		margin: 0;
		width: 100%;
		color: var(--csb-text, #111);
		font-size: 0.8125rem;
		font-weight: 600;
		line-height: 1.3;
		text-align: left;
		display: block;
		-webkit-line-clamp: unset;
		overflow: visible;
	}

	.csb-home-category-bento .csb-bento-item-meta {
		width: 100%;
		margin: auto 0 0;
		color: var(--csb-primary, #dd2f6e);
		font-size: 0.75rem;
		font-weight: 700;
		line-height: 1.3;
		text-align: left;
		white-space: normal;
	}

	.csb-home-category-bento .csb-bento-item-meta .csb-price-from,
	.csb-home-category-bento .csb-bento-item-meta .csb-price-to {
		display: block;
	}

	.csb-home-category-bento-link {
		font-size: 0.8125rem;
	}

	.csb-section-spacing--compact {
		padding-top: 1.35rem;
		padding-bottom: 1.35rem;
	}
}

.csb-bento-grid.csb-home-products-bento .csb-bento-item-media {
	aspect-ratio: var(--csb-featured-ratio, 3 / 4);
	max-height: none !important;
	min-height: 0 !important;
	height: auto !important;
}

.csb-bento-grid--size-thumbnail .csb-bento-item-media {
	min-height: 90px;
	max-height: 140px;
}

.csb-bento-grid--size-medium .csb-bento-item-media {
	min-height: 120px;
	max-height: 220px;
}

.csb-bento-grid--size-large .csb-bento-item-media {
	min-height: 160px;
	max-height: none;
}

.csb-page-spacer--sm { height: 1.5rem; }
.csb-page-spacer--md { height: 3rem; }
.csb-page-spacer--lg { height: 5rem; }
.csb-page-spacer--xl { height: 8rem; }

.csb-image-banner {
	position: relative;
	overflow: hidden;
}

.csb-image-banner--sm { min-height: 40vh; }
.csb-image-banner--md { min-height: 55vh; }
.csb-image-banner--lg { min-height: 70vh; }

.csb-image-banner-link {
	display: block;
	position: relative;
	height: 100%;
	color: inherit;
	text-decoration: none;
}

.csb-image-banner-img {
	width: 100%;
	height: 100%;
	min-height: inherit;
	object-fit: cover;
	display: block;
}

.csb-image-banner-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.35);
}

.csb-image-banner-caption {
	position: absolute;
	left: 1.5rem;
	right: 1.5rem;
	bottom: 1.5rem;
	z-index: 1;
	color: #fff;
}

.csb-image-banner-title {
	margin: 0 0 0.35rem;
	font-size: clamp(1.5rem, 3vw, 2.25rem);
	font-weight: 300;
}

.csb-image-banner-subtitle {
	margin: 0;
	font-size: 1rem;
	opacity: 0.9;
}
