/**
 * سایدبار فیلتر محصولات - استایل مدرن
 * سازگار با WooCommerce Blocks Product Filters
 */

/* ===== کانتینر اصلی سایدبار ===== */
.sidebar.single-product {
	background: #fff;
	border-radius: 12px;
	padding-right: 0 !important;
}

.sidebar-inner {
    padding: 0;
}

.sidebar .widget {
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}
.show-menu {
	right: 0 !important;
}
.sidebar-overlay {
	background: #444;
	width: 100%;
	height: 100%;
	position: fixed;
	right: 0;
	bottom: 0;
	opacity: .8;
	display: none;
}
.sidebar-overlay.is-visible {
	display: block !important;
}
/* ===== مخفی کردن دکمه overlay و تنظیم ساختار ===== */
.wc-block-product-filters__open-overlay {
    display: none !important;
}

.wc-block-product-filters__overlay {
    display: block !important;
    position: static !important;
    background: transparent !important;
}

.wc-block-product-filters__overlay-wrapper {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    background: transparent !important;
    box-shadow: none !important;
}

.wc-block-product-filters__overlay-dialog {
    padding: 0 !important;
}

.wc-block-product-filters__overlay-header,
.wc-block-product-filters__overlay-footer {
    display: none !important;
}

.wc-block-product-filters__overlay-content {
    padding: 0 !important;
}

/* ===== جستجوی محصول بالای سایدبار ===== */
.sidebar .product-search-form, .sidebar .woocommerce-product-search {
	border-radius: 20px;
}

.sidebar .product-search-form input[type="search"], .sidebar .woocommerce-product-search input[type="search"] {
	width: 100%;
	padding: 12px 40px 12px 16px;
	border: 0;
	border-radius: 20px;
	font-size: 14px;
	background: #fff;
	transition: all 0.2s;
	font-weight: 500;
	font-style: Medium;
	font-size: 12px;
	leading-trim: NONE;
	line-height: 28px;
	letter-spacing: 0%;
	text-align: right;
}

.sidebar .product-search-form input[type="search"]:focus,
.sidebar .woocommerce-product-search input[type="search"]:focus {
    border-color: #E67E22;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.1);
}

.sidebar .product-search-form::before, .sidebar .woocommerce-product-search::before {
	content: "\f002";
	font-family: "Font Awesome 5 Pro", "Font Awesome 5 Free";
	font-weight: 400;
	position: absolute;
	right: 20px;
	top: 50%;
	transform: translateY(-50%);
	color: #999;
	font-size: 14px;
}

.sidebar .product-search-form button,
.sidebar .woocommerce-product-search button {
    display: none;
}

/* ===== عنوان اصلی فیلترها ===== */
.sidebar-filter-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #EFEFEF;
}

.sidebar-filter-header svg {
    color: #666;
}

/* ===== جستجوی محصول در سایدبار ===== */
.sidebar-product-search {
	padding: 16px 0;
	position: sticky;
	top: 75px;
}
.sidebar-inner {
	top: 160px !important;
}
.sidebar-product-search .product-search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-product-search input[type="search"] {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 1px solid #E5E5E5;
    border-radius: 8px;
    font-size: 13px;
    background: #FAFAFA;
    transition: all 0.2s;
    color: #666;
}

.sidebar-product-search input[type="search"]::placeholder {
    color: #999;
}

.sidebar-product-search input[type="search"]:focus {
    border-color: #E67E22;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.1);
}

