/* Phase 6c: quick-add modal. Loads after ww-shop.css (design tokens), on
   every WooCommerce page (shop/category/tag archives + single-product,
   since the `product-card` template part with the quick-add button also
   appears in the PDP's "Related products" block). No !important anywhere —
   selectors are written specific enough to win the cascade on their own,
   same approach as every other Phase's CSS in this plugin.

   The modal reuses the REAL woocommerce/add-to-cart-with-options block
   markup (fetched from the Phase 6c REST endpoint — see
   waifuworld_render_add_to_cart_with_options_form() in the main plugin
   file), so its button/quantity-stepper/variant-pill styling below mirrors
   the PDP's "plain/restrained" look (ww-shop-pdp.css) rather than
   duplicating it — that PDP stylesheet is scoped to `.single-product` body
   class and wouldn't apply inside the modal on a shop/category page. */

/* ---------------------------------------------------------------------
   Loading state on the grid's neon quick-add button while the modal's
   product data is being fetched.
------------------------------------------------------------------------ */
.wc-block-components-product-button__button.ww-quickadd-btn-loading {
	position: relative;
	color: transparent;
	pointer-events: none;
}
.ww-quickadd-btn-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border: 2px solid rgba(255,255,255,0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ww-quickadd-spin 0.7s linear infinite;
}

@keyframes ww-quickadd-spin {
	to { transform: rotate(360deg); }
}

.wc-block-components-product-button__button.ww-quickadd-btn-error {
	animation: ww-quickadd-shake 0.4s ease;
}

@keyframes ww-quickadd-shake {
	25% { transform: translateX(-3px); }
	75% { transform: translateX(3px); }
}

/* ---------------------------------------------------------------------
   Overlay + dialog shell.
------------------------------------------------------------------------ */
.ww-quickadd-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(20, 16, 18, 0.55);
	backdrop-filter: blur(2px);
}
.ww-quickadd-overlay[hidden] {
	display: none;
}

