/**
 * Patricia Quick Buy — Estilos (mobile-first)
 * Paleta configurable vía CSS vars inyectadas desde settings:
 *   --pqb-btn-bg, --pqb-btn-text, --pqb-accent
 */

/* ──────────────────────────────────────────────────────────────
   Variables por defecto (overrideable desde wp_head)
   ────────────────────────────────────────────────────────────── */
:root {
	--pqb-btn-bg: #111111;
	--pqb-btn-text: #ffffff;
	--pqb-accent: #d63384;
	--pqb-radius: 14px;
	--pqb-radius-sm: 10px;
	--pqb-shadow: 0 10px 40px rgba(0,0,0,0.18);
	--pqb-border: #e5e5e5;
	--pqb-muted: #6b7280;
	--pqb-bg: #ffffff;
	--pqb-surface: #f8f8f8;
	--pqb-success: #059669;
	--pqb-error: #dc2626;
	--pqb-whatsapp: #25D366;
	--pqb-addi: #002B56;
	--pqb-addi-accent: #FDD35E;
}

/* Body scroll lock cuando el modal está abierto */
body.pqb-lock-scroll { overflow: hidden; touch-action: none; }

/* ──────────────────────────────────────────────────────────────
   MODAL — Estructura
   ────────────────────────────────────────────────────────────── */
.pqb-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: flex-end;
	justify-content: center;
}
.pqb-modal.is-open {
	display: flex;
	animation: pqb-fade 180ms ease-out;
}
.pqb-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.55);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
}
.pqb-modal__sheet {
	position: relative;
	width: 100%;
	max-height: 95vh;
	background: var(--pqb-bg);
	border-radius: 20px 20px 0 0;
	box-shadow: var(--pqb-shadow);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	animation: pqb-slide-up 240ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.pqb-modal__close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 5;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: rgba(255,255,255,0.95);
	color: #111;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
	transition: transform .15s ease;
}
.pqb-modal__close:hover { transform: scale(1.08); }
.pqb-modal__body {
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	flex: 1;
}

