/* ==========================================================================
   Camera Builder — Front-end styles
   Compatible with WoodMart theme 8.x
   Palette: black / white / gray only
   ========================================================================== */

/* --- Variables ----------------------------------------------------------- */
:root {
	--cb-black:        #111111;
	--cb-dark:         #333333;
	--cb-mid:          #666666;
	--cb-border:       #d8d8d8;
	--cb-border-light: #ebebeb;
	--cb-bg:           #f6f6f6;
	--cb-bg-row:       #ffffff;
	--cb-radius-btn:   6px;
	--cb-radius-box:   8px;
	--cb-shadow:       0 1px 8px rgba(0,0,0,0.08);
	--cb-shadow-modal: 0 8px 40px rgba(0,0,0,0.18);
	--cb-transition:   0.15s ease;
}

/* --- Wrap ---------------------------------------------------------------- */
.cb-wrap {
	font-family: inherit;
	color: var(--cb-black);
	max-width: 960px;
	margin: 0 auto 48px;
}

/* --- Top Bar ------------------------------------------------------------ */
.cb-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px;
	margin-bottom: 16px;
}

.cb-topbar__title {
	font-size: 1.35rem;
	font-weight: 700;
	margin: 0;
	line-height: 1.2;
	color: var(--cb-black);
}

.cb-topbar__actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	align-items: center;
}

/* --- Buttons — monochrome base ------------------------------------------ */
.cb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 16px;
	border: 1.5px solid var(--cb-black);
	border-radius: var(--cb-radius-btn);
	font-size: 0.82rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: background var(--cb-transition), color var(--cb-transition);
	text-decoration: none;
	white-space: nowrap;
	background: #fff;
	color: var(--cb-black);
	vertical-align: middle;
}
.cb-btn:hover:not(:disabled) {
	background: var(--cb-black);
	color: #fff;
}
.cb-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.cb-btn__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 15px;
	height: 15px;
}
.cb-btn__icon svg {
	width: 15px;
	height: 15px;
	display: block;
}

/* Top-bar action variants — all same monochrome style */
.cb-btn--cart,
.cb-btn--pdf,
.cb-btn--clear {
	background: #fff;
	border-color: var(--cb-black);
	color: var(--cb-black);
}
.cb-btn--cart:hover:not(:disabled),
.cb-btn--pdf:hover:not(:disabled),
.cb-btn--clear:hover {
	background: var(--cb-black);
	color: #fff;
}

/* Row-level Choose / Change */
.cb-btn--choose,
.cb-btn--change {
	padding: 6px 14px;
	font-size: 0.8rem;
}

/* Remove × button — small circle */
.cb-btn--remove {
	padding: 0;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	font-size: 1rem;
	line-height: 1;
	flex-shrink: 0;
}

/* --- Summary Bar -------------------------------------------------------- */
.cb-summary-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
	padding: 12px 18px;
	background: var(--cb-bg);
	border: 1px solid var(--cb-border);
	border-radius: var(--cb-radius-box);
	margin-bottom: 16px;
}

.cb-hide-empty {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 0.85rem;
	color: var(--cb-mid);
	cursor: pointer;
	user-select: none;
	margin: 0;
	line-height: 1;
}
.cb-hide-empty input[type="checkbox"] {
	width: 15px;
	height: 15px;
	cursor: pointer;
	margin: 0;
	flex-shrink: 0;
	vertical-align: middle;
}

.cb-total-box {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 1px;
}

.cb-total-price {
	font-size: 1.45rem;
	font-weight: 700;
	color: var(--cb-black);
	line-height: 1.1;
}

.cb-total-count {
	font-size: 0.78rem;
	color: var(--cb-mid);
	line-height: 1.1;
}

/* --- Notice ------------------------------------------------------------- */
.cb-notice {
	padding: 11px 16px;
	border-radius: var(--cb-radius-box);
	margin-bottom: 14px;
	font-size: 0.88rem;
	font-weight: 500;
	border: 1px solid var(--cb-border);
}
.cb-notice--success {
	background: #f0f0f0;
	color: var(--cb-black);
	border-color: var(--cb-border);
}
.cb-notice--error {
	background: #f6f6f6;
	color: var(--cb-black);
	border-color: var(--cb-black);
}
.cb-notice--info {
	background: var(--cb-bg);
	color: var(--cb-dark);
	border-color: var(--cb-border);
}

