/* ============================================================
   Smart Quick View Modal — v3.2
   Fixes: center popup on mobile (no bottom sheet), attr left align,
          responsive controls, qty 40% / atc 60%
   ============================================================ */

/* ── Body scroll-lock when modal open ── */
body.smart-modal-open {
	overflow: hidden !important;
}

/* ── Overlay ── */
.smart-modal {
	display: none;              /* hidden by default */
	position: fixed;
	z-index: 99999;
	inset: 0;                   /* top/right/bottom/left: 0 */
	width: 100%;
	height: 100%;
	background-color: rgba(0,0,0,0.55);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	align-items: center;
	justify-content: center;
	overflow-y: auto;
}

/* JS sets display:flex — this keeps centering intact */
.smart-modal[style*="display: flex"],
.smart-modal[style*="display:flex"] {
	display: flex !important;
}

/* ── Modal Box ── */
.smart-modal-content {
	background-color: #fff;
	margin: auto;               /* centers in flex overlay */
	padding: 0;
	border-radius: 14px;
	width: 92%;
	max-width: 820px;
	position: relative;
	box-shadow: 0 8px 40px rgba(0,0,0,0.22);
	max-height: 90vh;
	overflow-y: auto;
}

@keyframes smart-modal-show {
	from { transform: scale(0.85); opacity: 0; }
	to   { transform: scale(1);    opacity: 1; }
}

