/**
 * Minifabrik Product Options — frontend baseline CSS.
 *
 * Every rule is wrapped in `:where()` for specificity (0,0,0). The child theme
 * `mf-addon-*` Global Styles (planned M6 T2) will override these without
 * needing `!important`.
 */

/* Wrapper -------------------------------------------------------------- */

:where(.mfpo-addons) {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin: 24px 0;
}

:where(.mfpo-addon-field) {
	display: block;
}

:where(.mfpo-addon-field[data-invalid="1"]) {
	outline: 2px solid #c00;
	outline-offset: 4px;
	border-radius: 4px;
}

:where(.mfpo-addon-field__label) {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
}

:where(.mfpo-addon-field__required) {
	color: #c00;
}

:where(.mfpo-addon-field__desc) {
	color: #666;
	font-size: 0.9em;
	margin: -2px 0 8px;
}

/* Select / Text / Number inputs --------------------------------------- */

:where(select.mfpo-addon-input,
	input.mfpo-addon-input[type="text"],
	input.mfpo-addon-input[type="number"]) {
	display: block;
	width: 100%;
	max-width: 360px;
	padding: 8px 10px;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	font: inherit;
}

/* Radio group --------------------------------------------------------- */

:where(.mfpo-addon-radios) {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

:where(.mfpo-addon-radio) {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

:where(.mfpo-addon-radio input[type="radio"]) {
	margin: 0;
}

/* Checkbox group ------------------------------------------------------ */

:where(.mfpo-addon-checkboxes) {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

:where(.mfpo-addon-checkbox) {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
}

:where(.mfpo-addon-checkbox__thumb) {
	display: inline-block;
	width: 32px;
	height: 32px;
	background-size: cover;
	background-position: center;
	border: 1px solid #ddd;
	border-radius: 4px;
}

/* Swatches ------------------------------------------------------------ */

:where(.mfpo-addon-swatches) {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 4px;
}

:where(.mfpo-addon-swatch) {
	width: 40px;
	height: 40px;
	border: 2px solid #ddd;
	border-radius: 50%;
	background-size: cover;
	background-position: center;
	background-color: transparent;
	cursor: pointer;
	padding: 0;
	transition: border-color 0.2s, transform 0.1s, box-shadow 0.2s;
}

:where(.mfpo-addon-swatch:hover) {
	border-color: #333;
	transform: scale(1.05);
}

:where(.mfpo-addon-swatch--active) {
	border-color: #2271b1;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

:where(.mfpo-addon-swatch--more) {
	width: auto;
	height: 40px;
	border-radius: 20px;
	padding: 0 14px;
	background: #f0f0f0;
	font-size: 0.85em;
	border-color: #d0d0d0;
}

/* Modal --------------------------------------------------------------- */

:where(.mfpo-addon-modal) {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
}

:where(.mfpo-addon-modal[hidden]) {
	display: none;
}

:where(.mfpo-addon-modal__backdrop) {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
}

:where(.mfpo-addon-modal__panel) {
	position: relative;
	background: #fff;
	border-radius: 8px;
	padding: 24px;
	max-width: 600px;
	width: calc(100% - 32px);
	max-height: 80vh;
	overflow: auto;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

:where(.mfpo-addon-modal__title) {
	margin: 0 32px 0 0;
	font-size: 1.1em;
}

:where(.mfpo-addon-modal__close) {
	position: absolute;
	top: 8px;
	right: 8px;
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 8px;
}

:where(.mfpo-addon-modal__grid) {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
	gap: 8px;
	margin-top: 16px;
}

:where(.mfpo-addon-modal__grid .mfpo-addon-swatch) {
	width: 100%;
	height: 56px;
	border-radius: 6px;
}

/* Total panel --------------------------------------------------------- */

:where(.mfpo-addon-total) {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin: 16px 0;
	padding: 12px;
	background: #f9f9f9;
	border-left: 3px solid #2271b1;
}

:where(.mfpo-addon-total[hidden]) {
	display: none;
}

:where(.mfpo-addon-total strong) {
	font-weight: 700;
}

/* Mobile -------------------------------------------------------------- */

@media (max-width: 767px) {
	:where(.mfpo-addon-swatch) {
		width: 36px;
		height: 36px;
	}
	:where(.mfpo-addon-modal__panel) {
		padding: 16px;
	}
}
