/**
 * Mağaza kenar çubuğu — ürün kategorileri grid (toptanmum-cat-filter-enhanced).
 * functions.php: toptanmum_category_filter_sidebar_enhance
 */

.toptanmum-cat-filter-enhanced {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid !important;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	align-items: stretch;
	width: 100%;
	box-sizing: border-box;
	grid-auto-flow: row;
}

/* Yanlışlıkla bu sınıf ürün döngüsüne yapışırsa (eski önbellek / JS) grid ürünleri gizleyebilir */
ul.products.toptanmum-cat-filter-enhanced,
ul.wc-block-grid__products.toptanmum-cat-filter-enhanced {
	display: flex !important;
	flex-wrap: wrap !important;
	grid-template-columns: unset !important;
}

.toptanmum-cat-filter-enhanced li.cat-item,
.toptanmum-cat-filter-enhanced ul.children li,
.toptanmum-cat-filter-enhanced ul ul li {
	float: none !important;
	clear: none !important;
	width: 100% !important;
	max-width: none !important;
	box-sizing: border-box;
}

.toptanmum-cat-filter-enhanced > li {
	position: relative;
	display: flex;
	flex-direction: column;
	margin: 0;
	min-width: 0;
	border: none;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 0 0 1px #e2e2e2, 0 1px 3px rgba(0, 0, 0, 0.05);
	overflow: visible;
	transition: box-shadow 0.2s;
}

.toptanmum-cat-filter-enhanced > li:hover {
	box-shadow: 0 0 0 1px #cfcfcf, 0 3px 10px rgba(0, 0, 0, 0.07);
}

.toptanmum-cat-filter-enhanced > li > a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 16px;
	text-decoration: none;
	color: #1f1f1f !important;
	line-height: 1.3;
	font-weight: 600;
	font-size: 0.95rem;
	transition: background 0.15s;
	flex: 0 0 auto;
}

.toptanmum-cat-filter-enhanced > li > a:hover {
	background: #f6f6f6;
	color: #111 !important;
}

.toptanmum-cat-filter-enhanced .count,
.toptanmum-cat-filter-enhanced span.count,
.toptanmum-cat-filter-enhanced .wc-block-product-categories-list-item-count {
	display: none !important;
}

.toptanmum-cat-filter-enhanced > li.current-cat,
.toptanmum-cat-filter-enhanced > li.current-cat-parent {
	background: #d3d389;
	box-shadow: 0 0 0 1px #bfc270, 0 1px 3px rgba(0, 0, 0, 0.05);
}

.toptanmum-cat-filter-enhanced > li.current-cat > a,
.toptanmum-cat-filter-enhanced > li.current-cat-parent > a {
	background: transparent;
	font-weight: 700;
	color: #2a2a1a !important;
}

.toptanmum-cat-filter-enhanced ul.children,
.toptanmum-cat-filter-enhanced ul ul {
	list-style: none;
	margin: 0 !important;
	padding: 10px 12px 16px !important;
	display: grid !important;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	border: 0;
	width: 100%;
	box-sizing: border-box;
	grid-auto-flow: row;
	float: none !important;
	overflow: visible;
}

.toptanmum-cat-filter-enhanced ul.children > li,
.toptanmum-cat-filter-enhanced ul ul > li {
	margin: 0 !important;
	padding: 0 !important;
	display: flex;
	flex-direction: column;
	min-height: 0;
	border: 1px solid #e0e0e0 !important;
	border-radius: 10px;
	background: #f6f6f6;
	overflow: visible;
	transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
	position: relative;
	z-index: 0;
}

.toptanmum-cat-filter-enhanced ul.children > li:hover,
.toptanmum-cat-filter-enhanced ul ul > li:hover {
	background: #efefef;
	border-color: #d0d0d0 !important;
}

.toptanmum-cat-filter-enhanced ul.children > li > a,
.toptanmum-cat-filter-enhanced ul ul > li > a {
	display: flex !important;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 11px 12px;
	font-weight: 500;
	font-size: 0.82rem;
	text-decoration: none;
	color: #222 !important;
	min-height: 2.85rem;
	flex: 1;
	box-sizing: border-box;
}

.toptanmum-cat-filter-enhanced ul.children > li > a:hover,
.toptanmum-cat-filter-enhanced ul ul > li > a:hover {
	color: #000 !important;
}

.toptanmum-cat-filter-enhanced ul.children > li.current-cat,
.toptanmum-cat-filter-enhanced ul ul > li.current-cat,
.toptanmum-cat-filter-enhanced ul.children > li.current-cat-parent,
.toptanmum-cat-filter-enhanced ul ul > li.current-cat-parent {
	background: #d3d389 !important;
	border: 1px solid #bfc270 !important;
	box-shadow: none;
	z-index: 2;
}

