/* Inside Tech Product Filter — style panelu i siatki. */

.itpf-filter {
	background: #fff;
	border: 1px solid #d8d8d8;
	border-radius: 4px;
	padding: 14px 16px;
	margin-bottom: 24px;

	/* Zmienne motywu — nadpisywalne globalnie (ustawienia wtyczki:
	   --itpf-accent-default) lub per widget (Elementor: --itpf-accent). */
	--itpf-accent: var(--itpf-accent-default, #2271b1);
	--itpf-cb-size: 18px;
	--itpf-cb-radius: 4px;
	--itpf-item-gap: 0px;
	--itpf-group-gap: 12px;
}

/* Odstępy sterowane zmiennymi (Elementor ustawia je na .itpf-filter) */
.itpf-filter li.itpf-node { margin-bottom: var(--itpf-item-gap, 0); }
.itpf-filter .itpf-list > li.itpf-node > .itpf-label { display: flex; margin: 0; }
.itpf-filter .itpf-groups { display: flex; flex-direction: column; gap: var(--itpf-group-gap, 12px); }
.itpf-filter .itpf-groups > .itpf-group { margin: 0; }
.itpf-filter .itpf-group .itpf-group-title { margin: 0; }
.itpf-filter .itpf-group-body:not(.itpf-collapsed) { margin-top: 6px; }
.itpf-filter .itpf-group-body > .itpf-list,
.itpf-filter .itpf-group-body > .itpf-tree { margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }

.itpf-filter .itpf-form { margin: 0; }

.itpf-group {
	margin-bottom: 12px;
}

.itpf-group-title {
	font-size: 14px;
	font-weight: 600;
	margin: 0 0 6px;
	color: #1d2327;
}

/* Tytuł grupy: domyślnie BEZ tła (motyw potrafi dodać tło na hover).
   Tło/hover można ustawić per widget w Elementorze. */
.itpf-filter .itpf-group-title .itpf-group-toggle,
.itpf-filter .itpf-group-title .itpf-group-toggle:hover {
	background: transparent;
	box-shadow: none;
}

/* Klikalny nagłówek grupy (zwijanie/rozwijanie) + ikona +/− po prawej */
.itpf-group-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	font-size: 14px;
	line-height: 1.3;
	color: #1d2327;
	text-align: left;
}

.itpf-group-toggle:hover .itpf-group-label { text-decoration: underline; }

.itpf-group-sign {
	position: relative;
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
}

.itpf-group-sign::before,
.itpf-group-sign::after {
	content: '';
	position: absolute;
	background: currentColor;
}

/* Linia pozioma (minus/plus) */
.itpf-group-sign::before {
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	margin-top: -1px;
}

/* Linia pionowa (plus; znika gdy grupa otwarta → minus) */
.itpf-group-sign::after {
	top: 0;
	bottom: 0;
	left: 50%;
	width: 2px;
	margin-left: -1px;
}

.itpf-group-toggle[aria-expanded="true"] .itpf-group-sign::after { display: none; }

.itpf-group-body.itpf-collapsed { display: none; }

/* Drzewo kategorii */
.itpf-tree,
.itpf-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.itpf-tree > li.itpf-node > ul.itpf-tree {
	margin-left: 18px;
	/* Odstęp od góry zagnieżdżonych podkategorii = odstęp pozycji (Elementor). */
	margin-top: var(--itpf-item-gap, 0);
}

.itpf-tree.itpf-collapsed {
	display: none;
}

/* Wiersz węzła: ☐ nazwa  licznik  +/− (ikona zaraz po liczniku) */
.itpf-tree .itpf-node-row {
	display: flex;
	align-items: center;
	gap: 6px;
}

.itpf-tree .itpf-toggle,
.itpf-tree .itpf-leaf {
	position: relative;
	flex: 0 0 auto;
	width: 14px;
	height: 14px;
	cursor: pointer;
	color: #666;
	line-height: 14px;
}

/* Liście nie mają ikony (zachowujemy wyrównanie). */
.itpf-tree .itpf-leaf { visibility: hidden; }

.itpf-tree .itpf-toggle::before,
.itpf-tree .itpf-toggle::after {
	content: '';
	position: absolute;
	background: currentColor;
}

/* Linia pozioma (minus / część plusa) */
.itpf-tree .itpf-toggle::before {
	left: 0;
	right: 0;
	top: 50%;
	height: 2px;
	margin-top: -1px;
}