/* --- Component Rows ----------------------------------------------------- */
.cb-components {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--cb-border);
	border-radius: var(--cb-radius-box);
	overflow: hidden;
	box-shadow: var(--cb-shadow);
}

.cb-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	background: var(--cb-bg-row);
	border-bottom: 1px solid var(--cb-border-light);
	transition: background var(--cb-transition);
}
.cb-row:last-child {
	border-bottom: none;
}
.cb-row:hover {
	background: #fafafa;
}
.cb-row.cb-row--selected {
	background: #f6f6f6;
}

/* Component icon box */
.cb-row__icon {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--cb-bg);
	border: 1px solid var(--cb-border);
	border-radius: var(--cb-radius-box);
	color: var(--cb-mid);
}
.cb-row__icon svg {
	width: 22px;
	height: 22px;
}

/* Label + badge group */
.cb-row__meta {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 145px;
	flex-shrink: 0;
}

.cb-row__label {
	font-weight: 600;
	font-size: 0.92rem;
	color: var(--cb-black);
}

.cb-badge {
	font-size: 0.67rem;
	font-weight: 700;
	padding: 2px 7px;
	border-radius: 20px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	white-space: nowrap;
	flex-shrink: 0;
}
.cb-badge--required {
	background: var(--cb-black);
	color: #fff;
}
.cb-badge--optional {
	background: #fff;
	color: var(--cb-mid);
	border: 1px solid var(--cb-border);
}

/* Selected product display */
.cb-row__selected {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
	min-width: 0;
}

.cb-selected-img {
	width: 42px;
	height: 42px;
	object-fit: cover;
	border-radius: var(--cb-radius-btn);
	border: 1px solid var(--cb-border);
	flex-shrink: 0;
	background: var(--cb-bg);
}

.cb-selected-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.3;
}

/* Product name link — black, no color */
.cb-selected-name {
	font-weight: 600;
	font-size: 0.88rem;
	color: var(--cb-black);
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 260px;
	display: block;
}
.cb-selected-name:hover {
	text-decoration: underline;
	color: var(--cb-black);
}

/* Price — reset WooCommerce/WoodMart overrides so no gap appears */
.cb-selected-price,
.cb-selected-price .woocommerce-Price-amount,
.cb-selected-price .amount,
.cb-selected-price bdi,
.cb-selected-price ins,
.cb-selected-price del {
	display: inline;
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--cb-black) !important;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 1.3;
	text-decoration: none !important;
}

/* Row actions */
.cb-row__actions {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
	flex-shrink: 0;
}

/* --- Modal --------------------------------------------------------------- */
.cb-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cb-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	cursor: pointer;
}

.cb-modal__box {
	position: relative;
	background: #fff;
	border-radius: 12px;
	box-shadow: var(--cb-shadow-modal);
	width: 92%;
	max-width: 760px;
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.cb-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 22px;
	border-bottom: 1px solid var(--cb-border-light);
	flex-shrink: 0;
}

.cb-modal__title {
	font-size: 1.05rem;
	font-weight: 700;
	margin: 0;
	color: var(--cb-black);
}

.cb-modal__close {
	background: transparent;
	border: none;
	font-size: 1.3rem;
	cursor: pointer;
	color: var(--cb-mid);
	line-height: 1;
	padding: 4px 8px;
	border-radius: var(--cb-radius-btn);
	transition: background var(--cb-transition), color var(--cb-transition);
}
.cb-modal__close:hover {
	background: var(--cb-bg);
	color: var(--cb-black);
}

.cb-modal__search {
	padding: 12px 22px;
	border-bottom: 1px solid var(--cb-border-light);
	flex-shrink: 0;
}

.cb-modal__search input[type="search"] {
	width: 100%;
	padding: 9px 13px;
	border: 1.5px solid var(--cb-border);
	border-radius: var(--cb-radius-btn);
	font-size: 0.88rem;
	outline: none;
	transition: border-color var(--cb-transition);
	box-sizing: border-box;
	background: var(--cb-bg);
	color: var(--cb-black);
}
.cb-modal__search input[type="search"]:focus {
	border-color: var(--cb-black);
	background: #fff;
}

