/* OPP Configurador de Lentes 1.2.0 — modal nativo con alcance .opp-cfg; tokens D18 de Brand con respaldo.
   Desktop/tablet (≥768 px): modal centrado (máx. 820 px, como el wizard Legacy). Móvil: pantalla completa. */

.opp-cfg {
	--opp-cfg-red: var(--opp-color-red, #de1a08);
	--opp-cfg-gray: var(--opp-color-gray, #323232);
	--opp-cfg-muted: var(--opp-color-muted, #6b6b6b);
	--opp-cfg-radius: var(--opp-control-radius, 8px);
	--opp-cfg-line: rgba(0, 0, 0, 0.14);
	font-family: var(--opp-font-sans, "Open Sans", Helvetica, Arial, sans-serif);
	color: var(--opp-cfg-gray);
	width: 100%;
}

.opp-cfg .opp-cfg__open {
	width: 100%;
	justify-content: center;
}

.opp-cfg [hidden] {
	display: none !important;
}

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

.opp-cfg__dialog {
	box-sizing: border-box;
	width: calc(100% - 48px);
	max-width: 820px;
	max-height: calc(100vh - 40px);
	max-height: calc(100dvh - 40px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 14px;
	background: #fff;
	color: var(--opp-cfg-gray);
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
	overflow: hidden;
	overscroll-behavior: contain;
}

.opp-cfg__dialog::backdrop {
	background: rgba(0, 0, 0, 0.55);
}

/* Sin <dialog> nativo: posicionamiento propio. */
.opp-cfg__dialog.is-fallback[open] {
	position: fixed;
	inset: 0;
	z-index: 100000;
}

.opp-cfg__frame {
	display: flex;
	flex-direction: column;
	max-height: inherit;
	min-height: 0;
}

.opp-cfg__dialog[open] .opp-cfg__frame {
	max-height: calc(100vh - 40px);
	max-height: calc(100dvh - 40px);
}

.opp-cfg__head {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.75rem 0.75rem 0.5rem 1.25rem;
	border-bottom: 1px solid var(--opp-cfg-line);
}

.opp-cfg__head-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--opp-cfg-gray);
	overflow-wrap: anywhere;
}

.opp-cfg .opp-cfg__close {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--opp-cfg-radius);
	background: transparent;
	color: var(--opp-cfg-gray);
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.opp-cfg .opp-cfg__close:hover {
	background: rgba(0, 0, 0, 0.05);
}

/* ---- Indicador Legacy «Personalización N de 3» ---- */

.opp-cfg__progress {
	flex: 0 0 auto;
	padding: 0.6rem 1.25rem 0;
}

.opp-cfg__progress-label {
	margin: 0 0 0.35rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--opp-cfg-muted);
}

.opp-cfg__progress-track {
	height: 4px;
	border-radius: 2px;
	background: rgba(0, 0, 0, 0.08);
	overflow: hidden;
}

.opp-cfg__progress-fill {
	display: block;
	height: 100%;
	width: 0;
	background: var(--opp-cfg-red);
	transition: width 0.2s ease;
}

.opp-cfg__progress.is-rapid .opp-cfg__progress-track {
	display: none;
}

/* ---- Cuerpo desplazable ---- */

.opp-cfg__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 1rem 1.25rem;
}

.opp-cfg fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

.opp-cfg__legend {
	padding: 0;
	margin: 0 0 0.6rem;
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.35;
}

.opp-cfg__legend:focus {
	outline: none;
}

.opp-cfg__legend:focus-visible {
	outline: 2px solid var(--opp-cfg-red);
	outline-offset: 2px;
}

.opp-cfg__hint {
	margin: 0 0 0.85rem;
	font-size: 0.9rem;
	color: var(--opp-cfg-muted);
}

/* ---- Tarjetas con imagen Legacy ---- */

.opp-cfg__options {
	display: grid;
	gap: 0.6rem;
	border-radius: var(--opp-cfg-radius);
}