@keyframes pqb-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}
@keyframes pqb-slide-up {
	from { transform: translateY(60px); opacity: 0; }
	to   { transform: translateY(0); opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────
   LOADING / ERROR
   ────────────────────────────────────────────────────────────── */
.pqb-loading, .pqb-error {
	padding: 60px 20px;
	text-align: center;
	color: var(--pqb-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	font-size: 15px;
}
.pqb-spinner {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: pqb-spin 0.7s linear infinite;
}
@keyframes pqb-spin { to { transform: rotate(360deg); } }

/* ──────────────────────────────────────────────────────────────
   PRODUCTO — Layout mobile (default)
   ────────────────────────────────────────────────────────────── */
.pqb-product {
	display: flex;
	flex-direction: column;
}

/* Galería */
.pqb-gallery {
	position: relative;
	background: var(--pqb-surface);
}
.pqb-gallery__main {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: var(--pqb-surface);
}
.pqb-gallery__main-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity .18s ease;
	display: block;
}
.pqb-gallery__main-img.is-swapping { opacity: 0.4; }
.pqb-gallery__placeholder {
	width: 100%;
	aspect-ratio: 1 / 1;
	background: var(--pqb-surface);
}
.pqb-gallery__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: rgba(255,255,255,0.9);
	color: #111;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
	opacity: 0.85;
	transition: opacity .15s;
}
.pqb-gallery__nav:hover { opacity: 1; }
.pqb-gallery__nav--prev { left: 10px; }
.pqb-gallery__nav--next { right: 10px; }

.pqb-gallery__thumbs {
	display: flex;
	gap: 6px;
	padding: 10px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
	background: var(--pqb-surface);
}
.pqb-gallery__thumb {
	flex: 0 0 56px;
	width: 56px;
	height: 56px;
	border-radius: var(--pqb-radius-sm);
	border: 2px solid transparent;
	padding: 0;
	overflow: hidden;
	cursor: pointer;
	background: #fff;
	transition: border-color .15s;
}
.pqb-gallery__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.pqb-gallery__thumb.is-active {
	border-color: var(--pqb-accent);
}

/* Info */
.pqb-info {
	padding: 16px 18px 24px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.pqb-info__title {
	font-size: 20px;
	line-height: 1.25;
	margin: 0;
	color: #111;
	font-weight: 600;
}
.pqb-info__price {
	font-size: 22px;
	font-weight: 700;
	color: #111;
}
.pqb-info__price del { color: var(--pqb-muted); font-weight: 400; font-size: 17px; margin-right: 8px; }
.pqb-info__price ins { text-decoration: none; color: #111; }
.pqb-info__desc {
	font-size: 14px;
	line-height: 1.5;
	color: var(--pqb-muted);
	max-height: 120px;
	overflow-y: auto;
}
.pqb-info__desc p { margin: 0 0 8px; }

/* Variaciones */
.pqb-variations {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.pqb-variation {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.pqb-variation__label {
	font-size: 13px;
	font-weight: 600;
	color: #111;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}
.pqb-variation__select {
	appearance: none;
	-webkit-appearance: none;
	width: 100%;
	padding: 12px 40px 12px 14px;
	border: 1.5px solid var(--pqb-border);
	border-radius: var(--pqb-radius-sm);
	background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path fill="%23111" d="M6 8L0 0h12z"/></svg>') no-repeat right 14px center;
	font-size: 15px;
	color: #111;
	min-height: 48px;
	cursor: pointer;
	transition: border-color .15s;
}
.pqb-variation__select:focus {
	outline: none;
	border-color: var(--pqb-accent);
}
.pqb-variations__reset { text-align: right; }

.pqb-link {
	background: none;
	border: none;
	padding: 0;
	color: var(--pqb-accent);
	font-size: 13px;
	cursor: pointer;
	text-decoration: underline;
}
.pqb-link--center { text-align: center; display: block; margin-top: 6px; }

/* Cantidad */
.pqb-qty-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}
.pqb-qty__label {
	font-size: 14px;
	font-weight: 600;
	color: #111;
}
.pqb-qty {
	display: flex;
	align-items: center;
	border: 1.5px solid var(--pqb-border);
	border-radius: var(--pqb-radius-sm);
	overflow: hidden;
	background: #fff;
}
.pqb-qty__btn {
	width: 42px;
	height: 42px;
	border: none;
	background: #fff;
	font-size: 20px;
	color: #111;
	cursor: pointer;
	font-weight: 500;
}
.pqb-qty__btn:hover { background: var(--pqb-surface); }
.pqb-qty__input {
	width: 50px;
	height: 42px;
	border: none;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	color: #111;
	background: #fff;
	-moz-appearance: textfield;
}
.pqb-qty__input::-webkit-outer-spin-button,
.pqb-qty__input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
.pqb-qty__input:focus { outline: none; }

.pqb-outofstock {
	padding: 10px 12px;
	background: #fef2f2;
	color: var(--pqb-error);
	border-radius: var(--pqb-radius-sm);
	font-size: 13px;
	font-weight: 500;
	border: 1px solid #fecaca;
}

/* Acciones */
.pqb-actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	position: sticky;
	bottom: 0;
	background: #fff;
	padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 4px);
	margin: 4px -18px -24px;
	padding-left: 18px;
	padding-right: 18px;
	border-top: 1px solid var(--pqb-border);
	z-index: 2;
}
.pqb-btn {
	appearance: none;
	border: none;
	border-radius: var(--pqb-radius-sm);
	padding: 14px 12px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 52px;
	transition: transform .1s ease, box-shadow .15s ease, opacity .15s;
	line-height: 1.2;
	text-align: center;
}
.pqb-btn:active { transform: scale(0.98); }
.pqb-btn:disabled, .pqb-btn.is-disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
.pqb-btn svg { flex-shrink: 0; }

.pqb-btn--primary {
	background: var(--pqb-btn-bg);
	color: var(--pqb-btn-text);
	grid-column: 1 / -1;
}
.pqb-btn--primary:hover:not(:disabled) { box-shadow: 0 4px 14px rgba(0,0,0,0.18); }

.pqb-btn--accent {
	background: var(--pqb-accent);
	color: #fff;
	grid-column: 1 / -1;
}
.pqb-btn--accent:hover:not(:disabled) { filter: brightness(1.08); }

.pqb-btn--whatsapp {
	background: var(--pqb-whatsapp);
	color: #fff;
}
.pqb-btn--whatsapp:hover { background: #1fb055; }

.pqb-btn--addi {
	background: var(--pqb-addi);
	color: #fff;
	position: relative;
}
.pqb-btn--addi:hover:not(:disabled) { background: #001d3d; }
.pqb-btn__addi-logo {
	display: inline-block;
	background: var(--pqb-addi-accent);
	color: var(--pqb-addi);
	font-weight: 800;
	padding: 2px 7px;
	border-radius: 4px;
	font-size: 12px;
	letter-spacing: 0.3px;
	margin-right: 4px;
}

.pqb-btn.is-loading { opacity: 0.8; cursor: wait; }

/* ──────────────────────────────────────────────────────────────
   TOAST
   ────────────────────────────────────────────────────────────── */
.pqb-toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translate(-50%, 80px);
	background: #111;
	color: #fff;
	padding: 12px 20px;
	border-radius: 50px;
	font-size: 14px;
	font-weight: 500;
	box-shadow: 0 10px 30px rgba(0,0,0,0.3);
	z-index: 1000000;
	opacity: 0;
	transition: transform .3s ease, opacity .3s ease;
	pointer-events: none;
	max-width: 90vw;
	text-align: center;
}
.pqb-toast.is-show {
	transform: translate(-50%, 0);
	opacity: 1;
}
.pqb-toast.is-success { background: var(--pqb-success); }
.pqb-toast.is-error { background: var(--pqb-error); }

/* ──────────────────────────────────────────────────────────────
   TABLET (≥ 600px) — Modal centrado, todavía stacked
   ────────────────────────────────────────────────────────────── */
@media (min-width: 600px) {
	.pqb-modal { align-items: center; }
	.pqb-modal__sheet {
		max-width: 560px;
		max-height: 92vh;
		border-radius: var(--pqb-radius);
	}
	.pqb-modal__close { top: 14px; right: 14px; }
	.pqb-gallery__main { aspect-ratio: 4 / 3; }
	.pqb-actions {
		grid-template-columns: 1fr 1fr;
	}
	.pqb-btn--primary, .pqb-btn--accent { grid-column: 1 / -1; }
}

/* ──────────────────────────────────────────────────────────────
   DESKTOP (≥ 900px) — Layout horizontal: galería izquierda + info derecha
   ────────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
	.pqb-modal__sheet {
		max-width: 960px;
		border-radius: var(--pqb-radius);
	}
	.pqb-product {
		flex-direction: row;
		min-height: 520px;
	}
	.pqb-gallery {
		flex: 0 0 50%;
		max-width: 50%;
		display: flex;
		flex-direction: column;
	}
	.pqb-gallery__main {
		aspect-ratio: 1 / 1;
		flex: 1;
	}
	.pqb-info {
		flex: 1;
		padding: 28px 28px 28px;
		max-height: 92vh;
		overflow-y: auto;
	}
	.pqb-info__title { font-size: 24px; }
	.pqb-info__price { font-size: 26px; }

	.pqb-actions {
		position: static;
		margin: 8px 0 0;
		padding: 0;
		border-top: none;
		grid-template-columns: 1fr 1fr;
		gap: 10px;
	}
	.pqb-btn--primary, .pqb-btn--accent { grid-column: 1 / -1; }

	.pqb-gallery__thumbs {
		padding: 12px;
	}
	.pqb-gallery__thumb {
		flex: 0 0 64px;
		width: 64px;
		height: 64px;
	}
}

/* ──────────────────────────────────────────────────────────────
   Ajustes defensivos contra temas agresivos
   ────────────────────────────────────────────────────────────── */
.pqb-modal * { box-sizing: border-box; }
.pqb-modal button { font-family: inherit; }
.pqb-modal img { max-width: 100%; height: auto; }

/* Evitar que el tema override el color de los botones */
.pqb-btn.pqb-btn--primary { background: var(--pqb-btn-bg) !important; color: var(--pqb-btn-text) !important; }
.pqb-btn.pqb-btn--accent  { background: var(--pqb-accent) !important; color: #fff !important; }
.pqb-btn.pqb-btn--whatsapp { background: var(--pqb-whatsapp) !important; color: #fff !important; }
.pqb-btn.pqb-btn--addi    { background: var(--pqb-addi) !important; color: #fff !important; }

/* Reducir motion si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
	.pqb-modal.is-open, .pqb-modal__sheet, .pqb-gallery__main-img, .pqb-btn, .pqb-toast {
		animation: none !important;
		transition: none !important;
	}
}
