/**
 * Banner y panel de cookies — referencia Gymshark (tarjeta «Cookies» y «Privacy Preference Center»).
 * Spec: shop/docs/cookies-medicion-v1.md.
 */

/* ---------- Velado de página (primera capa) ---------- */

.bb-shop-consent-scrim {
	position: fixed;
	z-index: 1190;
	inset: 0;
	background: rgba(0, 0, 0, 0.72);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.bb-shop-consent-scrim[hidden] {
	display: none;
}

html.bb-shop-has-consent-banner {
	overflow: hidden;
}

/* Contenedor: ancla la tarjeta y el panel en el mismo sitio (escritorio). */
.bb-shop-consent-stack {
	position: relative;
	z-index: 1200;
}

/* ---------- Primera capa: tarjeta ---------- */

.bb-shop-consent {
	position: fixed;
	z-index: 1200;
	right: 0;
	bottom: 0;
	left: 0;
	box-sizing: border-box;
	padding: 1.25rem var(--bb-shop-gutter) calc(1.25rem + env(safe-area-inset-bottom, 0px));
	background: var(--bb-color-bg);
	color: var(--bb-color-text-primary);
	box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
	font-family: var(--bb-font-body);
}

.bb-shop-consent[hidden] {
	display: none;
}

/* Escritorio: tarjeta bajo la cabecera; el panel crece hacia abajo en el mismo bloque. */
@media (min-width: 768px) {
	.bb-shop-consent-stack {
		position: fixed;
		top: calc(var(--bb-shop-topbar-height) + var(--bb-shop-header-height) + 24px);
		left: 50%;
		width: min(472px, calc(100vw - 2 * var(--bb-shop-gutter)));
		max-height: calc(100dvh - var(--bb-shop-topbar-height) - var(--bb-shop-header-height) - 48px);
		transform: translateX(-50%);
		display: flex;
		flex-direction: column;
		border-radius: 4px;
		background: var(--bb-color-bg);
		box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
		overflow: hidden;
	}

	.bb-shop-consent-stack .bb-shop-consent {
		position: relative;
		top: auto;
		right: auto;
		bottom: auto;
		left: auto;
		width: 100%;
		padding: 1.5rem;
		border-radius: 0;
		box-shadow: none;
		transform: none;
		flex-shrink: 0;
	}

	.bb-shop-consent-stack.is-dialog-only .bb-shop-consent {
		display: none;
	}

	.bb-shop-consent-stack .bb-shop-consent-dialog {
		display: none;
		position: relative;
		inset: auto;
		width: 100%;
		max-width: none;
		max-height: none;
		margin: 0;
		padding: 0;
		box-shadow: none;
		border-radius: 0;
	}

	.bb-shop-consent-stack.is-expanded .bb-shop-consent-dialog,
	.bb-shop-consent-stack.is-dialog-only .bb-shop-consent-dialog {
		display: flex;
		flex: 1 1 auto;
		min-height: 0;
		border-top: 1px solid var(--bb-shop-border);
	}

	.bb-shop-consent-stack.is-expanded .bb-shop-consent-dialog .bb-shop-consent-dialog__body {
		padding-top: 1rem;
	}

	.bb-shop-consent-stack.is-expanded .bb-shop-consent-dialog {
		max-height: min(520px, calc(100dvh - var(--bb-shop-topbar-height) - var(--bb-shop-header-height) - 200px));
	}

	.bb-shop-consent-stack.is-dialog-only .bb-shop-consent-dialog {
		border-top: 0;
		max-height: min(640px, calc(100dvh - var(--bb-shop-topbar-height) - var(--bb-shop-header-height) - 48px));
	}
}

.bb-shop-consent__title {
	margin: 0 0 0.75rem;
	font-family: var(--bb-font-body);
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
}

.bb-shop-consent__text {
	margin: 0 0 1.25rem;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--bb-color-text-secondary);
}