.opp-cfg__option {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.85rem;
	min-height: 64px;
	padding: 0.6rem 2.6rem 0.6rem 0.6rem;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: var(--opp-cfg-radius);
	background: #fff;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.opp-cfg__option:hover {
	border-color: var(--opp-cfg-gray);
}

.opp-cfg__option.is-selected,
.opp-cfg__option:has(input:checked) {
	border-color: var(--opp-cfg-red);
	box-shadow: 0 0 0 1px var(--opp-cfg-red);
}

.opp-cfg__option:has(input:focus-visible) {
	outline: 2px solid var(--opp-cfg-red);
	outline-offset: 2px;
}

.opp-cfg__option.is-disabled {
	opacity: 0.55;
	cursor: not-allowed;
}

/* Radio nativo accesible (teclado y lector), oculto visualmente. */
.opp-cfg .opp-cfg__radio {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.opp-cfg__check {
	position: absolute;
	top: 50%;
	right: 0.8rem;
	width: 20px;
	height: 20px;
	margin-top: -10px;
	border: 2px solid rgba(0, 0, 0, 0.3);
	border-radius: 50%;
	box-sizing: border-box;
}

.opp-cfg__option.is-selected .opp-cfg__check,
.opp-cfg__option:has(input:checked) .opp-cfg__check {
	border-color: var(--opp-cfg-red);
	background: radial-gradient(circle, var(--opp-cfg-red) 0 4px, transparent 5px);
}

/* Imagen, cuerpo e indicador son decorativos: el clic siempre llega al <label> (y de ahí al radio). */
.opp-cfg__option-media,
.opp-cfg__option-body,
.opp-cfg__check {
	pointer-events: none;
}

.opp-cfg__option-media {
	flex: 0 0 auto;
	display: block;
	width: 76px;
	height: 76px;
	object-fit: contain;
}

.opp-cfg__option-media--icon {
	width: 56px;
	height: 56px;
}

.opp-cfg__option-body {
	display: grid;
	gap: 0.15rem;
	min-width: 0;
}

.opp-cfg__option-title {
	font-weight: 600;
	line-height: 1.3;
}

.opp-cfg__option-desc {
	font-size: 0.85rem;
	line-height: 1.35;
	color: var(--opp-cfg-muted);
	overflow-wrap: anywhere;
}

.opp-cfg__option-price {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--opp-cfg-red);
}

/* Resaltado Legacy («flash») al volver a la modalidad o al faltar selección. */
.opp-cfg .is-flash {
	animation: opp-cfg-flash 1.2s ease;
}

@keyframes opp-cfg-flash {
	0%,
	100% {
		box-shadow: 0 0 0 1px var(--opp-cfg-red);
	}
	30%,
	70% {
		box-shadow: 0 0 0 4px rgba(222, 26, 8, 0.35);
	}
}

/* ---- Pie fijo: mini-resumen, estado y acciones ---- */

.opp-cfg__foot {
	flex: 0 0 auto;
	padding: 0.75rem 1.25rem 1rem;
	border-top: 1px solid var(--opp-cfg-line);
	background: #fff;
}

.opp-cfg__summary {
	padding: 0.55rem 0.75rem;
	border-radius: var(--opp-cfg-radius);
	background: #f6f6f6;
}

.opp-cfg__summary-row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin: 0 0 0.2rem;
	font-size: 0.875rem;
	line-height: 1.35;
}

.opp-cfg__summary-row span:first-child {
	min-width: 0;
	overflow-wrap: anywhere;
}

.opp-cfg__summary-row span:last-child {
	flex: 0 0 auto;
	font-weight: 600;
}

.opp-cfg__summary-row.is-total {
	margin-top: 0.35rem;
	padding-top: 0.35rem;
	border-top: 1px solid rgba(0, 0, 0, 0.12);
	font-size: 0.95rem;
}

.opp-cfg__summary-row.is-total span:last-child {
	color: var(--opp-cfg-red);
}

