/* ===================== General ===================== */
.cew-breadcrumb-wrap { direction: ltr; }
.cew-breadcrumb-list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	list-style: none;
	margin: 0;
	padding: 0;
}
.cew-breadcrumb-item a { text-decoration: none; transition: color .25s ease; }
.cew-breadcrumb-sep-wrap { display: inline-flex; align-items: center; }
.cew-breadcrumb-separator { display: inline-flex; align-items: center; line-height: 1; }
.cew-breadcrumb-separator svg { display: block; }

/* ===================== Product Attributes ===================== */
.cew-attr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.cew-attr-row {
	display: flex;
	align-items: baseline;
	border-bottom-width: 0;
	transition: color .25s ease;
}
.cew-attr-layout-column .cew-attr-row { flex-direction: column; align-items: flex-start; }
.cew-attr-label, .cew-attr-value { display: inline-block; }

/* ===================== Category Carousel ===================== */
/*
 * --cew-slides-mobile / --cew-slides-tablet / --cew-slides-desktop and
 * --cew-space-mobile / --cew-space-tablet / --cew-space-desktop are written
 * inline on .cew-cat-carousel-wrap by the PHP widget (from the "Slides Per
 * View" / "Space Between" controls). --cew-slides / --cew-space below just
 * pick the right pair for the current breakpoint. This makes the grid size
 * itself pure CSS, calculated identically to what Swiper will calculate once
 * its JS loads — so the layout is already correct on first paint and never
 * has to visibly "jump" from 1-big-image-per-row down to N-small-per-row.
 */
.cew-cat-carousel-outer {
    position: relative;
    direction: ltr;
    width: 100%;
    --cew-slides: var(--cew-slides-mobile, 2);
    --cew-space: var(--cew-space-mobile, 10px);
}
@media (min-width: 768px) {
    .cew-cat-carousel-outer {
        --cew-slides: var(--cew-slides-tablet, 3);
        --cew-space: var(--cew-space-tablet, 12px);
    }
}
@media (min-width: 1025px) {
    .cew-cat-carousel-outer {
        --cew-slides: var(--cew-slides-desktop, 5);
        --cew-space: var(--cew-space-desktop, 16px);
    }
}
.cew-cat-carousel-wrap {
    overflow: hidden;
    width: 100%;
}
.cew-cat-swiper {
    overflow: hidden;
    width: 100%;
}
.cew-cat-swiper .swiper-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    width: 100%;
    transition: none; /* جلوگیری از انیمیشن ناخواسته در ابتدا */
}
.cew-cat-swiper .swiper-slide {
    /* عرض هر اسلاید = (عرض کل - فاصله‌های بین اسلایدها) / تعداد اسلاید در هر ردیف
       نکته مهم: از max-width استفاده نمی‌کنیم چون max-width همیشه اعمال می‌شود حتی
       روی width اینلاینی که خود Swiper بعد از لود ست می‌کند و باعث تناقض بین عرض
       واقعی و عرضی که Swiper برای محاسبات لوپ/اسکرول در نظر گرفته می‌شد -> همون
       چیزی که باعث می‌شد اسکرول فقط یک طرف کار کند و لغزش نرم نباشد. */
    flex: 0 0 calc((100% - (var(--cew-slides) - 1) * var(--cew-space)) / var(--cew-slides));
    width: calc((100% - (var(--cew-slides) - 1) * var(--cew-space)) / var(--cew-slides));
    margin-right: var(--cew-space); /* دقیقا همان مقداری که Swiper به عنوان spaceBetween اعمال می‌کند */
    min-width: 0; /* جلوگیری از سرریز */
    height: auto;
    box-sizing: border-box;
    overflow: hidden; /* برش محتوای اضافی */
}

.cew-cat-card { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    text-decoration: none; 
    text-align: center; 
    width: 100%;
    height: 100%; /* پر کردن ارتفاع اسلاید */
}
.cew-cat-image-wrap { 
    display: block; 
    width: 100%; 
    aspect-ratio: 1/1; 
    overflow: hidden; 
}
.cew-cat-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity .3s ease, transform .3s ease;
}
/* تضمین اینکه تصویر از ظرف خود بزرگ‌تر نشود */
.cew-cat-image-wrap img {
    max-width: 100%;
    height: auto;
}
.cew-cat-title { 
    display: block; 
    transition: color .25s ease; 
    margin-top: 10px;
}

.cew-swiper-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 20;
	pointer-events: auto;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: color .25s ease, background-color .25s ease;
}
.cew-swiper-prev { left: -20px; }
.cew-swiper-next { right: -20px; }
.cew-swiper-btn-disabled { opacity: .35; cursor: default; pointer-events: none; }
.cew-cat-swiper .swiper-pagination-bullet { background: currentColor; opacity: .4; }
.cew-cat-swiper .swiper-pagination-bullet-active { opacity: 1; }