.bb-shop-consent__text a {
	color: var(--bb-color-text-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.bb-shop-consent__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 0.75rem 1rem;
}

/* «Déjame elegir»: enlace subrayado (el «Let Me Choose» de Gymshark). */
.bb-shop-consent__link {
	margin-right: auto;
	padding: 0.5rem 0;
	border: 0;
	background: none;
	color: var(--bb-color-text-primary);
	font-family: var(--bb-font-body);
	font-size: 0.8125rem;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* «Rechazar» y «Aceptar»: mismo botón negro (mismo peso, como pide la AEPD). */
.bb-shop-consent__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	min-width: 120px;
	padding: 0 1.25rem;
	border: 1px solid var(--bb-color-text-primary);
	border-radius: 2px;
	background: var(--bb-color-text-primary);
	color: #fff;
	font-family: var(--bb-font-body);
	font-size: 0.8125rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.bb-shop-consent__btn:hover {
	background: #333;
	border-color: #333;
}

.bb-shop-consent__btn--outline {
	background: var(--bb-color-bg);
	color: var(--bb-color-text-primary);
}

.bb-shop-consent__btn--outline:hover {
	background: var(--bb-color-surface-2);
	border-color: var(--bb-color-text-primary);
}

.bb-shop-consent__btn:focus-visible,
.bb-shop-consent__link:focus-visible,
.bb-shop-consent-cat__summary:focus-visible,
.bb-shop-consent-switch:focus-visible {
	outline: 2px solid var(--bb-color-text-primary);
	outline-offset: 2px;
}

@media (max-width: 479px) {
	.bb-shop-consent__actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	.bb-shop-consent__link {
		grid-column: 1 / -1;
		justify-self: start;
		order: 3;
	}
}

/* ---------- Segunda capa: panel de preferencias ---------- */

.bb-shop-consent-dialog {
	box-sizing: border-box;
	width: min(472px, calc(100vw - 2 * var(--bb-shop-gutter)));
	max-height: min(640px, calc(100dvh - 48px));
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: var(--bb-color-bg);
	color: var(--bb-color-text-primary);
	font-family: var(--bb-font-body);
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}

.bb-shop-consent-dialog[open] {
	display: flex;
}

.bb-shop-consent-dialog::backdrop {
	background: rgba(0, 0, 0, 0.72);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.bb-shop-consent-dialog__form {
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: 0;
	margin: 0;
}

.bb-shop-consent-dialog__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 1.25rem 1.5rem 1.5rem;
}

.bb-shop-consent-dialog__title {
	margin: 0 0 0.75rem;
	font-family: var(--bb-font-body);
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
}

.bb-shop-consent-dialog__intro {
	margin: 0 0 1.25rem;
	font-size: 0.8125rem;
	line-height: 1.55;
	color: var(--bb-color-text-secondary);
}

.bb-shop-consent-dialog__intro a {
	display: inline-block;
	margin-top: 0.25rem;
	color: var(--bb-color-text-primary);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.bb-shop-consent-dialog__subtitle {
	margin: 1.75rem 0 0.75rem;
	font-family: var(--bb-font-body);
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
}

.bb-shop-consent-dialog__list {
	margin: 0;
	padding: 0;
	list-style: none;
	border: 1px solid var(--bb-shop-border-strong);
}

.bb-shop-consent-cat {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: start;
	gap: 0 1rem;
	padding: 0 1rem;
}

.bb-shop-consent-cat + .bb-shop-consent-cat {
	border-top: 1px solid var(--bb-shop-border-strong);
}

.bb-shop-consent-cat__summary {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	min-height: 52px;
	list-style: none;
	font-size: 0.8125rem;
	font-weight: 600;
	cursor: pointer;
}

.bb-shop-consent-cat__summary::-webkit-details-marker {
	display: none;
}

/* «+» que pasa a «−» al abrir. */
.bb-shop-consent-cat__plus {
	position: relative;
	flex: 0 0 12px;
	width: 12px;
	height: 12px;
}

.bb-shop-consent-cat__plus::before,
.bb-shop-consent-cat__plus::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 0;
	width: 12px;
	height: 2px;
	margin-top: -1px;
	background: currentColor;
}

.bb-shop-consent-cat__plus::after {
	transform: rotate(90deg);
	transition: transform 0.15s ease;
}

.bb-shop-consent-cat__details[open] .bb-shop-consent-cat__plus::after {
	transform: rotate(0deg);
}

.bb-shop-consent-cat__text {
	margin: 0 0 1rem;
	padding-left: 1.5rem;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--bb-color-text-secondary);
}

.bb-shop-consent-cat__always {
	display: flex;
	align-items: center;
	min-height: 52px;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--bb-color-text-primary);
}

/* Interruptor (checkbox con role="switch"). */
.bb-shop-consent-switch {
	position: relative;
	flex: 0 0 auto;
	width: 40px;
	height: 22px;
	margin: 15px 0 0;
	border-radius: 999px;
	background: #8c8c8c;
	appearance: none;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.bb-shop-consent-switch::before {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s ease;
}

.bb-shop-consent-switch:checked {
	background: var(--bb-color-text-primary);
}

.bb-shop-consent-switch:checked::before {
	transform: translateX(18px);
}

.bb-shop-consent-dialog__footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 0.75rem;
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--bb-shop-border);
	background: var(--bb-color-bg);
}

/* Escritorio: «Guardar» a la izquierda; «Rechazar todas» y «Aceptar todas» juntos a la derecha. */
.bb-shop-consent-dialog__footer .bb-shop-consent__btn {
	min-width: 0;
}

.bb-shop-consent-dialog__save {
	margin-right: auto;
}

/* Móvil: «Rechazar todas» y «Aceptar todas» en una fila (mismo ancho) y «Guardar» debajo. */
@media (max-width: 479px) {
	.bb-shop-consent-dialog__footer {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	.bb-shop-consent-dialog__footer .bb-shop-consent__btn {
		padding: 0 0.5rem;
		white-space: nowrap;
	}

	.bb-shop-consent-dialog__save {
		grid-column: 1 / -1;
		order: 3;
		margin-right: 0;
	}
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
	.bb-shop-consent-scrim,
	.bb-shop-consent-dialog::backdrop {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		background: rgba(0, 0, 0, 0.85);
	}
}

@media (prefers-reduced-motion: reduce) {
	.bb-shop-consent-switch,
	.bb-shop-consent-switch::before,
	.bb-shop-consent-cat__plus::after,
	.bb-shop-consent__btn {
		transition: none;
	}
}
