/*
 * Quick Add Cart v1.2 — quick-add panel.
 * Fonts, text/link colours, price and the Add-to-cart button come from the active theme.
 * Tweak any --qac-* variable in Appearance > Customize > Additional CSS, e.g.
 *   .qac-panel { --qac-go-bg: #148c8d; --qac-off: #e07b24; --qac-img-w: 260px; }
 */
.qac-panel, .qac-modal {
	--qac-bg:          var(--wp--preset--color--base, #fff);
	--qac-muted:       color-mix(in srgb, currentColor 62%, transparent);
	--qac-border:      color-mix(in srgb, currentColor 15%, transparent);
	--qac-opt-border:  color-mix(in srgb, currentColor 40%, transparent);
	/* Selected size box: copies the theme's main button colours (set by JS), dark fallback */
	--qac-sel-bg:      var(--qac-theme-sel-bg, #1a1a1a);
	--qac-sel-text:    var(--qac-theme-sel-text, #fff);
	--qac-img-bg:      color-mix(in srgb, currentColor 7%, transparent);
	--qac-error:       #d63638;
	--qac-off:         #e07b24;      /* "₹X OFF" */
	--qac-go-bg:       var(--wp--preset--color--primary, var(--qac-sel-bg)); /* "Go to cart": theme colour, else selected-size colour */
	--qac-go-text:     #fff;
	--qac-price:       #5e3fde;      /* price inside the panel only */
	--qac-gap:         8px;
	--qac-img-w:       280px;        /* max width of each desktop image */
	--qac-radius:      4px;
	--qac-btn-radius:  8px;
	--qac-info-max:    470px;
}

.qac-panel {
	position: relative;
	box-sizing: border-box;
	display: block;
	width: 100%;
	margin: 0 0 24px;
	padding: 24px 32px 24px 16px;
	background: transparent;
	border: 1px solid var(--qac-border);
	font: inherit;
	list-style: none;
	clear: both;
	text-align: left;
}

/* Span the whole row in every grid type (float / flex / CSS grid themes). */
ul.products > .qac-panel,
.wc-block-product-template > .qac-panel,
.wc-block-grid__products > .qac-panel {
	float: none !important;
	width: 100% !important;
	max-width: none !important;
	flex: 0 0 100% !important;
	grid-column: 1 / -1 !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
}
.qac-spacer, .qac-pinned-hidden { display: none !important; }

/* Ad link on a search page: hide "Search Results for …" (normal searches keep it) */
body.search.qac-landing .page-title,
body.search.qac-landing .woocommerce-products-header__title,
body.search.qac-landing .hero-section:not(:has(.qac-panel)) { display: none !important; }

.qac-panel *, .qac-panel *::before, .qac-panel *::after,
.qac-modal *, .qac-modal *::before, .qac-modal *::after { box-sizing: border-box; }
.qac-panel[hidden], .qac-modal[hidden] { display: none !important; }
.qac-panel.qac-open { animation: qac-in .25s ease; }
@keyframes qac-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Loading skeleton */
.qac-panel.qac-loading { min-height: 300px; }
.qac-panel.qac-loading .qac-row { visibility: hidden; }
.qac-panel.qac-loading::after {
	content: ""; position: absolute; inset: 24px 32px 24px 16px;
	background: linear-gradient(90deg, var(--qac-img-bg) 0 30%, transparent 30% 33%, var(--qac-img-bg) 33% 63%, transparent 63% 66%, var(--qac-img-bg) 66%);
	animation: qac-pulse 1.2s ease-in-out infinite;
}
@keyframes qac-pulse { 50% { opacity: .5; } }

/* Failed load: show only the error message (never a previous product's data) */
.qac-panel.qac-failed .qac-gallery,
.qac-panel.qac-failed .qac-info > :not(.qac-actions),
.qac-panel.qac-failed .qac-add { display: none !important; }

/* ------------------------------------------------------------------ */
/* Desktop: [ slider | img 2 | img 3 ]  [ info, vertically centred ]   */
/* ------------------------------------------------------------------ */
.qac-row {
	display: grid;
	grid-template-columns: auto minmax(280px, var(--qac-info-max));
	gap: 20px;
	align-items: center;
	justify-content: start;
}

.qac-gallery {
	--qac-cols: 3;
	display: grid;
	grid-template-columns: repeat(var(--qac-cols), minmax(0, var(--qac-img-w)));
	gap: var(--qac-gap);
	min-width: 0;
}
.qac-gallery.qac-n-1 { --qac-cols: 1; }
.qac-gallery.qac-n-2 { --qac-cols: 2; }

.qac-slider { position: relative; min-width: 0; }
.qac-track {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
}
.qac-track::-webkit-scrollbar { display: none; }

.qac-panel .qac-slide,
.qac-panel .qac-fixed {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
	aspect-ratio: 3 / 4;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
	background: var(--qac-img-bg);
	opacity: 0;
	transition: opacity .3s ease;
}
.qac-panel .qac-slide { flex: 0 0 100%; scroll-snap-align: start; }
.qac-panel .is-loaded { opacity: 1; }

/* Dots: bottom-right of the slider, active one stretches into a pill */
.qac-dots {
	position: absolute; right: 10px; bottom: 14px; z-index: 2;
	display: flex; gap: 6px; align-items: center;
}
.qac-single .qac-dots, .qac-single .qac-nav { display: none !important; }
.qac-panel .qac-dot {
	width: 9px; height: 9px; min-height: 0; padding: 0; margin: 0;
	border: 1px solid rgba(0, 0, 0, .6); border-radius: 9px;
	background: rgba(255, 255, 255, .75); box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
	cursor: pointer; transition: width .3s, background .3s;
}
.qac-panel .qac-dot.is-active { width: 24px; background: #1a1a1a; border-color: #eee; }

.qac-panel .qac-nav {
	position: absolute; top: 50%; z-index: 2;
	width: 34px; height: 34px; min-height: 0; margin: -17px 0 0; padding: 0;
	border: 0; border-radius: 50%; box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
	background: rgba(255, 255, 255, .92); color: #222;
	font-size: 24px; line-height: 32px; text-align: center; cursor: pointer;
	opacity: 0; transition: opacity .2s;
}
.qac-prev { left: 8px; }
.qac-next { right: 8px; }
.qac-slider:hover .qac-nav, .qac-nav:focus-visible { opacity: 1; }

/* Info column */
.qac-info { min-width: 0; }
.qac-panel .qac-title { margin: 0 0 2px; padding: 0; font-size: 25px; line-height: 1.25; letter-spacing: .3px; }
/* Product name font (theme style: Dosis 500, capitalize, no underline) */
.qac-panel .qac-title,
.qac-panel .qac-title a {
	--theme-font-family: Dosis, Sans-Serif;
	--theme-font-weight: 500;
	--theme-text-transform: capitalize;
	--theme-text-decoration: none;
	font-family: Dosis, sans-serif !important;
	font-weight: 500 !important;
	text-transform: capitalize !important;
	text-decoration: none !important;
}
.qac-panel .qac-title a { color: inherit; }
/* Short description under the title (max 2 lines) */
.qac-sub {
	margin: 0 0 12px; color: var(--qac-muted); font-size: .95em; line-height: 1.45;
	display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.qac-sub:empty { display: none; }

.qac-price-wrap { margin: 0 0 14px; }
.qac-panel .qac-price { margin: 0; font-size: 1em; font-weight: 700; }
/* Price colour — scoped to this plugin's panel only */
.qac-panel .qac-price,
.qac-panel .qac-price > .woocommerce-Price-amount,
.qac-panel .qac-price ins,
.qac-panel .qac-price ins .woocommerce-Price-amount,
.qac-panel .qac-price > .woocommerce-Price-amount bdi,
.qac-panel .qac-price ins bdi { color: var(--qac-price) !important; }
/* WooCommerce's own "View cart" link never shows inside the panel */
.qac-panel .added_to_cart { display: none !important; }
.qac-panel .qac-price del { opacity: .5; font-weight: 400; margin: 0 6px 0 0; }
.qac-panel .qac-price ins { text-decoration: none; }
.qac-off { margin-left: 6px; color: var(--qac-off); font-weight: 600; font-size: .9em; white-space: nowrap; }
.qac-stock { margin: 4px 0 0; color: var(--qac-error); font-size: .8em; font-weight: 600; }
.qac-stock:empty { display: none; }

.qac-attr { margin-bottom: 16px; }
.qac-attr-head {
	display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
	margin-bottom: 12px; font-weight: 700; font-size: .95em;
}
.qac-attr-label.is-error { color: var(--qac-error); }
.qac-panel .qac-chart {
	width: auto; min-height: 0; margin: 0; padding: 0;
	border: 0; background: none; box-shadow: none;
	color: var(--wp--preset--color--primary, LinkText);
	font: inherit; font-size: .9em; font-weight: 400;
	text-transform: uppercase; text-decoration: underline; white-space: nowrap; cursor: pointer;
}

.qac-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.qac-opt-wrap { display: flex; flex-direction: column; align-items: center; }
.qac-panel .qac-opt {
	min-width: 50px; width: 100%; height: 34px; min-height: 0;
	margin: 0; padding: 0 10px;
	border: 1px solid var(--qac-opt-border); border-radius: var(--qac-radius);
	background: transparent; color: inherit; box-shadow: none;
	font: inherit; font-size: .9em; font-weight: 400; line-height: 1;
	text-transform: none; letter-spacing: normal;
	cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.qac-panel .qac-opt:hover:not(:disabled) { border-color: currentColor; }
/* Selected size: fixed colours + !important so theme button/hover/focus styles can't turn it white */
.qac-panel .qac-opt.is-active,
.qac-panel .qac-opt.is-active:hover,
.qac-panel .qac-opt.is-active:focus,
.qac-panel .qac-opt.is-active:focus-visible,
.qac-panel .qac-opt.is-active:active {
	background: var(--qac-sel-bg) !important;
	border-color: var(--qac-sel-bg) !important;
	color: var(--qac-sel-text) !important;
	opacity: 1 !important;
	text-decoration: none !important;
}
/* Unselected: also guard against theme focus/active styles */
.qac-panel .qac-opt:not(.is-active):focus,
.qac-panel .qac-opt:not(.is-active):active {
	background: transparent !important;
	color: inherit !important;
}
.qac-panel .qac-opt:focus-visible { outline: 2px solid var(--qac-sel-bg); outline-offset: 2px; }
/* Out of stock: grey box with a diagonal line corner to corner */
.qac-panel .qac-opt:disabled,
.qac-panel .qac-opt:disabled:hover {
	opacity: 1 !important;
	color: #a8a8a8 !important;
	border-color: #cfcfcf !important;
	font-weight: 400 !important;
	background: linear-gradient(to top right, transparent calc(50% - .75px), #b4b4b4 50%, transparent calc(50% + .75px)) !important;
	text-decoration: none !important;
	cursor: not-allowed;
}
/* Pinned / ad-link panel at the top only: in-stock sizes stand out clearly from sold-out ones */
.qac-panel.qac-top .qac-opt:not(:disabled):not(.is-active) {
	border-color: #1a1a1a !important;
	color: #1a1a1a !important;
	font-weight: 600 !important;
}
.qac-left { margin-top: 3px; color: var(--qac-error); font-size: .7em; font-weight: 600; line-height: 1; white-space: nowrap; }
.qac-left:empty { display: none; }

/* Add to cart: theme's .button.alt colours; "Go to cart" state in teal */
.qac-panel .qac-add {
	display: block; width: 100%; min-height: 38px; height: auto;
	margin: 4px 0 0; padding: 8px 16px; line-height: 1.2;
	border-radius: var(--qac-btn-radius);
	font-weight: 700; text-transform: uppercase; letter-spacing: .02em; text-align: center;
	cursor: pointer;
}
.qac-panel .qac-add.is-go,
.qac-panel .qac-add.is-go:hover {
	background: var(--qac-go-bg) !important; border-color: var(--qac-go-bg) !important; color: var(--qac-go-text) !important;
}
.qac-panel .qac-add:disabled { opacity: .6; cursor: not-allowed; }

.qac-msg { margin: 8px 0 0; font-size: .9em; }
.qac-msg:empty { display: none; }
.qac-msg.is-error { color: var(--qac-error); }

.qac-shake { animation: qac-shake .3s; }
@keyframes qac-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ------------------------------------------------------------------ */
/* Tablet: slider + 1 fixed image                                     */
/* ------------------------------------------------------------------ */
@media (max-width: 1100px) {
	.qac-gallery.qac-n-3 { --qac-cols: 2; }
	.qac-panel .qac-fixed-3 { display: none; }
}

/* ------------------------------------------------------------------ */
/* Mobile: [ slider | info ]  then full-width button                   */
/* ------------------------------------------------------------------ */
@media (max-width: 767px) {
	/* Measured from the mobile reference (393px wide) */
	.qac-panel { padding: 12px 10px 14px; border-left: 0; border-right: 0; }
	.qac-panel.qac-loading::after { inset: 12px 10px 14px; }
	.qac-row {
		grid-template-columns: 120px minmax(0, 1fr);
		grid-template-rows: auto auto auto 1fr auto;
		column-gap: 9px; row-gap: 0;
		align-items: start;
	}
	.qac-gallery { --qac-cols: 1 !important; grid-column: 1; grid-row: 1 / 5; }
	.qac-panel .qac-fixed { display: none; }
	.qac-info { display: contents; }
	.qac-info > * { grid-column: 2; }
	.qac-actions { grid-column: 1 / -1; grid-row: 5; margin-top: 20px; }

	/* Image 120 x 160 */
	.qac-panel .qac-slide { border-radius: 0; }
	.qac-dots { right: 6px; bottom: 8px; gap: 4px; }
	.qac-panel .qac-dot { width: 6px; height: 6px; }
	.qac-panel .qac-dot.is-active { width: 16px; }
	.qac-panel .qac-nav { display: none; }

	/* Text */
	.qac-panel .qac-title { margin: 0 0 1px; padding-right: 0; font-size: 18px; line-height: 1.3; letter-spacing: .2px; }
	.qac-panel .qac-sub { margin: 0 0 8px; font-size: 12px; line-height: 1.35; }
	.qac-price-wrap { margin: 0 0 10px; }
	.qac-panel .qac-price { font-size: 13px; margin-top: -8px; }
	.qac-off { font-size: 12px; }
	.qac-stock { font-size: 11px; }

	/* "Please select a size."  ……  SIZE CHART */
	.qac-attr { margin-bottom: 0; }
	.qac-attr-head { margin-top: -8px; margin-bottom: 12px; font-size: 13px; gap: 8px; }
	.qac-panel .qac-chart { font-size: 12px; }

	/* Size boxes: 42 x 24, 4 per row, 8px across / 16px between rows */
	.qac-opts { display: grid; grid-template-columns: repeat(4, 42px); column-gap: 8px; row-gap: 16px; margin-top: -8px; }
	.qac-opt-wrap { position: relative; }
	.qac-panel .qac-opt { width: 42px; min-width: 0; height: 24px; padding: 0; font-size: 12px; border-radius: 4px; }
	/* "N Left" sits inside the row gap so it doesn't push rows apart */
	.qac-left { position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px; font-size: 9px; text-align: center; }

	/* Add to cart: 40px tall, full width */
	.qac-panel .qac-add { min-height: 36px; margin: 0; padding: 6px 12px; border-radius: 10px; font-size: 14px; line-height: 1.2; }
	.qac-msg { font-size: 12px; }
}
/* Very small phones (≤359px): shrink slightly so 4 boxes still fit */
@media (max-width: 359px) {
	.qac-row { grid-template-columns: 100px minmax(0, 1fr); }
	.qac-opts { grid-template-columns: repeat(4, 38px); column-gap: 6px; }
	.qac-panel .qac-opt { width: 38px; font-size: 11px; }
}
@media (hover: none) { .qac-panel .qac-nav { display: none; } }

/* ------------------------------------------------------------------ */
/* Size chart popup                                                    */
/* ------------------------------------------------------------------ */
html.qac-modal-lock { overflow: hidden; }
.qac-modal { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.qac-modal-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); animation: qac-fade .2s ease; }
.qac-modal-box {
	position: relative; display: flex; flex-direction: column;
	width: 100%; max-width: 760px; max-height: 90vh;
	background: var(--qac-bg); color: inherit;
	border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
	animation: qac-in .25s ease;
}
.qac-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--qac-border); }
.qac-modal-head h3 { margin: 0; font-size: 1.1em; }
.qac-modal .qac-modal-close {
	width: auto; min-height: 0; margin: 0; padding: 0 6px;
	border: 0; background: none; box-shadow: none; color: inherit;
	font-size: 28px; line-height: 1; cursor: pointer;
}
.qac-modal-body { overflow: auto; padding: 16px 18px; }
.qac-modal-body img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.qac-modal-body iframe { display: block; width: 100%; height: 70vh; border: 0; }

/* Size guide from the Size Guide plugin */
.qac-guide h4 { margin: 16px 0 8px; font-size: 1em; }
.qac-guide h4:first-child { margin-top: 0; }
.qac-guide-text { margin-bottom: 12px; font-size: .95em; }
.qac-guide-text > :last-child { margin-bottom: 0; }
.qac-guide { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.qac-guide-table { overflow-x: auto; margin: 0 0 16px; -webkit-overflow-scrolling: touch; }
/* Covers our tables and the Size Guide plugin's own tables */
.qac-guide table { width: 100%; min-width: 300px; margin: 0 0 16px; border-collapse: collapse; font-size: 14px; text-align: center; }
.qac-guide th,
.qac-guide td { padding: 8px 10px; border: 1px solid var(--qac-border); white-space: nowrap; }
.qac-guide th, .qac-guide thead td { background: color-mix(in srgb, currentColor 6%, transparent); font-weight: 700; }
.qac-guide tbody tr:nth-child(even) td { background: color-mix(in srgb, currentColor 3%, transparent); }
.qac-guide caption { caption-side: bottom; padding-top: 6px; font-size: 12px; opacity: .7; }
/* Size Guide plugin markup: show content it normally hides until its own popup opens */
.qac-guide .mfp-hide, .qac-guide [style*="display:none"], .qac-guide [style*="display: none"] { display: block !important; }
.qac-guide a.open-popup-link, .qac-guide .ct_size_guide_btn, .qac-guide button { display: none !important; }
.qac-guide-img img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
@keyframes qac-fade { from { opacity: 0; } }

@media (max-width: 767px) {
	.qac-modal { align-items: flex-end; padding: 0; }
	.qac-modal-box { max-width: none; max-height: 88vh; border-radius: 14px 14px 0 0; animation: qac-up .25s ease; }
	@keyframes qac-up { from { transform: translateY(100%); } }
}