.sidebar-product-search button {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-product-search button:hover {
    color: #E67E22;
}

/* ===== مخفی کردن عنوان اصلی "فیلترها1" ===== */
.wc-block-product-filters__overlay-content > .wp-block-heading,
.wc-block-product-filters__overlay-content > h2 {
    display: none !important;
}

/* ===== استایل هر بلاک فیلتر ===== */
[data-block-name="woocommerce/product-filter-price"],
[data-block-name="woocommerce/product-filter-rating"],
[data-block-name="woocommerce/product-filter-attribute"],
[data-block-name="woocommerce/product-filter-taxonomy"],
[data-block-name="woocommerce/product-filter-status"] {
    border-bottom: 1px solid #EFEFEF;
}

[data-block-name="woocommerce/product-filter-price"]:last-child,
[data-block-name="woocommerce/product-filter-rating"]:last-child,
[data-block-name="woocommerce/product-filter-attribute"]:last-child,
[data-block-name="woocommerce/product-filter-taxonomy"]:last-child,
[data-block-name="woocommerce/product-filter-status"]:last-child {
    border-bottom: none;
}

/* ===== عنوان هر فیلتر (H3) - آکاردئون ===== */
[data-block-name="woocommerce/product-filter-price"] > .wp-block-heading, [data-block-name="woocommerce/product-filter-rating"] > .wp-block-heading, [data-block-name="woocommerce/product-filter-attribute"] > .wp-block-heading, [data-block-name="woocommerce/product-filter-taxonomy"] > .wp-block-heading, [data-block-name="woocommerce/product-filter-status"] > .wp-block-heading {
	display: flex;
	align-items: center;
	justify-content: right;
	padding: 14px 0px;
	margin: 0 !important;
	color: #333;
	cursor: pointer;
	transition: all 0.2s;
	flex-direction: row-reverse;
	font-weight: 700;
	font-size: 15px;
	line-height: 100%;
	letter-spacing: 0%;
	text-align: right;
}

/* حالت باز آکاردئون */


[data-block-name] > .wp-block-heading:hover {
    background: #FAFAFA;
}
#sidebar .sidebar-inner {
	display: flex;
	flex-direction: column;
	gap: 0px;
	background: #ffffff;
	border-radius: 18px;
	padding: 0;
	transition: all .3s ease;
}
/* ===== محتوای فیلترها - حالت آکاردئون ===== */
[data-block-name="woocommerce/product-filter-price"] > .wc-block-product-filter-price-slider,
[data-block-name="woocommerce/product-filter-rating"] > .wc-block-product-filter-checkbox-list,
[data-block-name="woocommerce/product-filter-attribute"] > .wc-block-product-filter-checkbox-list,
[data-block-name="woocommerce/product-filter-taxonomy"] > .wc-block-product-filter-checkbox-list,
[data-block-name="woocommerce/product-filter-status"] > .wc-block-product-filter-checkbox-list {
	max-height: 300px;
	padding: 15px 0;
	overflow-y: auto;
}


/* ===== لیست چک‌باکس‌ها ===== */
.wc-block-product-filter-checkbox-list fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.wc-block-product-filter-checkbox-list fieldset legend {
    display: none;
}

.wc-block-product-filter-checkbox-list__items {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.wc-block-product-filter-checkbox-list__item {
    padding: 10px 0;
    border-bottom: 1px solid #F5F5F5;
}

.wc-block-product-filter-checkbox-list__item:last-child {
    border-bottom: none;
}

/* زیرمجموعه‌ها - Depth */
.wc-block-product-filter-checkbox-list__item.has-depth-1 {
    padding-right: 10px;
}

.wc-block-product-filter-checkbox-list__item.has-depth-2 {
    padding-right: 36px;
}

/* ===== استایل چک‌باکس‌ها - دایره‌ای ===== */
.wc-block-product-filter-checkbox-list__label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 13px;
	color: #555;
	transition: color 0.2s;
	width: 100%;
}

.wc-block-product-filter-checkbox-list__label:hover {
    color: #333;
}

.wc-block-product-filter-checkbox-list__input-wrapper {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-block-product-filter-checkbox-list__input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    z-index: 2;
}