.toptanmum-cat-filter-enhanced ul.children > li.current-cat > a,
.toptanmum-cat-filter-enhanced ul ul > li.current-cat > a,
.toptanmum-cat-filter-enhanced ul.children > li.current-cat-parent > a,
.toptanmum-cat-filter-enhanced ul ul > li.current-cat-parent > a {
	font-weight: 700;
	color: #2a2a1a !important;
}

.toptanmum-cat-filter-enhanced > li.current-cat ul.children li {
	background: #d3d389 !important;
	border: 1px solid #bfc270 !important;
	box-shadow: none;
	z-index: 2;
}

.toptanmum-cat-filter-enhanced > li.current-cat ul.children li > a {
	font-weight: 700;
	color: #2a2a1a !important;
}

.toptanmum-cat-filter-enhanced > li.current-cat ul.children li:hover {
	background: #c9c97f !important;
	border-color: #bfc270 !important;
}

/* width="1" kaldırıldı: lazy/placeholder bazı kategori görsellerinde 1x1 ile işaretlenir ve tamamen gizlenirdi */
.toptanmum-cat-filter-enhanced img[src=""],
.toptanmum-cat-filter-enhanced .wc-block-product-categories__image:empty {
	display: none !important;
}

.toptanmum-cat-filter-enhanced .wc-block-product-categories-list {
	display: grid !important;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
	width: 100%;
}

.toptanmum-cat-filter-enhanced .wc-block-product-categories-list-item {
	margin: 0;
	padding: 0;
	border: 1px solid #e2e2e2;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.toptanmum-cat-filter-enhanced:has(> li:only-child) > li {
	grid-column: 1 / -1;
}

/**
 * Mobil / tablet: “Mumlar” ve “Ham madde” üst blokları alt alta (DOM sırası: önce Mumlar, sonra Ham madde).
 * JS: .toptanmum-cat-filter-stack-wrap sarmalayıcıya eklenir (flex/grid satırı dikeye çevrilir).
 */
@media (max-width: 991px) {
	.toptanmum-cat-filter-enhanced {
		grid-template-columns: minmax(0, 1fr) !important;
	}

	.toptanmum-cat-filter-enhanced .wc-block-product-categories-list {
		grid-template-columns: minmax(0, 1fr) !important;
	}

	/* Avada: :has() olmayan tarayıcılar + farklı sınıf varyantları */
	.fusion-sidebar .fusion-columns .fusion-column:has(.toptanmum-cat-filter-enhanced),
	.fusion-widget-area .fusion-columns .fusion-column:has(.toptanmum-cat-filter-enhanced),
	#secondary .fusion-columns .fusion-column:has(.toptanmum-cat-filter-enhanced),
	.fusion-sidebar .fusion-layout-column:has(.toptanmum-cat-filter-enhanced),
	.fusion-sidebar .fusion_builder_column:has(.toptanmum-cat-filter-enhanced),
	.fusion-sidebar .fusion-column:has(.toptanmum-cat-filter-enhanced) {
		width: 100% !important;
		max-width: 100% !important;
		flex: 0 0 100% !important;
	}

	/* JS ile işaretlenen üst sarmalayıcı */
	.toptanmum-cat-filter-stack-wrap {
		flex-direction: column !important;
		align-items: stretch !important;
	}

	.toptanmum-cat-filter-stack-wrap[class*="fusion-flex-row"],
	.toptanmum-cat-filter-stack-wrap.fusion-flex-align-flex-start {
		flex-direction: column !important;
	}
}

/* Dar ekran: alt kategori düğmeleri tek sütun (isteğe bağlı sıkışma) */
@media (max-width: 420px) {
	.toptanmum-cat-filter-enhanced ul.children,
	.toptanmum-cat-filter-enhanced ul ul {
		grid-template-columns: 1fr !important;
	}
}

/**
 * Mobil: kategori grid kenar çubuğunda gizli; tam ekran menü (Ürünler) içinde gösterilir.
 * body.toptanmum-mobile-cat-overlay-open iken liste overlay host’ta olduğundan bu kurallar uygulanmaz.
 */
@media (max-width: 768px) {
	body:not(.toptanmum-mobile-cat-overlay-open) ul.toptanmum-cat-filter-enhanced {
		display: none !important;
	}

	body:not(.toptanmum-mobile-cat-overlay-open) .widget_product_categories:has(ul.toptanmum-cat-filter-enhanced),
	body:not(.toptanmum-mobile-cat-overlay-open) .wp-block-woocommerce-product-categories:has(ul.toptanmum-cat-filter-enhanced),
	body:not(.toptanmum-mobile-cat-overlay-open) .fusion-widget:has(ul.toptanmum-cat-filter-enhanced) {
		display: none !important;
	}
}