.opp-cfg__summary-note {
	margin: 0.15rem 0 0;
	font-size: 0.75rem;
	color: var(--opp-cfg-muted);
}

.opp-cfg__status {
	margin: 0.5rem 0 0;
	font-size: 0.875rem;
}

.opp-cfg__status:empty {
	display: none;
}

.opp-cfg__status.is-error {
	color: var(--opp-cfg-red);
	font-weight: 600;
}

.opp-cfg__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.opp-cfg .opp-cfg__btn {
	min-height: 44px;
	padding: 0.4rem 1rem;
	border-radius: var(--opp-cfg-radius);
	font-weight: 600;
	cursor: pointer;
}

.opp-cfg .opp-cfg__btn--ghost {
	border: 1px solid rgba(0, 0, 0, 0.25);
	background: #fff;
	color: var(--opp-cfg-gray);
}

.opp-cfg .opp-cfg__btn--ghost:hover {
	border-color: var(--opp-cfg-gray);
}

.opp-cfg .opp-cfg__btn--primary {
	flex: 1 1 auto;
	justify-content: center;
}

.opp-cfg .opp-cfg__btn:focus-visible,
.opp-cfg .opp-cfg__close:focus-visible {
	outline: 3px solid rgba(222, 26, 8, 0.45);
	outline-offset: 2px;
}

.opp-cfg .opp-cfg__btn:disabled {
	opacity: 0.6;
	cursor: progress;
}

/* ---- Aro no disponible (Legacy) ---- */

.opp-cfg--unavailable {
	padding: 1rem;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: var(--opp-cfg-radius);
}

.opp-cfg--unavailable p {
	margin: 0 0 0.4rem;
}

.opp-cfg__notice-title {
	font-weight: 700;
}

/* Bloqueo de scroll de la página mientras el modal está abierto. */
html.opp-cfg-lock,
html.opp-cfg-lock body {
	overflow: hidden;
}

/* Desktop/tablet: imágenes algo mayores, como el wizard Legacy. */
@media screen and (min-width: 768px) {
	.opp-cfg__option {
		min-height: 76px;
	}

	.opp-cfg__option-media {
		width: 92px;
		height: 92px;
	}

	.opp-cfg__option-media--icon {
		width: 66px;
		height: 66px;
	}
}

/* Móvil: pantalla completa; cabecera y pie respetan las zonas seguras. */
@media screen and (max-width: 767px) {
	.opp-cfg__dialog {
		width: 100%;
		max-width: 100%;
		height: 100%;
		height: 100vh;
		height: 100dvh;
		max-height: 100%;
		max-height: 100dvh;
		margin: 0;
		border-radius: 0;
		box-shadow: none;
	}

	.opp-cfg__dialog[open] .opp-cfg__frame {
		height: 100%;
		max-height: 100%;
	}

	.opp-cfg__head {
		padding-top: max(0.6rem, env(safe-area-inset-top, 0px));
		padding-left: max(16px, env(safe-area-inset-left, 0px));
		padding-right: max(8px, env(safe-area-inset-right, 0px));
	}

	.opp-cfg__progress,
	.opp-cfg__body {
		padding-left: 16px;
		padding-right: 16px;
	}

	.opp-cfg__foot {
		padding: 0.6rem 16px max(0.75rem, env(safe-area-inset-bottom, 0px));
	}

	/* Una sola fila siempre: Cancelar | Atrás | Continuar, en orden DOM. */
	.opp-cfg .opp-cfg__actions {
		flex-wrap: nowrap;
	}

	.opp-cfg .opp-cfg__btn {
		flex: 1 1 0;
		padding: 0.4rem 0.6rem;
	}

	/* Mismo flex que ya aplica Brand al .button del add-to-cart (ancho actual del principal). */
	.opp-cfg .opp-cfg__btn--primary {
		flex: 1 1 auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.opp-cfg__option,
	.opp-cfg__progress-fill {
		transition: none;
	}

	.opp-cfg .is-flash {
		animation: none;
	}
}