/* دایره چک‌باکس */
.wc-block-product-filter-checkbox-list__input-wrapper::before {
	content: "" !important;
	position: absolute !important;
	width: 20px !important;
	height: 20px !important;
	border: 2px solid #D0D0D0;
	border-radius: 8px !important;
	background: #fff !important;
	transition: all 0.2s;
	top: 0 !important;
	right: 0 !important;
	opacity: 1 !important;
	pointer-events: auto;
}

/* هاور */
.wc-block-product-filter-checkbox-list__label:hover .wc-block-product-filter-checkbox-list__input-wrapper::before {
    border-color: #999;
}

/* وقتی چک شده */
.wc-block-product-filter-checkbox-list__input:checked ~ .wc-block-product-filter-checkbox-list__input-wrapper::before,
.wc-block-product-filter-checkbox-list__label:has(input:checked) .wc-block-product-filter-checkbox-list__input-wrapper::before {
    background: #333;
    border-color: #333;
}

/* آیکون تیک */
.wc-block-product-filter-checkbox-list__mark {
	position: absolute;
	width: 100% !important;
	height: 100% !important;
	color: #fff !important;
	opacity: 0;
	transition: opacity 0.2s;
	z-index: 1;
	background: #002C6E;
	border-radius: 6px;
	top: 1px !important;
	right: 1px !important;
	border: 0 !important;
	margin: 0 !important;
}

.wc-block-product-filter-checkbox-list__input:checked + .wc-block-product-filter-checkbox-list__mark {
    opacity: 1;
}

/* متن آیتم */
.wc-block-product-filter-checkbox-list__text-wrapper {
    flex: 1;
}

.wc-block-product-filter-checkbox-list__text {
    font-size: 13px;
    color: inherit;
}
#sidebar.active {
	right: 0;
}
/* دکمه نمایش بیشتر */
.wc-block-product-filter-checkbox-list__show-more {
    background: transparent;
    border: none;
    color: #E67E22;
    font-size: 13px;
    cursor: pointer;
    padding: 10px 0 0;
    margin-top: 4px;
    transition: color 0.2s;
    text-align: right;
    width: 100%;
}

.wc-block-product-filter-checkbox-list__show-more:hover {
    color: #D35400;
    text-decoration: underline;
}

/* ===== فیلتر قیمت - اسلایدر ===== */
.wc-block-product-filter-price-slider__content {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.wc-block-product-filter-price-slider__range {
    width: 100%;
    height: 6px;
    background: #E5E5E5;
    border-radius: 3px;
    position: relative;
    margin: 15px 0;
}

.wc-block-product-filter-price-slider__range .range-bar {
    position: absolute;
    height: 100%;
    background: #E67E22;
    border-radius: 3px;
    left: var(--low);
    right: calc(100% - var(--high));
}

.wc-block-product-filter-price-slider__range input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    top: 0;
}

.wc-block-product-filter-price-slider__range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid #E67E22;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    margin-top: -6px;
}

.wc-block-product-filter-price-slider__range input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid #E67E22;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
}

.wc-block-product-filter-price-slider__left,
.wc-block-product-filter-price-slider__right {
    flex: 1;
    min-width: 80px;
}

.wc-block-product-filter-price-slider__left input,
.wc-block-product-filter-price-slider__right input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #E5E5E5;
    border-radius: 6px;
    font-size: 12px;
    text-align: center;
    background: #FAFAFA;
}

.wc-block-product-filter-price-slider__left input:focus,
.wc-block-product-filter-price-slider__right input:focus {
    border-color: #E67E22;
    outline: none;
    background: #fff;
}

/* ===== فیلترهای Active/Selected ===== */
.wc-block-product-filter-removable-chips {
    padding: 12px 20px;
    border-bottom: 1px solid #EFEFEF;
}

.wc-block-product-filter-removable-chips__items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.wc-block-product-filter-removable-chips__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #FFF3E6;
    color: #E67E22;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.wc-block-product-filter-removable-chips__item button {
    background: none;
    border: none;
    color: #E67E22;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

