/*
 * Altınkenti Horizontal Product Filters
 * Desktop toolbar + native Shoptimizer mobile drawer compatibility.
 */

@media (min-width: 993px) {

	/* Shoptimizer may print its original ordering/count using a different hook. Keep only ours. */
	body.akf-horizontal-filters-enabled .woocommerce-ordering,
	body.akf-horizontal-filters-enabled .woocommerce-result-count {
		display: none !important;
	}

	body.akf-horizontal-filters-enabled .akf-ordering .woocommerce-ordering {
		display: block !important;
	}

	body.akf-horizontal-filters-enabled .akf-result-summary .woocommerce-result-count {
		display: block !important;
	}

	body.akf-horizontal-filters-enabled #primary.content-area {
		float: none !important;
		width: 100% !important;
	}

	.akf-result-summary {
		display: flex;
		width: 100%;
		min-height: 20px;
		margin: 0 0 9px;
		padding: 0 3px;
		align-items: center;
		justify-content: flex-end;
	}

	.akf-result-summary .woocommerce-result-count {
		float: none !important;
		margin: 0 !important;
		padding: 0 !important;
		color: #60646c;
		font-size: 13px;
		line-height: 1.5;
		text-align: right;
		white-space: nowrap;
	}

	.akf-archive-controls {
		position: relative;
		z-index: 20;
		width: 100%;
		margin: 0 0 22px;
		padding: 12px;
		border: 1px solid #e4e7eb;
		border-radius: 8px;
		background: #fff;
		box-shadow: 0 4px 18px rgba(17, 24, 39, 0.04);
	}

	.akf-filter-row {
		display: flex;
		width: 100%;
		min-height: 42px;
		align-items: center;
		gap: 10px;
	}

	.akf-filter-caption {
		color: #374151;
		font-size: 13px;
		font-weight: 600;
		flex: 0 0 auto;
	}

	.akf-sidebar-slot {
		min-width: 0;
		flex: 1 1 auto;
	}

	.akf-sidebar-slot .akf-secondary-wrapper {
		position: static !important;
		display: block !important;
		width: 100% !important;
		height: auto !important;
		margin: 0 !important;
		padding: 0 !important;
		overflow: visible !important;
		visibility: visible !important;
		opacity: 1 !important;
		transform: none !important;
		background: transparent !important;
		box-shadow: none !important;
	}

	.akf-sidebar-slot #akf-secondary.widget-area {
		position: static !important;
		float: none !important;
		display: flex;
		width: 100% !important;
		margin: 0 !important;
		padding: 0 !important;
		flex-wrap: wrap;
		align-items: center;
		gap: 10px;
		overflow: visible !important;
	}


	.akf-item {
		position: relative;
		display: block;
		min-width: 0;
		margin: 0 !important;
		padding: 0 !important;
		border: 0 !important;
		overflow: visible !important;
	}

	.akf-toggle {
		display: inline-flex;
		width: 160px;
		max-width: 220px;
		height: 42px;
		margin: 0;
		padding: 0 13px;
		border: 1px solid #d9dde3;
		border-radius: 6px;
		background: #fff;
		color: #202124;
		box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
		font: inherit;
		font-size: 13px;
		font-weight: 500;
		line-height: 1;
		cursor: pointer;
		align-items: center;
		gap: 8px;
		text-align: left;
		transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
	}

	.akf-toggle:hover,
	.akf-toggle:focus-visible,
	.akf-item.is-open > .akf-toggle {
		border-color: #ff6b00;
		outline: 0;
		box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.1);
	}

	.akf-item.has-selection > .akf-toggle {
		border-color: #ff6b00;
		background: #fffaf5;
	}

	.akf-label {
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.akf-count {
		display: inline-flex;
		min-width: 20px;
		height: 20px;
		padding: 0 6px;
		border-radius: 999px;
		background: #a94f00;
		color: #fff;
		font-size: 11px;
		font-weight: 700;
		line-height: 20px;
		align-items: center;
		justify-content: center;
	}

	.akf-count[hidden] {
		display: none;
	}

	.akf-chevron {
		width: 7px;
		height: 7px;
		margin-left: auto;
		border-right: 1.5px solid currentColor;
		border-bottom: 1.5px solid currentColor;
		transform: rotate(45deg) translateY(-2px);
		transition: transform 0.18s ease;
		flex: 0 0 auto;
	}

	.akf-item.is-open .akf-chevron {
		transform: rotate(225deg) translate(-1px, -1px);
	}

	.akf-panel {
		position: absolute;
		z-index: 60;
		top: calc(100% + 8px);
		left: 0;
		display: none;
		width: 320px;
		max-width: min(380px, calc(100vw - 32px));
		max-height: 430px;
		padding: 18px;
		overflow-x: hidden;
		overflow-y: auto;
		border: 1px solid #e1e4e8;
		border-radius: 8px;
		background: #fff;
		box-shadow: 0 16px 40px rgba(17, 24, 39, 0.16);
	}

	.akf-item.is-open > .akf-panel {
		display: block;
	}

	.akf-item.akf-align-right > .akf-panel {
		right: 0;
		left: auto;
	}

	.akf-panel ul {
		margin-top: 0;
		margin-bottom: 0;
	}

	.akf-panel input[type="search"],
	.akf-panel input[type="text"],
	.akf-panel select {
		width: 100%;
	}

	.akf-panel form,
	.akf-panel .price_slider_wrapper {
		width: 100%;
	}

	.akf-ordering {
		position: relative;
		margin-left: auto;
		flex: 0 0 220px;
	}

	.akf-ordering .woocommerce-ordering {
		float: none !important;
		display: block;
		width: 220px;
		margin: 0 !important;
		padding: 0 !important;
	}

	.akf-ordering .woocommerce-ordering::before,
	.akf-ordering .woocommerce-ordering::after {
		display: none !important;
	}

	.akf-ordering select.orderby {
		appearance: none !important;
		-webkit-appearance: none !important;
		display: block;
		width: 100% !important;
		height: 42px;
		margin: 0 !important;
		padding: 0 40px 0 13px !important;
		border: 1px solid #d9dde3 !important;
		border-radius: 6px !important;
		outline: 0;
		background: #fff !important;
		color: #202124;
		box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
		font-family: inherit;
		font-size: 13px;
		font-weight: 500;
		cursor: pointer;
	}

	.akf-ordering::after {
		content: "";
		position: absolute;
		z-index: 2;
		top: 16px;
		right: 17px;
		width: 7px;
		height: 7px;
		border-right: 1.5px solid #30343b;
		border-bottom: 1.5px solid #30343b;
		pointer-events: none;
		transform: rotate(45deg);
	}



	/*
	 * Keep the native Shoptimizer sidebar in the DOM for mobile, but remove it
	 * from the desktop page flow. The custom desktop copy uses the akf-* names,
	 * so these selectors do not affect the horizontal toolbar.
	 */
	body.akf-horizontal-filters-enabled .secondary-wrapper,
	body.akf-horizontal-filters-enabled #secondary.widget-area {
		display: none !important;
	}

	/* Keep Shoptimizer/WooCommerce native controls in the DOM for mobile,
	   but hide their duplicate desktop output. */
	body.akf-horizontal-filters-enabled
	.akf-archive-controls ~ .woocommerce-result-count,
	body.akf-horizontal-filters-enabled
	.akf-archive-controls ~ .woocommerce-ordering {
		display: none !important;
	}

	/* Hide only a leftover original direct-child sidebar if a theme update re-adds it. */
	body.akf-horizontal-filters-enabled .site-content > .col-full > .secondary-wrapper {
		display: none !important;
	}
}

