/**
 * Custom Elementor Product Grid — cart controls.
 * Covers both button styles: the full-width bar and the minimalist circle.
 */

/*
 * The native WooCommerce `button` class is kept for AJAX/theme compatibility,
 * so these rules are written specifically enough to win against theme styles.
 */
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) .cepg-add,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	border: 0;
	box-shadow: none;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

/* Full width bar */

/*
 * Obsidian Black background, white text/icon by default — uniform across
 * every add button this plugin renders (simple, variable, icon style).
 * Hover switches to Electric Orange. --cepg-btn-bg / --cepg-btn-hover-bg /
 * --cepg-btn-color (Style_Controls, only written when a merchant actually
 * picks a color in the panel) let a single widget instance override any of
 * these independently. Text color deliberately stays constant across rest
 * and hover — white reads cleanly on both the Obsidian and Orange defaults,
 * and on most custom pairs a merchant would realistically choose.
 */
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) .cepg-add--full {
	gap: 9px;
	/* margin auto-centers once a merchant narrows --cepg-btn-width below
	   100% — a no-op at the 100% default. */
	width: var(--cepg-btn-width, 100%);
	margin-left: auto;
	margin-right: auto;
	min-height: 44px;
	padding: 10px 16px;
	/*
	 * Default flex-start, not the base .cepg-add's center: with
	 * .cepg-add__price's margin-left:auto absorbing all free space, icon+
	 * label render flush-left regardless of this value normally — it only
	 * takes visible effect once Drawer_Typography_Controls' "Center Button
	 * Content" switch also zeroes that auto margin (see .cepg-add__price
	 * below), at which point icon+label+price become one group this
	 * property can actually center.
	 */
	justify-content: var(--cepg-btn-justify, flex-start);
	background: var(--cepg-btn-bg, var(--cepg-obsidian));
	border-radius: var(--cepg-btn-radius, 10px);
	color: var(--cepg-btn-color, #ffffff);
	/*
	 * Deliberately NOT --cepg-font (Outfit): the CTA is meant to read like
	 * the rest of the storefront's own UI chrome (checkout button, etc.),
	 * which uses the theme's native system-font stack, not the plugin's
	 * imported display face. --cepg-btn-font-family stays merchant-
	 * overridable like every other --cepg-btn-* custom property.
	 */
	font-family: var(--cepg-btn-font-family, var(--cepg-font, "Outfit", -apple-system, sans-serif));
	font-size: var(--cepg-btn-font-size, 16px);
	font-weight: 600;
	line-height: 1.2;
}

:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add--full:hover,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add--full:focus-visible {
	background: var(--cepg-btn-hover-bg, var(--cepg-orange));
	color: var(--cepg-btn-color, #ffffff);
}

/* Notify Me is a different action from Add to Bag, so on the grid card/Quick View it keeps its
   own neutral-dark treatment rather than the Orange accent. */
:is(.cepg-card, .cepg-quickview) .cepg-add--notify,
:is(.cepg-card, .cepg-quickview) a.cepg-add--notify {
	background: var(--cepg-dark);
	color: #ffffff;
}

:is(.cepg-card, .cepg-quickview) a.cepg-add--notify:hover,
:is(.cepg-card, .cepg-quickview) a.cepg-add--notify:focus-visible {
	background: var(--cepg-obsidian);
	color: #ffffff;
}

/*
 * On the product page itself, Notify Me replaces Add to Cart in the exact
 * same spot — it needs to look like the same button (obsidian rest, orange
 * hover), not a visually distinct neutral-dark variant, so it reads as one
 * consistent CTA style across simple and variable products alike.
 */
.cepg-single-picker .cepg-add--notify,
.cepg-single-picker button.cepg-add--notify {
	background: var(--cepg-obsidian);
	color: #ffffff;
}

.cepg-single-picker button.cepg-add--notify:hover,
.cepg-single-picker button.cepg-add--notify:focus-visible {
	background: var(--cepg-orange);
	color: #ffffff;
}

.cepg-add__glyph {
	flex: 0 0 auto;
	width: 17px;
	height: 17px;
}

.cepg-add__label {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Pinned to the button's trailing edge — icon+label stay centered in the remaining space. */
.cepg-add__price {
	flex: 0 0 auto;
	margin-left: var(--cepg-btn-price-margin, auto);
	padding-left: 12px;
	border-left: 1px solid rgba(255, 255, 255, 0.35);
	font-weight: 700;
	white-space: nowrap;
}

/*
 * get_display_price_html() returns WooCommerce's own markup
 * (.woocommerce-Price-amount > bdi > ...), which most themes give an
 * explicit dark color of its own — that beats our button's inherited white
 * outright, since CSS inheritance always loses to any rule declared
 * directly on the element. Forcing every level back to `inherit` is what
 * actually makes the price render white on the Orange/Obsidian button
 * instead of the theme's default text color.
 */
.cepg-add__price,
.cepg-add__price * {
	color: inherit;
}

:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add:focus-visible {
	outline: 2px solid var(--cepg-obsidian);
	outline-offset: 2px;
}

/* Loading state driven by WooCommerce's AJAX handler. */
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading {
	pointer-events: none;
}

:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading .cepg-add__label,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading .cepg-add__glyph,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading .cepg-add__price {
	visibility: hidden;
}

/*
 * A translucent-white ring with a solid leading edge in the button's own
 * text color — white by default, which reads clearly against both the
 * Orange rest state and the Obsidian hover state, so one rule covers both
 * button styles and both color states without an override.
 */
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading::after {
	content: "";
	position: absolute;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: var(--cepg-btn-color, #ffffff);
	border-radius: 50%;
	animation: cepg-spin 0.6s linear infinite;
}

:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.added {
	position: relative;
}

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

/* Success state. */
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.added .cepg-add__glyph {
	display: none;
}

:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add--full.added .cepg-add__label,
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add--full.added .cepg-add__price {
	visibility: hidden;
}

:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.added::after {
	content: "\2713";
	position: absolute;
	font-size: 18px;
	line-height: 1;
	/*
	 * No explicit color: the checkmark inherits the button's text color,
	 * which stays constant (white by default) across rest and hover — so it
	 * always stays readable against whichever background is showing,
	 * without a separate rule to keep in sync.
	 */
}

@media (prefers-reduced-motion: reduce) {
	:is(.cepg-card, .cepg-quickview, .cepg-single-picker) a.cepg-add.loading::after {
		animation-duration: 1.6s;
	}
}

/* WooCommerce injects a "View cart" link after a successful AJAX add. */
:is(.cepg-card, .cepg-quickview, .cepg-single-picker) .added_to_cart {
	display: none !important;
}

/*
 * Deliberately unscoped (not wrapped in :is(.cepg-card, .cepg-quickview, .cepg-single-picker)):
 * a last-resort net so that ANY WooCommerce add-to-cart button sharing a
 * page with this widget — not just the drawer's own — matches this widget's
 * Orange/Obsidian default instead of a theme's default accent color. Fixed
 * to the brand literals rather than --cepg-btn-bg etc.: those custom
 * properties are merchant-editable via :root (Style_Controls) and a
 * merchant who customized them presumably wants exactly that override, not
 * this hardcoded fallback, so this block intentionally doesn't reference
 * them. The !important is intentional here, for the same reason: this
 * block exists specifically to beat theme styles our own scoped rules
 * above wouldn't otherwise reach.
 *
 * Real limit: this only helps on pages where this stylesheet is actually
 * enqueued, which — by design, for performance — is only pages that contain
 * this widget. It will NOT reach woocommerce_template_single_add_to_cart()
 * on a plain single-product page with no instance of this widget on it.
 * True site-wide coverage needs either the widget present on that template
 * too, or a small always-loaded stylesheet outside this plugin's
 * conditional-loading model — ask if you want that built.
 */
.add_to_cart_button.product_type_simple,
.add_to_cart_button.product_type_variable,
.single_add_to_cart_button {
	background-color: #ff6b00 !important;
	color: #ffffff !important;
	border-color: #ff6b00 !important;
}

.add_to_cart_button.product_type_simple:hover,
.add_to_cart_button.product_type_variable:hover,
.single_add_to_cart_button:hover {
	background-color: #0d0f12 !important;
	color: #ffffff !important;
	border-color: #0d0f12 !important;
}


@media (max-width: 767px) {
	:is(.cepg-card, .cepg-quickview, .cepg-single-picker) .cepg-add--full { font-size: var(--cepg-btn-font-size, 15px); }
}
