/* ==========================================================================
   Cargo Pilot — Cargo Single Product Image  v1.0.2 Beta
   ========================================================================== */

/* ---- Wrapper ---- */
.cp-spi-wrapper {
	display: flex;
	flex-direction: column;
	width: 100%;
}

/* ============================================================
   MAIN PREVIEW
   ============================================================ */
.cp-spi-preview {
	position: relative;
	width: 100%;
	overflow: hidden;
	line-height: 0;
	/* default: auto mode, height driven by image */
}

/* ------ AUTO MODE: natural image dimensions ------- */
.cp-spi-preview[data-mode="auto"] .cp-spi-preview-item {
	display: none;
	width: 100%;
}

.cp-spi-preview[data-mode="auto"] .cp-spi-preview-item.cp-active {
	display: block;
}

.cp-spi-preview[data-mode="auto"] img,
.cp-spi-preview[data-mode="auto"] video {
	display: block;
	width: 100%;
	height: auto;
	/* natural height — no forced crop */
}

/* ------ RATIO MODE: container has aspect-ratio; image fills + crops ------ */
/* aspect-ratio is set inline via PHP                                         */
.cp-spi-preview[data-mode="ratio"] {
	overflow: hidden;
}

.cp-spi-preview[data-mode="ratio"] .cp-spi-preview-item {
	/* All items sit in the same absolute slot; hidden ones are display:none  */
	position: absolute;
	inset: 0;
	display: none;
	width: 100%;
	height: 100%;
}

.cp-spi-preview[data-mode="ratio"] .cp-spi-preview-item.cp-active {
	display: block;
}

.cp-spi-preview[data-mode="ratio"] img,
.cp-spi-preview[data-mode="ratio"] video {
	display: block;
	width: 100%;
	height: 100%;
	/* fill the aspect-ratio container  */
	object-fit: cover;
	/* crop to fill — centred by default */
}

/* ============================================================
   BOTTOM ROW: thumbnails + nav
   ============================================================ */
.cp-spi-bottom {
	display: flex;
	align-items: stretch;
}

/* ============================================================
   STRUCTURE ORIENTATIONS via data-thumb-pos
   ============================================================ */

/* ---- HORIZONTAL: Bottom (Default) & Top ---- */
.cp-spi-wrapper[data-thumb-pos="bottom"],
.cp-spi-wrapper[data-thumb-pos="top"] {
	flex-direction: column;
}

.cp-spi-wrapper[data-thumb-pos="top"] {
	flex-direction: column-reverse;
	/* Swap preview and thumbnails */
}

.cp-spi-wrapper[data-thumb-pos="bottom"] .cp-spi-bottom {
	flex-direction: row;
	margin-top: var(--cp-spi-gap, 14px);
}

.cp-spi-wrapper[data-thumb-pos="top"] .cp-spi-bottom {
	flex-direction: row;
	margin-bottom: var(--cp-spi-gap, 14px);
}

/* ---- Scrollable thumbnail strip ---- */
.cp-spi-thumbnails-wrap {
	flex: 1 1 auto;
	min-width: 0;
	/* CRITICAL: prevents flex child from overflowing */
	overflow: hidden;
	/* clips thumbnails to the reserved width */
}

.cp-spi-thumbnails {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 10px;
	/* overridden by Elementor spacing control */
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}

/* ---- Individual thumbnail ---- */
.cp-spi-thumb {
	flex: 0 0 auto;
	cursor: pointer;
	overflow: hidden;
	/* clips image to border-radius — no gap */
	position: relative;
	line-height: 0;
	box-sizing: border-box;
	transition: opacity 0.2s ease;
}

.cp-spi-thumb:hover {
	opacity: 0.8;
}

/* Active indicator: outline is independent of Elementor border control */
.cp-spi-thumb.cp-active {
	outline: 2px solid #333;
	outline-offset: -2px;
}

.cp-spi-thumb img,
.cp-spi-thumb video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Video play badge */
.cp-spi-thumb-video-badge {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.35);
	color: #fff;
	pointer-events: none;
}

/* ============================================================
   NAVIGATION BUTTONS
   ============================================================ */
.cp-spi-nav {
	flex: 0 0 auto;
	/* reserves its own space — thumbnails never overlap */
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-left: 10px;
}

.cp-spi-nav-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border: none;
	outline: none;
	background: #f0f0f0;
	color: #333;
	border-radius: 6px;
	font-size: 14px;
	padding: 0;
	line-height: 1;
	flex-shrink: 0;
	/* Minimum size so nav always reserves space before JS runs */
	min-width: 36px;
	min-height: 36px;
	/* width/height also set by JS to align with thumbnail height */
	box-sizing: border-box;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cp-spi-nav-btn i,
.cp-spi-nav-btn svg {
    display: block;
    pointer-events: none;
    color: inherit;
    fill: currentColor;
}

/* ============================================================
   EDITOR PLACEHOLDER
   ============================================================ */
.cp-spi-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	background: #f5f5f5;
	border: 2px dashed #ccc;
	color: #888;
	font-size: 14px;
	font-family: sans-serif;
	border-radius: 6px;
	width: 100%;
	box-sizing: border-box;
	text-align: center;
	padding: 20px;
}

.cp-spi-thumb-placeholder {
	flex: 0 0 auto;
	background: #e5e5e5;
	border-radius: 6px;
}