@media (min-width: 993px) and (max-width: 1220px) {
	.akf-filter-row {
		flex-wrap: wrap;
	}

	.akf-ordering {
		margin-left: 0;
	}

	.akf-toggle {
		width: 150px;
	}
}

@media (max-width: 992px) {
	/*
	 * Mobile is intentionally left to Shoptimizer's original implementation.
	 * Hide every element generated by this plugin so the native filter drawer,
	 * native result count and native ordering remain exactly as before.
	 */
	.akf-clear-row,
	.akf-result-summary,
	.akf-archive-controls {
		display: none !important;
	}
}

/* WOOF/HUSKY: sorting is not a product filter. */
.woof_products_top_panel .akf-orderby-chip,
.woof_products_top_panel_ul .akf-orderby-chip,
.woof_products_top_panel.akf-top-panel-empty,
.woof_products_top_panel_ul.akf-top-panel-empty {
	display: none !important;
}

@media (min-width: 993px) {
	/* Restore a clean, familiar filter-list appearance inside dropdowns. */
	.akf-panel ul {
		list-style: none !important;
		padding-left: 0 !important;
	}

	.akf-panel ul li {
		position: relative;
		margin: 0 !important;
		padding: 0 !important;
	}

	.akf-panel ul li + li {
		margin-top: 8px !important;
	}

	.akf-panel ul li > a {
		display: flex;
		width: 100%;
		min-height: 24px;
		color: #34383f;
		text-decoration: none;
		align-items: center;
	}

	.akf-panel ul li > a::before {
		content: "";
		display: inline-block;
		width: 8px;
		height: 8px;
		margin-right: 9px;
		border: 1.5px solid #ff6b00;
		border-radius: 50%;
		background: #fff;
		box-sizing: border-box;
		flex: 0 0 8px;
	}

	.akf-panel ul li.chosen > a::before,
	.akf-panel ul li.current-cat > a::before,
	.akf-panel ul li.woocommerce-widget-layered-nav-list__item--chosen > a::before {
		background: #ff6b00;
		box-shadow: inset 0 0 0 2px #fff;
	}

	.akf-panel ul li .count {
		margin-left: auto;
		padding-left: 12px;
		color: #7b8087;
		font-size: 12px;
	}

	/* WooCommerce hides the slider until its script initializes. */
	.akf-panel .price_slider_wrapper .price_slider {
		margin: 4px 0 16px;
	}

	.akf-ordering select.orderby {
		text-overflow: ellipsis;
		white-space: nowrap;
	}
}