/* دکمه پاک کردن فیلترها */
.wc-block-product-filter-clear-button {
    margin-top: 10px;
}

.wc-block-product-filter-clear-button .wp-block-button__link {
    background: transparent !important;
    color: #E67E22 !important;
    border: 1px solid #E67E22 !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
}

.wc-block-product-filter-clear-button .wp-block-button__link:hover {
    background: #E67E22 !important;
    color: #fff !important;
}

/* ===== سوییچ تاگل ===== */
.filter-toggle-wrapper {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 11px 20px;
}
.filter-toggle-wrapper.just-instok {
	border-bottom: 1px solid #ECF1FA;
}
.menu-top-trigger {
	margin-bottom: 0 !important;
}
.filter-toggle-label {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.filter-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}
/* استایل لایه کدر */
.overlay-filter {
	position: fixed;
	top: 0;
	left: -100%;
	width: 100%;
	height: 100%;
	z-index: 999999;
	transition: left 0.3s ease;
	background: #001F52;
	opacity: 40%;
}
/* وقتی سایدبار باز است، این کلاس را به overlay اضافه کنید */
.overlay-filter.active {
  left: 0;
}


.filter-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.filter-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #E0E0E0;
    transition: 0.3s;
    border-radius: 24px;
}

.filter-toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    right: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.filter-toggle input:checked + .filter-toggle-slider {
    background-color: #333;
}

.filter-toggle input:checked + .filter-toggle-slider::before {
    transform: translateX(-20px);
}

/* ===== مخفی کردن فیلترهای مخفی ===== */
.wc-block-product-filter--hidden {
    display: none !important;
}

/* ===== فیلتر Active که مخفی نیست ===== */
[data-block-name="woocommerce/product-filter-active"]:not([hidden]):not(.wc-block-product-filter--hidden) {
    display: block;
}



@media (min-width: 992px) {
    .sidebar-mobile-close,
    .sidebar-mobile-overlay {
        display: none !important;
    }
}

/* ===== دکمه باز کردن فیلتر موبایل ===== */

/* --- آکاردئون فیلتر دسته‌بندی --- */
.wc-block-product-filter-checkbox-list__item {
	display: block !important;
}
/* مخفی کردن زیردسته‌ها (depth-1 و depth-2) به صورت پیش‌فرض */
.wc-block-product-filter-checkbox-list__show-more {
	display: none;
}
/* وقتی والد باز شده، فرزندان سطح 1 نمایش داده شوند */
.wc-block-product-filter-checkbox-list__item.parent-open + .wc-block-product-filter-checkbox-list__item.has-depth-1 {
    display: block !important;
}

/* نمایش زیردسته‌های سطح 1 وقتی والد باز است */
.wc-block-product-filter-checkbox-list__item.has-depth-1.subcategory-visible {
    display: block !important;
}

/* نمایش زیردسته‌های سطح 2 وقتی والد باز است */
.wc-block-product-filter-checkbox-list__item.has-depth-2.subcategory-visible {
    display: block !important;
    padding-right: 40px;
}

/* استایل دکمه تاگل (+/-) */
.category-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #555;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    line-height: 1;
    transition: all 0.25s ease;
    vertical-align: middle;
    font-family: monospace;
}

.category-toggle-btn:hover {
    color: #222;
}

/* وقتی باز است */
.category-toggle-btn.is-open {
    transform: rotate(0deg);
}

/* چیدمان لیبل با دکمه */
.wc-block-product-filter-checkbox-list__item.has-toggle .wc-block-product-filter-checkbox-list__label {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}

/* انیمیشن نمایش زیردسته‌ها */
.wc-block-product-filter-checkbox-list__item.has-depth-1.subcategory-visible,
.wc-block-product-filter-checkbox-list__item.has-depth-2.subcategory-visible {
    animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        overflow: hidden;
    }
    to {
        opacity: 1;
        max-height: 200px;
        overflow: visible;
    }
}