/* ===================== CTA Button ===================== */
.cew-cta-wrap { display: flex; }
.cew-cta-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all .3s ease;
	text-decoration: none;
	position: relative;
}
.cew-cta-icon-wrap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: all .3s ease;
	position: relative;
}
.cew-cta-icon-onhover { display: none; }
.cew-cta-button:hover .cew-cta-icon-default { display: none; }
.cew-cta-button:hover .cew-cta-icon-onhover { display: inline-flex; }

/* ===================== Popup ===================== */
.cew-popup-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 999999;
	align-items: center;
	justify-content: center;
	padding: 20px;
}
.cew-popup-overlay.cew-popup-open {
	display: flex;
}
.cew-popup-box {
	position: relative;
	max-width: 520px;
	width: 100%;
	max-height: 90vh;
	overflow-y: auto;
	padding: 32px;
	box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.cew-popup-close {
	position: absolute;
	top: 12px;
	right: 12px;
	background: transparent;
	border: none;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	color: inherit;
}
.cew-popup-title { margin: 0 0 16px; }

/* ===================== Product Gallery ===================== */
.cew-gallery-wrap {
	display: flex;
	align-items: stretch;
	gap: 16px;
	direction: ltr;
	--cew-thumb-size: var(--cew-thumb-size-desktop, 90px);
	--cew-thumbs-count: var(--cew-thumbs-count-desktop, 4);
}
@media (max-width: 1024px) {
	.cew-gallery-wrap {
		--cew-thumb-size: var(--cew-thumb-size-tablet, 90px);
		--cew-thumbs-count: var(--cew-thumbs-count-tablet, 4);
	}
}
@media (max-width: 767px) {
	.cew-gallery-wrap {
		--cew-thumb-size: var(--cew-thumb-size-mobile, 90px);
		--cew-thumbs-count: var(--cew-thumbs-count-mobile, 3);
	}
}
.cew-gallery-wrap.cew-thumbs-left { flex-direction: row; }
.cew-gallery-wrap.cew-thumbs-right { flex-direction: row-reverse; }
.cew-gallery-thumbs-col {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}
.cew-gallery-thumbs {
	overflow: hidden;
	width: fit-content;
	flex-shrink: 0;
	/* ارتفاع ثابت و همیشه معتبر بر اساس تعداد و سایز تامبنیل‌ها؛
	   Swiper در حالت vertical بدون این، ارتفاعی نجومی محاسبه می‌کند
	   (همون باگ height: 6710886.4px) */
	height: calc((var(--cew-thumbs-count) * var(--cew-thumb-size)) + ((var(--cew-thumbs-count) - 1) * var(--cew-thumbs-gap, 12px)));
}
.cew-gallery-thumbs .swiper-wrapper {
	flex-direction: column;
	height: 100%;
}
.cew-gallery-thumb {
	cursor: pointer;
	overflow: hidden;
	flex-shrink: 0;
}
.cew-gallery-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border: 2px solid transparent;
	transition: opacity .25s ease, border-color .25s ease;
	box-sizing: border-box;
}
.cew-thumb-nav-btn {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
}
.cew-gallery-main {
	flex: 1;
	overflow: hidden;
	min-width: 0;
}
.cew-gallery-main img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

@media (max-width: 767px) {
	.cew-gallery-wrap,
	.cew-gallery-wrap.cew-thumbs-left,
	.cew-gallery-wrap.cew-thumbs-right {
		flex-direction: column-reverse !important;
	}
	.cew-gallery-thumbs-col { flex-direction: row; width: 100%; }
	.cew-gallery-thumbs .swiper-wrapper { flex-direction: row; }

	/* .cew-gallery-main normally uses flex:1 (flex-basis:0%) so it stretches
	   to match the thumbs column's height in the desktop/tablet side-by-side
	   layout. In the mobile column-reverse layout the main axis is height,
	   and a 0% flex-basis wins over the "Main Image Height" value Elementor
	   writes on the element (flex-basis takes precedence over the height
	   property for sizing), and .cew-gallery-wrap has no explicit height of
	   its own to grow into — so the main image collapsed to 0px height and
	   disappeared entirely. Restoring flex-basis:auto lets its own height
	   apply again. Width is set explicitly too: in column direction the
	   cross-axis (width) should stretch automatically, but Elementor's own
	   generated height rule for this element doesn't include a width
	   declaration, so we don't rely on inherited stretch behavior alone. */
	.cew-gallery-main {
		flex: 0 1 auto;
		width: 100%;
	}

	/* On mobile the strip runs horizontally below the main image, so its
	   box needs a width calc (how much room N thumbnails + gaps take up)
	   instead of the height calc used for the vertical desktop/tablet
	   layout. Swiper's JS also switches `direction` to horizontal at this
	   breakpoint (see widgets.js), so these two stay in sync. */
	.cew-gallery-thumbs {
		height: auto;
		width: calc((var(--cew-thumbs-count) * var(--cew-thumb-size)) + ((var(--cew-thumbs-count) - 1) * var(--cew-thumbs-gap, 12px)));
		max-width: 100%;
	}

	/* Rotate the up/down chevrons into left/right chevrons to match the
	   horizontal thumbnail strip. */
	.cew-thumb-nav-btn svg {
		transform: rotate(-90deg);
	}
}