.ww-quickadd-dialog {
	position: relative;
	width: 100%;
	max-width: 780px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	background: var(--shop-bg, #fafaf8);
	border-radius: 14px;
	box-shadow: 0 24px 60px rgba(0,0,0,0.35);
	padding: 32px;
}

.ww-quickadd-close {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 50%;
	background: rgba(0,0,0,0.06);
	color: var(--shop-text, #333);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease;
}
.ww-quickadd-close:hover {
	background: rgba(0,0,0,0.12);
}

.ww-quickadd-body {
	display: grid;
	grid-template-columns: minmax(0, 280px) 1fr;
	gap: 28px;
}

@media screen and (max-width: 640px) {
	.ww-quickadd-dialog {
		padding: 24px 18px;
	}
	.ww-quickadd-body {
		grid-template-columns: 1fr;
	}
}

/* ---------------------------------------------------------------------
   Gallery.
------------------------------------------------------------------------ */
.ww-quickadd-gallery-main {
	border-radius: 10px;
	overflow: hidden;
	background: #f0f0ee;
	aspect-ratio: 3 / 4;
}
.ww-quickadd-gallery-main img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.ww-quickadd-gallery-thumbs {
	display: flex;
	gap: 8px;
	margin-top: 10px;
	flex-wrap: wrap;
}
.ww-quickadd-gallery-thumbs button {
	padding: 0;
	width: 52px;
	height: 52px;
	border-radius: 6px;
	overflow: hidden;
	border: 2px solid transparent;
	background: none;
	cursor: pointer;
}
.ww-quickadd-gallery-thumbs button.is-active {
	border-color: var(--shop-price, #B12704);
}
.ww-quickadd-gallery-thumbs img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ---------------------------------------------------------------------
   Info column: title, price, then the real add-to-cart-with-options form.
------------------------------------------------------------------------ */
.ww-quickadd-title {
	font-family: 'Montserrat', sans-serif;
	font-weight: 800;
	font-size: 20px;
	color: var(--shop-card-title, #6d382b);
	margin: 0 0 8px;
}
.ww-quickadd-price,
.ww-quickadd-price .wc-block-components-product-price {
	font-family: 'Montserrat', sans-serif;
	font-weight: 900;
	font-style: italic;
	font-size: 22px;
	color: var(--shop-price, #B12704);
	margin: 0 0 18px;
}

.ww-quickadd-form-wrap .wc-block-add-to-cart-with-options {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

/* Variation attribute pills — same "chip" shape as the filter-bar pills
   this markup borrows its block from, restyled to the shop palette. */
.ww-quickadd-form-wrap .wc-block-product-filter-chips__items {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	list-style: none;
	margin: 0;
	padding: 0;
}
.ww-quickadd-form-wrap .wc-block-product-filter-chips__item {
	border: 1px solid var(--shop-border-control, #ccc);
	background: #fff;
	color: var(--shop-text, #333);
	border-radius: 999px;
	padding: 6px 16px;
	font-family: 'Inter', sans-serif;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.ww-quickadd-form-wrap .wc-block-product-filter-chips__item:hover {
	border-color: var(--shop-price, #B12704);
}
.ww-quickadd-form-wrap .wc-block-product-filter-chips__item[aria-checked="true"] {
	border-color: var(--shop-price, #B12704);
	background: var(--shop-price, #B12704);
	color: #fff;
}
.ww-quickadd-form-wrap .wc-block-product-filter-chips__item[disabled] {
	opacity: 0.4;
	cursor: not-allowed;
}
.ww-quickadd-form-wrap .wp-block-woocommerce-add-to-cart-with-options-variation-selector-attribute-name {
	display: block;
	font-family: 'Inter', sans-serif;
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--shop-text-muted, #888);
	margin-bottom: 6px;
}

/* Quantity stepper + Add to cart button row — plain/restrained, matching
   the PDP's visual language (no gradient/glow; that treatment stays
   exclusive to the grid's own neon quick-add trigger button). */
.ww-quickadd-form-wrap .wp-block-group {
	display: flex;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 10px;
}
.ww-quickadd-form-wrap .wc-block-components-quantity-selector {
	display: flex;
	align-items: stretch;
	border: 1px solid var(--shop-border-control, #ccc);
	border-radius: 6px;
	overflow: hidden;
}
.ww-quickadd-form-wrap .wc-block-components-quantity-selector__button {
	border: none;
	background: #f5f5f3;
	color: var(--shop-text, #333);
	width: 34px;
	cursor: pointer;
	font-size: 16px;
}
.ww-quickadd-form-wrap .wc-block-components-quantity-selector__button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}
.ww-quickadd-form-wrap .wc-block-components-quantity-selector__input {
	width: 46px;
	border: none;
	border-left: 1px solid var(--shop-border-control, #ccc);
	border-right: 1px solid var(--shop-border-control, #ccc);
	text-align: center;
	font-family: 'Inter', sans-serif;
	font-size: 14px;
	-moz-appearance: textfield;
}
.ww-quickadd-form-wrap .wp-block-woocommerce-product-button {
	flex: 1 1 auto;
}
.ww-quickadd-form-wrap .wc-block-components-product-button__button {
	width: 100%;
	height: 100%;
	min-height: 40px;
	border: none;
	border-radius: 6px;
	background: var(--shop-text, #333);
	color: #fff;
	font-family: 'Inter', sans-serif;
	font-weight: 700;
	font-size: 14px;
	cursor: pointer;
	transition: background 0.15s ease, opacity 0.15s ease;
}
.ww-quickadd-form-wrap .wc-block-components-product-button__button:hover {
	background: #000;
}
.ww-quickadd-form-wrap .wc-block-components-product-button__button:disabled,
.ww-quickadd-form-wrap .wc-block-components-product-button__button.is-disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
.ww-quickadd-form-wrap .wc-block-components-product-button__button.is-added {
	background: #2e7d32;
}

.ww-quickadd-message {
	margin-top: 12px;
	font-family: 'Inter', sans-serif;
	font-size: 13px;
	color: var(--shop-text, #333);
}
.ww-quickadd-message[hidden] {
	display: none;
}
.ww-quickadd-message.is-error {
	color: #b3261e;
}

/* ---------------------------------------------------------------------
   In-modal loading overlay (fetching product data / submitting add-to-cart).
------------------------------------------------------------------------ */
.ww-quickadd-loading-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(250, 250, 248, 0.75);
	border-radius: 14px;
}
.ww-quickadd-loading-overlay[hidden] {
	display: none;
}
.ww-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid var(--shop-border, #e8e8e8);
	border-top-color: var(--shop-price, #B12704);
	border-radius: 50%;
	animation: ww-quickadd-spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
	.ww-quickadd-btn-loading::after,
	.ww-quickadd-btn-error,
	.ww-spinner {
		animation: none;
	}
}