/* ── Opening & Closing Animation Classes ── */
.smart-modal.smart-modal-opening {
	animation: smart-modal-bg-show 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.smart-modal.smart-modal-opening .smart-modal-content {
	animation: smart-modal-show 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;
}
.smart-modal.smart-modal-closing {
	animation: smart-modal-bg-hide 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;
}
.smart-modal.smart-modal-closing .smart-modal-content {
	animation: smart-modal-hide 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;
}

@keyframes smart-modal-bg-show {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes smart-modal-bg-hide {
	from { opacity: 1; }
	to   { opacity: 0; }
}

@keyframes smart-modal-hide {
	from { transform: scale(1); opacity: 1; }
	to   { transform: scale(0.85); opacity: 0; }
}

/* ── Close Button ── */
.smart-modal-close {
	color: #333;
	font-size: 18px;
	font-weight: bold;
	cursor: pointer;
	position: absolute;
	right: 12px;
	top: 12px;
	z-index: 10;
	background: rgba(255,255,255,0.95);
	width: 32px;
	height: 32px;
	line-height: 32px;
	text-align: center;
	border-radius: 50%;
	transition: background 0.2s, color 0.2s, transform 0.2s;
	box-shadow: 0 2px 8px rgba(0,0,0,0.15);
	user-select: none;
}

.smart-modal-close:hover,
.smart-modal-close:focus {
	background: #e0457b;
	color: #fff;
	transform: scale(1.1);
	text-decoration: none;
}

/* ── Modal Body ── */
.smart-modal-body {
	padding: 24px;
}

/* ── Loading Spinner ── */
.smart-modal-loader {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 60px 20px;
	color: #888;
	font-size: 14px;
}

.smart-loader-spinner {
	width: 36px;
	height: 36px;
	border: 3px solid #e0e0e0;
	border-top-color: #e0457b;
	border-radius: 50%;
	animation: smart-spin 0.8s linear infinite;
}

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

.smart-error {
	color: #c0392b;
	text-align: center;
	padding: 24px;
	font-size: 14px;
}

/* ============================================================
   Product Quick View Layout
   ============================================================ */
.smart-product-quick-view {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	align-items: flex-start;
}

/* ── Image Panel ── */
.smart-pq-left {
	flex: 1 1 36%;
	min-width: 180px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #f5f5f5;
	border-radius: 10px;
	padding: 14px;
	overflow: hidden;
}

.smart-pq-left img {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	display: block;
	transition: transform 0.3s ease;
}

.smart-pq-left img:hover {
	transform: scale(1.03);
}

/* ── Right Panel ── */
.smart-pq-right {
	flex: 1 1 52%;
	min-width: 220px;
	display: flex;
	flex-direction: column;
}

/* ── Title ── */
.smart-pq-title {
	font-size: 20px;
	margin: 0 0 6px;
	color: #1a1a1a;
	font-weight: 700;
	line-height: 1.3;
}

/* ── Price ── */
.smart-pq-price {
	font-size: 19px;
	font-weight: bold;
	margin-bottom: 14px;
	line-height: 1.4;
}

.smart-pq-price del {
	color: #999;
	font-size: 14px;
	font-weight: normal;
	margin-right: 6px;
}

.smart-pq-price ins {
	text-decoration: none;
	color: #0c8a24;
}

.smart-pq-price .woocommerce-Price-amount {
	color: #0c8a24;
}

.smart-pq-price del .woocommerce-Price-amount {
	color: #999;
}

/* ============================================================
   WooCommerce Variation Form overrides in popup
   ============================================================ */
.smart-product-quick-view .variations_form {
	margin-bottom: 0;
	width: 100%;
}

/* Hide Clear link */
.smart-product-quick-view a.reset_variations {
	display: none !important;
}

/* Hide Secondary Price (WC shows variation price separately) */
.smart-product-quick-view .woocommerce-variation-price {
	display: none !important;
}

/* WC select dropdowns in popup */
.smart-product-quick-view table.variations select {
	width: 100%;
	padding: 6px 10px;
	border: 1px solid #ddd;
	border-radius: 6px;
	font-size: 13px;
	background: #fff;
}

/* ============================================================
   Attribute Table — Reset all WC default borders/backgrounds
   ============================================================ */
.smart-product-quick-view table.variations {
	width: 100%;
	margin-bottom: 12px;
	border-collapse: collapse;
}

/* Hard reset: no borders, no backgrounds from theme/WC */
.smart-product-quick-view table.variations,
.smart-product-quick-view table.variations tbody,
.smart-product-quick-view table.variations tr,
.smart-product-quick-view table.variations td,
.smart-product-quick-view table.variations th {
	border: none !important;
	background: transparent !important;
}

/* Attribute labels — always left aligned */
.smart-product-quick-view table.variations td.label,
.smart-product-quick-view table.variations td.label label,
.smart-product-quick-view table.variations th.label,
.smart-product-quick-view table.variations th.label label {
	text-align: left !important;
}

/* ── STACKED layout (label on top, swatches below) ── */
.attr-layout-stacked .smart-product-quick-view table.variations tr {
	display: block;
	margin-bottom: 14px;
}

.attr-layout-stacked .smart-product-quick-view table.variations td,
.attr-layout-stacked .smart-product-quick-view table.variations th {
	display: block;
	padding: 0;
}

/* Label: only bottom padding, divider comes from ::after (width set via admin) */
.attr-layout-stacked .smart-product-quick-view table.variations td.label,
.attr-layout-stacked .smart-product-quick-view table.variations th.label {
	padding-bottom: 7px;
	color: #555;
	font-weight: 600;
	font-size: 13px;
	text-align: left !important;
	/* No border-bottom here — controlled by ::after pseudo-element from admin settings */
}

/* Swatches area */
.attr-layout-stacked .smart-product-quick-view table.variations td.value,
.attr-layout-stacked .smart-product-quick-view table.variations th.value {
	padding-top: 8px;
}

/* ── INLINE layout (label left, swatches right) ── */
.attr-layout-inline .smart-product-quick-view table.variations tr {
	display: flex;
	align-items: center;
	margin-bottom: 10px;
}

.attr-layout-inline .smart-product-quick-view table.variations td,
.attr-layout-inline .smart-product-quick-view table.variations th {
	padding: 0;
}

.attr-layout-inline .smart-product-quick-view table.variations td.label,
.attr-layout-inline .smart-product-quick-view table.variations th.label {
	flex: 0 0 80px;
	min-width: 80px;
	max-width: 110px;
	color: #555;
	font-weight: 600;
	font-size: 13px;
	padding-right: 10px;
	white-space: nowrap;
	text-align: left !important;
}

.attr-layout-inline .smart-product-quick-view table.variations td.value,
.attr-layout-inline .smart-product-quick-view table.variations th.value {
	flex: 1;
	min-width: 0;
}

/* Swatches always wrap */
.smart-product-quick-view .smart-swatches-list {
	flex-wrap: wrap !important;
}

/* ============================================================
   Action Row (Qty + ATC + Buy Now)
   ============================================================ */
.smart-product-quick-view .single_variation_wrap {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 0 !important;
	padding-bottom: 0 !important;
}

.smart-product-quick-view .woocommerce-variation-add-to-cart {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: stretch;
	margin-bottom: 0 !important;
	padding-bottom: 0 !important;
}

/* Buy Now wrapper — full width row below ATC */
.smart-product-quick-view .smart-buy-now-wrap {
	flex: 0 0 100%;
	width: 100%;
}

/* Remove empty space */
.smart-product-quick-view form.cart {
	margin-bottom: 0 !important;
}

/* ============================================================
   Quantity +/- Styling
   ============================================================ */
.smart-product-quick-view .quantity {
	display: block !important;
	margin-right: 0 !important;
}

.smart-qty-wrapper {
	display: flex;
	align-items: stretch;
	border: 1px solid #ddd;
	border-radius: 6px;
	height: 44px;
	overflow: hidden;
	flex-shrink: 0;
}

.smart-qty-btn {
	background: #f5f5f5;
	border: none !important;
	outline: none !important;
	width: 36px;
	height: 100%;
	cursor: pointer;
	font-size: 18px;
	color: #333;
	transition: background 0.2s, color 0.2s;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.smart-qty-btn:hover {
	background: #e0457b;
	color: #fff;
}

.smart-qty-wrapper input.qty {
	width: 46px;
	height: 100%;
	text-align: center;
	border: none;
	-moz-appearance: textfield;
	padding: 0;
	margin: 0;
	font-size: 15px;
	background: #fff;
}

.smart-qty-wrapper input.qty::-webkit-outer-spin-button,
.smart-qty-wrapper input.qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* ============================================================
   Add to Cart Button
   ============================================================ */
.smart-product-quick-view button.single_add_to_cart_button {
	background-color: #222;
	color: #fff;
	border: none;
	height: 44px;
	padding: 0 24px;
	border-radius: 6px;
	font-weight: 600;
	cursor: pointer;
	flex: 1;
	transition: background-color 0.25s;
	opacity: 1 !important;
	pointer-events: auto !important;
	font-size: 15px;
	white-space: nowrap;
	touch-action: manipulation;
}

.smart-product-quick-view button.single_add_to_cart_button:hover {
	background-color: #444;
}

.smart-product-quick-view button.single_add_to_cart_button:disabled {
	opacity: 1 !important;
	cursor: pointer !important;
}

/* Hide View Cart link globally in quick view */
.smart-product-quick-view a.added_to_cart,
.smart-modal-body a.added_to_cart {
	display: none !important;
}

/* ============================================================
   Buy Now Button
   ============================================================ */
.smart-product-quick-view .smart-buy-now-btn {
	background-color: #e0457b;
	color: #fff;
	border: none;
	width: 100%;
	padding: 12px 24px;
	border-radius: 6px;
	font-weight: 600;
	font-size: 15px;
	cursor: pointer;
	text-align: center;
	transition: background-color 0.25s;
	display: block;
}

.smart-product-quick-view .smart-buy-now-btn:hover {
	background-color: #c03265;
}

.smart-product-quick-view .smart-buy-now-btn:disabled {
	background-color: #d0d0d0;
	cursor: not-allowed;
	color: #999;
}

/* ============================================================
   RESPONSIVE — Tablet (768px – 900px)
   ============================================================ */
@media (max-width: 900px) {
	.smart-modal-content {
		width: 92%;
		max-height: 88vh;
	}
	.smart-modal-body {
		padding: 18px;
	}
	.smart-pq-left {
		flex: 1 1 100%;
		min-width: auto;
		max-height: 250px;
		padding: 10px;
	}
	.smart-pq-right {
		flex: 1 1 100%;
		min-width: auto;
	}
}

/* ============================================================
   RESPONSIVE — Mobile (max 600px) — Centered Popup
   (No bottom sheet — popup opens centered on screen)
   ============================================================ */
@media (max-width: 600px) {

	/* Center popup (NOT bottom sheet) */
	.smart-modal {
		align-items: center !important;
		justify-content: center !important;
		padding: 40px 6px;
	}

	/* Centered modal box */
	.smart-modal-content {
		width: calc(100% - 12px) !important;
		max-width: 420px !important;
		max-height: calc(100vh - 80px) !important;
		margin: auto !important;
		border-radius: 14px !important;
		/* Normal fade+scale animation, no slide-up */
		animation: smart-modal-show 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
		box-shadow: 0 8px 40px rgba(0,0,0,0.25);
	}

	.smart-modal-body {
		padding: 0 0 16px 0;
	}

	.smart-product-quick-view {
		flex-direction: column;
		gap: 0;
	}

	/* Thumbnail-sized container — image shows FULLY inside (no crop) */
	.smart-pq-left {
		flex: none;
		width: 100%;
		height: 200px;          /* thumbnail height — image fully visible inside */
		padding: 10px;          /* padding so image floats inside the box */
		border-radius: 14px 14px 0 0;
		background: #f8f9fa;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		overflow: hidden;
	}

	.smart-pq-left img {
		border-radius: 8px;
		max-width: 100%;
		max-height: 100%;
		width: auto;
		height: auto;
		object-fit: contain;   /* full image visible — no crop */
		display: block;
	}

	.smart-pq-right {
		flex: none;
		width: 100%;
		padding: 14px 14px 10px;
	}

	/* Typography */
	.smart-pq-title {
		font-size: 16px !important;
		margin-bottom: 5px !important;
		line-height: 1.35;
		color: #111;
		font-weight: 700;
	}

	.smart-pq-price {
		font-size: 15px !important;
		margin-bottom: 12px !important;
	}

	.smart-pq-price del {
		font-size: 13px;
		color: #999;
	}

	/* Attribute table */
	.smart-product-quick-view table.variations {
		margin-bottom: 12px;
	}

	.smart-product-quick-view table.variations tr {
		display: block !important;
		margin-bottom: 8px !important;
	}

	.smart-product-quick-view table.variations td,
	.smart-product-quick-view table.variations th {
		display: block !important;
		padding: 0 !important;
		border: none !important;
		background: transparent !important;
	}

	.smart-product-quick-view table.variations td.label,
	.smart-product-quick-view table.variations th.label {
		padding-bottom: 5px !important;
		font-size: 12px !important;
		font-weight: 700 !important;
		color: #555 !important;
		text-align: left !important;
		/* Divider width controlled by admin ::after pseudo — no direct border here */
	}

	.smart-product-quick-view table.variations td.value,
	.smart-product-quick-view table.variations th.value {
		padding-top: 7px !important;
	}

	/* Action Row — Qty 40% / ATC 60% */
	.smart-product-quick-view .woocommerce-variation-add-to-cart {
		display: flex !important;
		flex-direction: row !important;
		flex-wrap: wrap !important;
		gap: 8px !important;
		align-items: stretch;
		margin-top: 14px !important;
	}

	/* Qty wrapper — 40% */
	.smart-product-quick-view .quantity {
		flex: 0 0 40% !important;
		max-width: 40% !important;
		display: flex !important;
	}

	.smart-product-quick-view .smart-qty-wrapper {
		flex: 1;
		width: 100%;
		height: 46px;           /* Fixed height matching Buy Now / ATC */
		padding: 0 !important;             /* Remove padding so children fill height */
		border-radius: 10px !important;
		border-color: #ddd;
		align-items: stretch !important;
	}

	/* Plus / Minus — 3px left/right padding for clear visibility */
	.smart-product-quick-view .smart-qty-wrapper .smart-qty-btn {
		width: auto;
		min-width: 28px;
		padding: 0 8px !important;
		font-size: 20px;
		font-weight: 700;
		background: #f5f5f5 !important;
		border: none !important;
		outline: none !important;
		height: auto !important; /* Let stretch do the work */
		line-height: 1;
	}

	.smart-qty-wrapper input.qty {
		font-size: 15px;
		height: 100%;
		padding: 0 4px;
	}

	/* ATC Button — 60% */
	.smart-product-quick-view button.single_add_to_cart_button {
		flex: 0 0 calc(60% - 8px) !important;
		max-width: calc(60% - 8px) !important;
		min-width: 0 !important;
		height: auto !important;          /* auto height — driven by padding */
		padding: 7px 8px !important;      /* 7px top & bottom */
		border-radius: 10px !important;
		font-size: 14px !important;
		font-weight: 700 !important;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	/* Buy Now Button — full width below */
	.smart-product-quick-view .smart-buy-now-wrap {
		flex: 0 0 100% !important;
		width: 100% !important;
	}

	.smart-product-quick-view .smart-buy-now-btn {
		height: 46px !important;
		padding: 0 !important;
		font-size: 14px !important;
		border-radius: 10px !important;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	/* Close Button */
	.smart-modal-close {
		position: absolute;
		right: 12px;
		top: 12px;
		background: rgba(255, 255, 255, 0.95);
		color: #111;
		width: 32px;
		height: 32px;
		line-height: 32px;
		font-size: 18px;
		box-shadow: 0 2px 8px rgba(0,0,0,0.15);
		z-index: 10;
	}
}