.cb-modal__body {
	flex: 1;
	overflow-y: auto;
	padding: 16px 22px;
	position: relative;
	min-height: 200px;
}

.cb-modal__footer {
	padding: 10px 22px;
	border-top: 1px solid var(--cb-border-light);
	flex-shrink: 0;
}

/* --- Products Grid ------------------------------------------------------ */
.cb-products-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
	gap: 12px;
}

.cb-product-card {
	border: 1.5px solid var(--cb-border);
	border-radius: var(--cb-radius-box);
	padding: 12px;
	cursor: pointer;
	transition: border-color var(--cb-transition), box-shadow var(--cb-transition);
	background: #fff;
	display: flex;
	flex-direction: column;
	gap: 7px;
}
.cb-product-card:hover {
	border-color: var(--cb-black);
	box-shadow: 0 0 0 2px rgba(0,0,0,0.08);
}
.cb-product-card.cb-product-card--active {
	border-color: var(--cb-black);
	background: #f6f6f6;
}

.cb-product-card__img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: contain;
	border-radius: var(--cb-radius-btn);
	background: var(--cb-bg);
}

.cb-product-card__name {
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--cb-black);
	overflow: hidden;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

/* Reset WooCommerce price markup inside product cards */
.cb-product-card__price,
.cb-product-card__price .woocommerce-Price-amount,
.cb-product-card__price .amount,
.cb-product-card__price bdi,
.cb-product-card__price ins,
.cb-product-card__price del {
	display: inline;
	font-size: 0.88rem;
	font-weight: 700;
	color: var(--cb-black) !important;
	margin: 0 !important;
	padding: 0 !important;
	text-decoration: none !important;
}

.cb-product-card__select {
	margin-top: auto;
	padding: 6px 0;
	background: var(--cb-black);
	color: #fff;
	border: 1.5px solid var(--cb-black);
	border-radius: var(--cb-radius-btn);
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	width: 100%;
	transition: background var(--cb-transition), color var(--cb-transition);
	text-align: center;
	line-height: 1.4;
}
.cb-product-card__select:hover {
	background: #fff;
	color: var(--cb-black);
}

/* --- Spinner ------------------------------------------------------------ */
.cb-spinner {
	display: none;
	position: absolute;
	inset: 0;
	align-items: center;
	justify-content: center;
	background: rgba(255,255,255,0.8);
}
.cb-spinner.cb-spinner--active {
	display: flex;
}
.cb-spinner::after {
	content: '';
	width: 32px;
	height: 32px;
	border: 2.5px solid var(--cb-border);
	border-top-color: var(--cb-black);
	border-radius: 50%;
	animation: cb-spin 0.7s linear infinite;
}
@keyframes cb-spin {
	to { transform: rotate(360deg); }
}

/* --- Pagination --------------------------------------------------------- */
.cb-pagination {
	display: flex;
	gap: 5px;
	justify-content: center;
	flex-wrap: wrap;
}

.cb-page-btn {
	padding: 5px 10px;
	border: 1.5px solid var(--cb-border);
	background: #fff;
	border-radius: var(--cb-radius-btn);
	font-size: 0.8rem;
	cursor: pointer;
	color: var(--cb-black);
	transition: background var(--cb-transition), border-color var(--cb-transition), color var(--cb-transition);
	line-height: 1;
}
.cb-page-btn:hover,
.cb-page-btn.cb-page-btn--active {
	background: var(--cb-black);
	border-color: var(--cb-black);
	color: #fff;
}

/* --- Empty state -------------------------------------------------------- */
.cb-empty-state {
	text-align: center;
	padding: 40px 20px;
	color: var(--cb-mid);
	font-size: 0.88rem;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
	.cb-topbar {
		flex-direction: column;
		align-items: flex-start;
	}
	.cb-row {
		flex-wrap: wrap;
	}
	.cb-row__meta {
		min-width: 0;
	}
	.cb-row__actions {
		margin-left: 0;
	}
	.cb-selected-name {
		max-width: 160px;
	}
	.cb-modal__box {
		max-height: 95vh;
		border-radius: 12px 12px 0 0;
		position: fixed;
		bottom: 0;
		width: 100%;
		max-width: 100%;
	}
	.cb-products-grid {
		grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	}
}