/* Linia pionowa (plus); znika po rozwinięciu → zostaje minus */
.itpf-tree .itpf-toggle::after {
	top: 0;
	bottom: 0;
	left: 50%;
	width: 2px;
	margin-left: -1px;
}

.itpf-tree .itpf-toggle.itpf-expanded::after { display: none; }

/* Checkbox + etykieta */
.itpf-label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	cursor: pointer;
}

.itpf-label .itpf-cb {
	margin: 0;
	flex: 0 0 auto;
	width: var(--itpf-cb-size, 18px);
	height: var(--itpf-cb-size, 18px);
	-webkit-appearance: none;
	appearance: none;
	border: var(--itpf-cb-border-width, 2px) solid var(--itpf-cb-border-color, #c9cdd2);
	border-radius: var(--itpf-cb-radius, 4px);
	background: #fff;
	position: relative;
	cursor: pointer;
	vertical-align: middle;
	transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.itpf-label .itpf-cb:hover { border-color: var(--itpf-accent, #2271b1); }

.itpf-label .itpf-cb:focus-visible {
	outline: 2px solid var(--itpf-accent, #2271b1);
	outline-offset: 2px;
}

.itpf-label .itpf-cb:checked {
	background: var(--itpf-accent, #2271b1);
	border-color: var(--itpf-accent, #2271b1);
}

.itpf-label .itpf-cb:checked::after {
	content: '';
	position: absolute;
	left: 50%;
	top: 46%;
	width: 5px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: translate(-50%, -50%) rotate(45deg);
}

.itpf-name {
	color: #333;
}

.itpf-labels .itpf-label:hover .itpf-name { text-decoration: underline; }

/* Licznik */
.itpf-count {
	display: inline-block;
	min-width: 22px;
	padding: 0 6px;
	background: #f0f0f1;
	border-radius: 9px;
	font-size: 11px;
	line-height: 16px;
	text-align: center;
	color: #50575e;
}

/* Płaska lista (atrybuty) */
.itpf-list {
	max-height: 300px;
	overflow-y: auto;
}

/* Akcje */
.itpf-actions {
	margin-top: 12px;
	display: flex;
	gap: 10px;
	align-items: center;
}

.itpf-actions .button { background: #2271b1; color: #fff; border: none; }
.itpf-reset { color: #2271b1; text-decoration: none; }
.itpf-reset:hover { text-decoration: underline; }

/* Siatka wyników */
.itpf-results {
	margin-top: 12px;
}

.itpf-results .itpf-total {
	font-size: 13px;
	color: #666;
	margin: 0 0 8px;
}

.itpf-results .itpf-empty {
	padding: 24px;
	text-align: center;
	color: #777;
	border: 1px dashed #d8d8d8;
}

.itpf-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 16px;
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
}

.itpf-grid.columns-2 { grid-template-columns: repeat(2, 1fr); }
.itpf-grid.columns-3 { grid-template-columns: repeat(3, 1fr); }
.itpf-grid.columns-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.itpf-grid.columns-5 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.itpf-grid.columns-6 { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

.itpf-item.product {
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	padding: 8px;
	text-align: center;
	margin: 0;
}

.itpf-item.product .itpf-thumb {
	display: block;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	margin-bottom: 6px;
}

.itpf-item.product .itpf-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.itpf-item.product .itpf-title h3 {
	font-size: 13px;
	font-weight: 600;
	margin: 0 0 4px;
	color: #1d2327;
}

.itpf-item.product .itpf-price {
	font-size: 13px;
	color: #b32d2d;
}

/* Paginacja */
.itpf-pagination {
	margin: 16px 0 0;
	text-align: center;
}

.itpf-pagination ul {
	list-style: none;
	display: inline-flex;
	gap: 6px;
	margin: 0;
	padding: 0;
}

.itpf-pagination a.itpf-page {
	display: inline-block;
	min-width: 30px;
	padding: 4px 8px;
	border: 1px solid #d8d8d8;
	border-radius: 3px;
	text-align: center;
	text-decoration: none;
	color: #2271b1;
}

.itpf-pagination .current {
	min-width: 30px;
	padding: 4px 8px;
	border: 1px solid #2271b1;
	background: #2271b1;
	color: #fff;
	border-radius: 3px;
	text-align: center;
}

/* Stany ładowania */
.itpf-results.itpf-loading {
	opacity: 0.55;
	pointer-events: none;
	position: relative;
}

.itpf-results.itpf-loading::after {
	content: '...';
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 24px;
	color: #2271b1;
	background: rgba(255,255,255,0.6);
}

/* Zasłona + spinner podczas filtrowania (AJAX soft-refresh / własna siatka). */
body.itpf-loading-body {
	position: relative;
}

body.itpf-loading-body::before {
	content: '';
	position: fixed;
	inset: 0;
	z-index: 99990;
	background: var(--itpf-preloader-overlay, rgba(255, 255, 255, 0.55));
	transition: opacity 0.2s ease;
	opacity: 1;
}

body.itpf-loading-body::after {
	content: '';
	position: fixed;
	top: 50%;
	left: 50%;
	width: var(--itpf-preloader-size, 44px);
	height: var(--itpf-preloader-size, 44px);
	margin: calc(var(--itpf-preloader-size, 44px) / -2) 0 0 calc(var(--itpf-preloader-size, 44px) / -2);
	z-index: 99991;
	border: 4px solid var(--itpf-preloader-track, rgba(34, 113, 177, 0.25));
	border-top-color: var(--itpf-preloader-color, #2271b1);
	border-radius: 50%;
	animation: itpf-spin 0.8s linear infinite;
}

body.itpf-loading-body .itpf-filter,
body.itpf-loading-body .itpf-results,
body.itpf-loading-body ul.products,
body.itpf-loading-body .elementor-wc-products,
body.itpf-loading-body .elementor-loop-container {
	opacity: 0.4;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

@keyframes itpf-spin {
	to { transform: rotate(360deg); }
}

/* Responsywność */
@media (max-width: 600px) {
	.itpf-filter { padding: 10px; }
	.itpf-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

/* Przełącznik +/−: wyrównanie i własne ikony (wybrane w Elementorze) */
.itpf-tree .itpf-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.itpf-group-sign {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.itpf-ic { display: inline-block; line-height: 1; }

.itpf-ic-expanded { display: none; }

/* Ukryj domyślne kreski CSS, gdy użyto własnych ikon */
.itpf-toggle.itpf-custom::before,
.itpf-toggle.itpf-custom::after,
.itpf-group-sign.itpf-custom::before,
.itpf-group-sign.itpf-custom::after { display: none; }

/* Przełączanie ikon wg stanu */
.itpf-toggle.itpf-expanded .itpf-ic-collapsed,
.itpf-group-toggle[aria-expanded="true"] .itpf-ic-collapsed { display: none; }

.itpf-toggle.itpf-expanded .itpf-ic-expanded,
.itpf-group-toggle[aria-expanded="true"] .itpf-ic-expanded { display: inline-block; }

/* Rozmiar/pokazanie własnych ikon (fontowe FA/eicons oraz SVG z Elementora) */
.itpf-toggle,
.itpf-group-sign { overflow: visible; }

.itpf-ic {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.itpf-ic i { font-size: 1em; line-height: 1; }

.itpf-ic svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
	display: block;
	stroke: currentColor;
}

/* Ładniejszy, ostylowalny pasek przewijania (zmienne z Elementora) */
.itpf-filter .itpf-list,
.itpf-filter .itpf-tree {
	scrollbar-width: thin; /* Firefox */
	scrollbar-color: var(--itpf-sb-thumb, #c9cdd2) var(--itpf-sb-track, transparent);
}

.itpf-filter .itpf-list::-webkit-scrollbar,
.itpf-filter .itpf-tree::-webkit-scrollbar {
	width: var(--itpf-sb-size, 8px);
	height: var(--itpf-sb-size, 8px);
}

.itpf-filter .itpf-list::-webkit-scrollbar-track,
.itpf-filter .itpf-tree::-webkit-scrollbar-track {
	background: var(--itpf-sb-track, transparent);
	border-radius: var(--itpf-sb-radius, 8px);
}

.itpf-filter .itpf-list::-webkit-scrollbar-thumb,
.itpf-filter .itpf-tree::-webkit-scrollbar-thumb {
	background: var(--itpf-sb-thumb, #c9cdd2);
	border-radius: var(--itpf-sb-radius, 8px);
}

.itpf-filter .itpf-list::-webkit-scrollbar-thumb:hover,
.itpf-filter .itpf-tree::-webkit-scrollbar-thumb:hover {
	background: var(--itpf-sb-thumb-hover, var(--itpf-sb-thumb, #b3b8bf));
}