/* v1.0.3: one authoritative clear control; WOOF's panel is inconsistent for sorting. */
.woof_products_top_panel,
.woof_products_top_panel_ul {
	display: none !important;
}

.akf-clear-row[hidden] {
	display: none !important;
}

.akf-clear-row {
	display: flex;
	width: 100%;
	margin: 0 0 10px;
	padding: 0 4px;
	align-items: center;
}

.akf-clear-filters {
	color: #34383f;
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
}

.akf-clear-filters:hover,
.akf-clear-filters:focus-visible {
	color: #c45100;
	text-decoration: underline;
}

@media (min-width: 993px) {
	/* Keep layered-nav counts on the same row as their attribute label. */
	.akf-panel ul li {
		display: flex !important;
		width: 100%;
		align-items: center;
		gap: 10px;
	}

	.akf-panel ul li > a {
		width: auto !important;
		min-width: 0;
		flex: 1 1 auto;
	}

	.akf-panel ul li .count {
		float: none !important;
		display: inline-block !important;
		width: auto !important;
		min-width: max-content;
		margin: 0 0 0 auto !important;
		padding: 0 !important;
		line-height: 1.4;
		text-align: right;
		white-space: nowrap;
		flex: 0 0 auto;
	}

	/* Price-filter spacing and predictable flex layout. */
	.akf-panel .widget_price_filter .price_slider_wrapper,
	.akf-panel .price_slider_wrapper {
		padding-top: 4px;
	}

	.akf-panel .price_slider_wrapper .price_slider.ui-slider {
		display: block !important;
		margin: 8px 8px 20px !important;
	}

	.akf-panel .price_slider_amount {
		clear: both;
		display: flex;
		width: 100%;
		padding-top: 2px;
		align-items: center;
		flex-wrap: wrap;
		gap: 10px 12px;
	}

	.akf-panel .price_slider_amount .button {
		float: none !important;
		margin: 0 !important;
		flex: 0 0 auto;
	}

	.akf-panel .price_slider_amount .price_label {
		float: none !important;
		display: block !important;
		width: 100%;
		margin: 0 !important;
		line-height: 1.5;
		order: 2;
	}
}


/* v1.0.11 — Safe mega-menu compatibility
 * Do not modify Shoptimizer menu columns or submenu layout.
 * Keep the horizontal filter bar in the normal page layer so the theme's
 * mega-menu overlay can darken it exactly like the rest of the archive page.
 */
@media (min-width: 993px) {
  body.akf-horizontal-filters-enabled .akf-archive-controls {
    position: relative;
    z-index: 0 !important;
  }

  body.akf-horizontal-filters-enabled .akf-result-summary {
    position: relative;
    z-index: 0 !important;
  }

  body.akf-horizontal-filters-enabled .akf-panel {
    z-index: 5 !important;
  }
}




/* v1.0.13 — Floating filter dropdowns without layout shift
 * Only the opened option panels are layered above products. They do not reserve
 * page height, so product cards are not pushed down. The toolbar itself stays
 * in the normal page layer for Shoptimizer mega-menu overlay compatibility.
 */
