/**
 * Minimal frontend styling for the Dimitra sample button.
 * Deliberately avoids fixed colors that would fight the Astra theme;
 * inherits WooCommerce button classes wherever possible.
 */

.dimitra-sample-block {
	margin: 1em 0;
	clear: both;
}

/**
 * Grid-card variant. Sits as a full-width block directly beneath the card's
 * add-to-cart button. Width is forced to 100% because the button is inserted
 * as a sibling of Elementor's add-to-cart widget, whose parent container is a
 * flex column - an inline-block would otherwise collapse to its text width.
 */
.dimitra-sample-block--compact {
	display: block;
	width: 100%;
	margin: 0.5em 0 0;
	clear: both;
}

.dimitra-sample-block--compact .dimitra-sample-button {
	display: block;
	width: 100%;
	text-align: center;
	font-size: 0.85em;
	padding-top: 0.6em;
	padding-bottom: 0.6em;
}

.dimitra-sample-block--compact .dimitra-sample-message {
	display: block;
	font-size: 0.8em;
	margin-top: 0.35em;
	text-align: center;
}

/* The staging container is emptied by the placement script; keep it inert
   even if a stylesheet somewhere overrides [hidden]. */
#dimitra-sample-staging {
	display: none !important;
}

/**
 * Card corner clipping.
 *
 * The Elementor loop card carries --border-radius:8px on its inner
 * container (.e-con, the element that also paints the grey background) but
 * never sets `overflow`, and drops its horizontal padding to 0 below 767px.
 * The product image therefore sits flush to the card edge with square
 * corners spilling past the card's rounded ones. The container is also
 * justify-content:flex-end, so adding the sample button raises the content
 * stack and presses the image into the rounded top edge - which is what
 * makes the long-standing mismatch suddenly visible.
 *
 * Clipping the radiused container to its own radius fixes it. Scoped to
 * cards that actually contain a sample button (:has, plus a JS-set class
 * fallback for browsers without :has support) so no unrelated grid or
 * page section is affected.
 */
.e-loop-item .e-con:has( .dimitra-sample-block ),
.e-loop-item .e-con.dimitra-sample-card {
	overflow: hidden;
}

/* Keep the image itself inside the box in case a nested wrapper sets its
   own width, which is what lets it bleed past the padding edge. */
.e-loop-item .e-con:has( .dimitra-sample-block ) .elementor-widget-theme-post-featured-image img,
.e-loop-item .e-con.dimitra-sample-card .elementor-widget-theme-post-featured-image img {
	display: block;
	max-width: 100%;
	height: auto;
}

.dimitra-sample-description {
	font-size: 0.9em;
	opacity: 0.85;
	margin-bottom: 0.5em;
}

/**
 * Match the site's own add-to-cart button (.sagor-cart-btn, rendered by the
 * theme's custom cart shortcode) so the sample button reads as part of the
 * same control group rather than falling back to the theme's default blue.
 *
 * Values mirror the theme's inline rule exactly: background #d39a1e,
 * hover #c88d12, white text, 4px radius. The custom properties below let a
 * site owner retheme both states without editing this file.
 */
.dimitra-sample-block {
	--dimitra-sample-bg: #d39a1e;
	--dimitra-sample-bg-hover: #c88d12;
	--dimitra-sample-fg: #fff;
}

.dimitra-sample-button {
	display: inline-block;
	cursor: pointer;
	line-height: 1.4;
}

/**
 * Astra styles generic `.button` elements via a long multi-selector chain
 * (`.woocommerce button.button.alt`, `[CLASS*="wc-block"] ...`) that sets
 * background-color from --ast-global-color-0 - the theme blue seen before
 * this rule existed. The doubled class below outranks it on specificity
 * without resorting to !important, so a site owner can still override this
 * from the Customizer or a child theme.
 */
.dimitra-sample-block .dimitra-sample-button.dimitra-sample-button {
	background: var( --dimitra-sample-bg );
	background-color: var( --dimitra-sample-bg );
	border: 0;
	border-radius: 4px;
	color: var( --dimitra-sample-fg );
}

.dimitra-sample-block .dimitra-sample-button.dimitra-sample-button:hover,
.dimitra-sample-block .dimitra-sample-button.dimitra-sample-button:focus {
	background: var( --dimitra-sample-bg-hover );
	background-color: var( --dimitra-sample-bg-hover );
	color: var( --dimitra-sample-fg );
}

.dimitra-sample-button:focus-visible,
.dimitra-sample-button:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.dimitra-sample-button.loading {
	opacity: 0.6;
	pointer-events: none;
}

.dimitra-sample-message {
	display: block;
	margin-top: 0.5em;
	font-size: 0.9em;
}

.dimitra-sample-message.success {
	color: #2a7a2a;
}

.dimitra-sample-message.error {
	color: #c0392b;
}

.dimitra-shipping-progress {
	margin-bottom: 1em;
}

.dimitra-sample-footer-fallback {
	margin: 1em 0;
}

.dimitra-shipping-progress:empty {
	display: none;
	margin: 0;
}

@media ( max-width: 480px ) {
	.dimitra-sample-button {
		width: 100%;
		text-align: center;
	}
}
