/* Shoppable Video for WooCommerce — frontend styles */

/* Defined on :root (not just .svp-feed) because the shared product modal
 * (#svp-modal-overlay) is printed once in the footer as a sibling of the
 * feed containers, not nested inside them — a variable scoped only to
 * .svp-feed would not cascade into it. */
:root {
	--svp-accent: #1e6b52;
	--svp-radius: 12px;
}

/* Optional heading/subheading printed above the feed by
 * SVP_Shortcode::render_heading_block() — only appears when the shortcode
 * attribute / Elementor field / Gutenberg attribute is actually filled in,
 * so this never changes the layout of existing feeds. Elementor's Style
 * tab "Heading" section overrides color/size/alignment directly via
 * higher-specificity inline selectors; the shortcode and Gutenberg block
 * just use these defaults. */
.svp-feed-heading-wrap {
	margin: 0 0 16px;
}
.svp-feed-heading {
	margin: 0 0 4px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	color: #1e1e1e;
}
.svp-feed-subheading {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: #6b6b6b;
}

.svp-feed {
	margin: 24px 0;
	box-sizing: border-box;
}
.svp-feed *,
.svp-feed *::before,
.svp-feed *::after {
	box-sizing: border-box;
}

/* --- Carousel layout ---
 * --svp-cols is set per-instance (and per-breakpoint via media queries) by
 * templates/carousel.php based on the columns/columns_tablet/columns_mobile
 * settings — this drives how many cards are visible at once. */
.svp-feed-carousel {
	--svp-cols: 3;
}
.svp-carousel-viewport {
	position: relative;
}
.svp-feed-carousel .svp-carousel-track {
	display: flex;
	gap: 14px;
	overflow-x: auto;
	scroll-snap-type: x proximity;
	padding-bottom: 2px;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
	/* Native scrollbar is replaced by the dot navigation below the track. */
	scrollbar-width: none;
	-ms-overflow-style: none;
}
.svp-feed-carousel .svp-carousel-track::-webkit-scrollbar {
	display: none;
}
.svp-feed-carousel .svp-video-card {
	flex-grow: 0 !important;
	flex-shrink: 0 !important;
	flex-basis: calc( ( 100% - ( var( --svp-cols, 3 ) - 1 ) * 14px ) / var( --svp-cols, 3 ) ) !important;
	width: auto !important;
	scroll-snap-align: start;
}

/* Prev/next nav arrows.
 * --svp-arrow-bg / --svp-arrow-color / --svp-arrow-hover-bg / --svp-arrow-hover-color
 * are only ever set inline by the Elementor widget's Style tab (see
 * class-svp-elementor-widget.php); the shortcode and Gutenberg block never
 * set them, so the var() fallbacks below (the original hardcoded look) are
 * what those contexts use. Hover fallbacks default to the same as the
 * resting state (no visible change) unless a hover color is explicitly set. */