@media (min-width: 993px) {
  body.akf-horizontal-filters-enabled .akf-archive-controls {
    position: relative;
    z-index: 2;
    overflow: visible !important;
  }

  body.akf-horizontal-filters-enabled .akf-sidebar-slot,
  body.akf-horizontal-filters-enabled .akf-secondary-wrapper,
  body.akf-horizontal-filters-enabled #akf-secondary,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .widget {
    overflow: visible !important;
  }

  body.akf-horizontal-filters-enabled .akf-sidebar-slot .widget {
    position: relative;
  }

  body.akf-horizontal-filters-enabled .akf-panel,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-content,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-layout-dropdown .wpc-filter-content,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-layout-dropdown .wpc-filter-content-wrapper,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .woof_block_html_items,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .select2-dropdown {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 0 !important;
    width: max(240px, 100%) !important;
    min-width: 240px !important;
    max-width: 320px !important;
    z-index: 9999 !important;
    background: #fff;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .14);
    border-radius: 8px;
  }

  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-layout-dropdown .wpc-filter-content:not(.wpc-opened),
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-layout-dropdown .wpc-filter-content-wrapper:not(.wpc-opened) {
    display: none;
  }

  body.akf-horizontal-filters-enabled ul.products,
  body.akf-horizontal-filters-enabled ul.products li.product,
  body.akf-horizontal-filters-enabled .products,
  body.akf-horizontal-filters-enabled .product {
    position: relative;
    z-index: 1;
  }
}


/* v1.0.14 — Active dropdown above products, without creating empty space
 * v1.0.13 made the panels floating, but some Shoptimizer product-card layers
 * could still paint above them. This raises only the active filter toolbar layer
 * above product cards, while keeping the mega-menu overlay safe.
 */
@media (min-width: 993px) {
  body.akf-horizontal-filters-enabled .akf-archive-controls:has(.akf-panel),
  body.akf-horizontal-filters-enabled .akf-archive-controls:has(.wpc-filter-content),
  body.akf-horizontal-filters-enabled .akf-archive-controls:has(.woof_block_html_items) {
    z-index: 80 !important;
    overflow: visible !important;
  }

  body.akf-horizontal-filters-enabled .akf-sidebar-slot,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .widget,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-layout-dropdown,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .woof_container {
    position: relative !important;
    z-index: 90 !important;
    overflow: visible !important;
  }

  body.akf-horizontal-filters-enabled .akf-panel,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-content,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .wpc-filter-content-wrapper,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .woof_block_html_items,
  body.akf-horizontal-filters-enabled .akf-sidebar-slot .select2-dropdown {
    z-index: 10000 !important;
    pointer-events: auto;
  }

  body.akf-horizontal-filters-enabled ul.products,
  body.akf-horizontal-filters-enabled ul.products li.product,
  body.akf-horizontal-filters-enabled ul.products li.product *,
  body.akf-horizontal-filters-enabled .products,
  body.akf-horizontal-filters-enabled .product,
  body.akf-horizontal-filters-enabled .product-inner,
  body.akf-horizontal-filters-enabled .woocommerce-loop-product__link,
  body.akf-horizontal-filters-enabled .woocommerce-card__header {
    z-index: auto !important;
  }

  body.akf-horizontal-filters-enabled ul.products li.product {
    position: relative;
  }

  /* Keep the theme mega-menu above the filter area when the main menu is open. */
  body.akf-horizontal-filters-enabled .site-header,
  body.akf-horizontal-filters-enabled .site-header .main-navigation,
  body.akf-horizontal-filters-enabled .main-navigation ul.menu > li > ul.sub-menu {
    z-index: 99999 !important;
  }
}


/* v1.0.17 — Let Shoptimizer mega menu cover the filter bar
 * When the main mega menu is open, the filter bar must stay under the menu.
 * When a filter dropdown itself is open, v1.0.14 behavior remains: it floats
 * above product cards without pushing products down.
 */
@media (min-width: 993px) {
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .akf-archive-controls,
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .akf-toolbar,
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .akf-filter-bar,
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .akf-horizontal-filters,
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .akf-sidebar-slot {
    z-index: 0 !important;
  }

  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .akf-panel {
    display: none !important;
  }

  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .main-navigation ul.menu > li > .sub-menu-wrapper,
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .main-navigation ul.menu > li:hover > .sub-menu-wrapper,
  body.akf-horizontal-filters-enabled.akf-shoptimizer-menu-open .main-navigation ul.menu > li:focus-within > .sub-menu-wrapper {
    z-index: 99999 !important;
  }
}