.svp-carousel-arrow {
	position: absolute;
	top: 40%;
	transform: translateY(-50%);
	width: 36px !important;
	height: 36px !important;
	border-radius: 50%;
	background: var( --svp-arrow-bg, #fff );
	border: none;
	color: var( --svp-arrow-color, #1e1e1e ) !important;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	line-height: 0;
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.22 );
	z-index: 5;
	transition: background-color 0.15s ease, color 0.15s ease;
}
.svp-carousel-arrow:hover,
.svp-carousel-arrow:focus,
.svp-carousel-arrow:focus-visible {
	background: var( --svp-arrow-hover-bg, var( --svp-arrow-bg, #fff ) ) !important;
	color: var( --svp-arrow-hover-color, var( --svp-arrow-color, #1e1e1e ) ) !important;
}
/* Clicking the arrow leaves it focused (not just briefly ":hover"), and
 * plain ":focus" isn't the same as ":focus-visible" — clicking with a
 * mouse focuses the button but many browsers don't treat that as
 * "focus-visible", so the ":focus-visible" rule above alone never matched
 * after a click and the theme's own default focused-button background
 * (blue on this theme) showed through instead of the styled color. Adding
 * plain ":focus" (and forcing background with !important, same reasoning
 * as the hotspot button fix) closes that gap so the arrow keeps its
 * chosen/hover color after every click, not just while the mouse hovers. */
.svp-carousel-arrow svg {
	width: 18px !important;
	height: 18px !important;
	min-width: 18px;
	flex-shrink: 0;
	stroke: currentColor;
	fill: none;
}
.svp-carousel-prev {
	left: -14px;
}
.svp-carousel-next {
	right: -14px;
}
@media ( max-width: 600px ) {
	/* Previously hidden entirely on mobile ("rely on native swipe"), but
	 * that meant "Continue Scrolling" (infinite loop) never worked on
	 * touch devices — native swipe just stops at the last card, it has no
	 * concept of looping. The arrow-click handler already loops correctly
	 * (see bindCarouselArrows() in frontend.js), so the fix is simply to
	 * keep the arrows reachable on mobile too — swipe still works for
	 * normal scrolling, the arrows are just an extra always-available way
	 * to advance/loop. Pulled slightly inward (-14px -> 2px) so they stay
	 * within the viewport instead of overflowing off narrow screens. */
	.svp-carousel-arrow {
		width: 32px !important;
		height: 32px !important;
	}
	.svp-carousel-prev {
		left: 2px;
	}
	.svp-carousel-next {
		right: 2px;
	}
}

/* Pagination dots — replaces the native horizontal scrollbar. Built/updated
 * dynamically by frontend.js since the number of pages depends on how many
 * cards are visible at the current breakpoint. --svp-dot-color /
 * --svp-dot-active-color / --svp-dot-size follow the same "Elementor-only
 * inline override, sane fallback otherwise" pattern as the arrow colors. */
.svp-carousel-dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 12px;
}
.svp-carousel-dot {
	width: var( --svp-dot-size, 8px );
	height: var( --svp-dot-size, 8px );
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var( --svp-dot-color, #d6d6d6 );
	cursor: pointer;
	transition: background-color 0.2s ease, width 0.2s ease;
}
.svp-carousel-dot.is-active {
	background: var( --svp-dot-active-color, var( --svp-accent, #1e6b52 ) );
	width: calc( var( --svp-dot-size, 8px ) * 2.2 );
	border-radius: 999px;
}

/* --- Inline (vertical TikTok-style) layout --- */
.svp-feed-inline {
	display: flex;
	flex-direction: column;
	gap: 18px;
	max-width: 420px;
	margin-left: auto;
	margin-right: auto;
}
.svp-feed-inline .svp-video-card {
	width: 100%;
}

/* --- Video card --- */
.svp-video-card {
	position: relative;
	border-radius: var(--svp-radius, 12px);
	overflow: hidden;
	background: #000;
	cursor: pointer;
}
.svp-video-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 9 / 16;
	background: #111;
}
.svp-video-el {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.svp-play-btn {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	color: #1e1e1e !important;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	line-height: 0;
}
.svp-play-btn svg {
	width: 16px !important;
	height: 16px !important;
	min-width: 16px;
	flex-shrink: 0;
	margin-left: 2px; /* optically center the play triangle */
}
.svp-video-card.svp-playing .svp-play-btn {
	display: none;
}
.svp-hotspot-btn {
	position: absolute;
	bottom: 12px;
	right: 12px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--svp-hotspot-bg, #fff) !important;
	border: none;
	color: var(--svp-hotspot-color, #1e1e1e) !important;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
	line-height: 0;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
/* Without an explicit hover/focus state, this <button> fell back to the
 * active theme's own global button:hover color (blue on this theme) as
 * soon as the cursor touched it — the base rule only covered the resting
 * state. Explicit hover/focus rules (with their own overridable CSS vars,
 * defaulting back to the resting-state colors) close that gap and give
 * Elementor something to hook "Icon/Background Hover Color" into. */
.svp-hotspot-btn:hover,
.svp-hotspot-btn:focus,
.svp-hotspot-btn:focus-visible {
	background: var(--svp-hotspot-hover-bg, var(--svp-hotspot-bg, #fff)) !important;
	color: var(--svp-hotspot-hover-color, var(--svp-hotspot-color, #1e1e1e)) !important;
}
.svp-hotspot-btn svg {
	width: 18px !important;
	height: 18px !important;
	min-width: 18px;
	flex-shrink: 0;
}
.svp-play-btn svg,
.svp-hotspot-btn svg {
	stroke: currentColor;
	fill: none;
}
.svp-play-btn svg path {
	fill: currentColor;
}
.svp-hotspot-count {
	position: absolute;
	top: -4px;
	right: -4px;
	background: var(--svp-accent, #1e6b52);
	color: #fff;
	font-size: 10px;
	line-height: 1;
	padding: 3px 5px;
	border-radius: 999px;
}
.svp-video-price-badge {
	position: absolute;
	top: 10px;
	left: 10px;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	font-size: 12px;
	padding: 4px 8px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.svp-combo-label {
	background: var(--svp-accent, #1e6b52);
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 10px;
	text-transform: uppercase;
}

/* --- Modal --- */
.svp-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
.svp-modal {
	background: #fff;
	width: 100%;
	max-width: 860px;
	max-height: 90vh;
	border-radius: 14px;
	overflow: hidden;
	display: flex;
	position: relative;
}
@media (max-width: 640px) {
	/* Root cause of the mobile "everything disappears" bug: with
	 * flex-direction:column, .svp-modal-video-wrap's flex-basis:42% needed
	 * a definite height on its parent (.svp-modal) to resolve against —
	 * but .svp-modal's height was auto, so the percentage fell back to the
	 * video's intrinsic size, which could blow up to fill (or exceed) the
	 * whole viewport. Combined with .svp-modal-overlay centering vertically,
	 * an oversized modal got pushed so its top (with the close button) sat
	 * above the visible viewport — leaving only the video on screen, no
	 * close button, no product list. Fixed by giving every level a
	 * definite height instead of a percentage of an auto one. */
	.svp-modal-overlay {
		align-items: flex-start;
		padding: 0;
	}
	.svp-modal {
		flex-direction: column;
		width: 100%;
		max-width: 100%;
		height: 100vh;
		max-height: 100vh;
		border-radius: 0;
	}
	.svp-modal-video-wrap {
		flex: 0 0 auto;
		height: 38vh;
		max-height: 38vh;
	}
	.svp-modal-body {
		flex: 1 1 auto;
		min-height: 0; /* lets this flex child scroll instead of growing to fit its content */
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}
	.svp-modal-close {
		z-index: 3;
	}
}
.svp-modal-close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: none;
	background: rgba(255, 255, 255, 0.9);
	font-size: 20px;
	line-height: 1;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}
.svp-modal-video-wrap {
	flex: 0 0 42%;
	background: #000;
}
.svp-modal-video {
	width: 100%;
	height: 100%;
	max-height: 90vh;
	object-fit: contain;
	display: block;
}
.svp-modal-body {
	flex: 1;
	padding: 20px;
	overflow-y: auto;
}
.svp-modal-title {
	margin: 0 0 12px;
	font-size: 16px;
}
.svp-modal-products {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.svp-modal-product {
	display: flex;
	align-items: center;
	gap: 10px;
	border: 1px solid #eee;
	border-radius: 10px;
	padding: 10px;
}
.svp-modal-product img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
}
.svp-modal-product-info {
	flex: 1;
	min-width: 0;
}
.svp-modal-product-name {
	font-weight: 600;
	font-size: 13px;
	margin: 0 0 2px;
}
.svp-modal-product-price {
	font-size: 13px;
	color: #555;
}
.svp-modal-product-add {
	flex-shrink: 0;
}

/* Forced with !important throughout: the plugin's buttons/links must look
 * identical regardless of the active theme's default <button>/<a> styling
 * (text-transform, padding, letter-spacing, font-family all commonly get
 * overridden by WooCommerce themes otherwise — see the icon-visibility fix
 * above for the same root cause). */
.svp-btn {
	all: unset;
	box-sizing: border-box !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 6px !important;
	padding: 9px 16px !important;
	margin: 0 !important;
	border-radius: 8px !important;
	border: none !important;
	background: var(--svp-accent, #1e6b52) !important;
	color: #fff !important;
	font-family: inherit !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	line-height: normal !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	text-align: center !important;
	cursor: pointer !important;
	text-decoration: none !important;
	white-space: nowrap !important;
	vertical-align: middle !important;
}
.svp-btn:hover,
.svp-btn:focus,
.svp-btn:active {
	opacity: 0.92 !important;
	color: #fff !important;
	text-decoration: none !important;
}
.svp-btn[disabled] {
	opacity: 0.6 !important;
	cursor: not-allowed !important;
}
.svp-btn-small {
	padding: 6px 10px !important;
	font-size: 12px !important;
}
.svp-btn-whatsapp {
	background: #25d366 !important;
}
/* .svp-btn's own `display: inline-flex !important` above wins over jQuery's
 * .hide()/.show() (which just toggles an inline `display:none` — !important
 * in a stylesheet beats a non-!important inline style). Without this, the
 * WhatsApp button stayed visible/clickable even when JS tried to hide it
 * (e.g. WhatsApp disabled for that video) — worse, it could still carry the
 * wa.me link from whichever video was last opened. JS now toggles this
 * class instead of relying on .show()/.hide(). */
.svp-btn-hidden {
	display: none !important;
}
.svp-modal-actions {
	margin-top: 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.svp-modal-cart-msg {
	margin-top: 10px;
	font-size: 13px;
	color: var(--svp-accent, #1e6b52);
	min-height: 16px;
}
.svp-out-of-stock {
	color: #b32d2e;
	font-size: 12px;
}
.svp-empty-notice {
	padding: 16px;
	background: #fff8e5;
	border: 1px solid #f0dca0;
	border-radius: 8px;
}

/* --- Front-end "Add Video" (staff-only) ---
 * Only ever rendered for users who pass
 * SVP_Frontend_Editor::current_user_can_edit(), so it's safe for these
 * styles to load in the shared stylesheet without an extra request. */
.svp-add-video-trigger {
	all: unset !important;
	box-sizing: border-box !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 6px !important;
	margin-top: 10px !important;
	padding: 8px 14px !important;
	border-radius: 8px !important;
	border: 1px dashed var( --svp-accent, #1e6b52 ) !important;
	background: transparent !important;
	color: var( --svp-accent, #1e6b52 ) !important;
	font-family: inherit !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	cursor: pointer !important;
}
.svp-add-video-trigger svg {
	width: 14px !important;
	height: 14px !important;
	flex-shrink: 0;
	stroke: currentColor;
	fill: none;
}
.svp-add-video-trigger:hover {
	background: rgba( 30, 107, 82, 0.08 ) !important;
}

.svp-editor-modal .svp-modal-body {
	width: 100%;
}
.svp-editor-row {
	margin-bottom: 16px;
}
.svp-editor-row label {
	display: block;
	font-weight: 600;
	font-size: 13px;
	margin-bottom: 6px;
}
.svp-required {
	color: #b32d2e;
}
.svp-editor-input {
	width: 100%;
	box-sizing: border-box;
	padding: 8px 10px;
	border: 1px solid #ddd;
	border-radius: 6px;
	font-size: 13px;
	font-family: inherit;
	margin-top: 6px;
}
.svp-editor-checkbox-label {
	display: flex !important;
	align-items: center;
	gap: 8px;
	font-weight: 400 !important;
	cursor: pointer;
}
.svp-editor-preview {
	margin-top: 8px;
}
.svp-editor-preview video,
.svp-editor-preview img {
	display: block;
	border-radius: 6px;
}
.svp-editor-search-results {
	position: relative;
}
.svp-editor-search-results .svp-search-results-list {
	list-style: none;
	margin: 4px 0 0;
	padding: 0;
	border: 1px solid #eee;
	border-radius: 6px;
	max-height: 180px;
	overflow-y: auto;
}
.svp-editor-search-results .svp-search-results-list li {
	padding: 8px 10px;
	font-size: 13px;
	cursor: pointer;
	display: flex;
	justify-content: space-between;
	gap: 8px;
}
.svp-editor-search-results .svp-search-results-list li:hover {
	background: #f7f7f7;
}
.svp-editor-search-results .svp-search-results-list li span {
	color: #777;
	white-space: nowrap;
}
.svp-editor-tag-list {
	list-style: none;
	margin: 10px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}
.svp-editor-tag-list li {
	background: #f1f5f3;
	border-radius: 999px;
	padding: 5px 10px;
	font-size: 12px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.svp-editor-tag-list .svp-remove-product {
	color: #b32d2e;
	text-decoration: none;
	font-weight: 700;
}
.svp-editor-msg {
	font-size: 13px;
	min-height: 18px;
	margin-bottom: 8px;
}
.svp-editor-msg-error {
	color: #b32d2e;
}
.svp-editor-msg-ok {
	color: var( --svp-accent, #1e6b52 );
}
