/*!
 * Autotehnika — razvijajući meni kategorija (WooCommerce Product Categories widget).
 * Scopeano na .product-categories kako ne bi utjecalo na ostatak stranice.
 * Struktura nakon JS-a:
 *   li.cat-item > div.ath-cat-row > (a + span.ath-cat-count + span.ath-cat-toggle)
 *   li.cat-item > ul.children
 */

.product-categories {
	--ath-accent: #C6291F;
	--ath-ink: #1A1A1A;
	--ath-grey: #55504C;
	--ath-line: #ECE8E4;
	--ath-muted: #8A8580;
	--ath-hover: #F6F3F1;
	--ath-chip: #F1EDEA;
	--ath-tint: #FBF1EF;
	--ath-ease: cubic-bezier(0.22, 0.61, 0.36, 1);

	list-style: none;
	/* Negativna margina + padding u retku = tekst poravnat s naslovom widgeta,
	   a hover podloga se proteže do rubova kutije. */
	margin: 0 -8px;
	padding: 0;
	font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.product-categories li.cat-item {
	list-style: none;
	margin: 0;
	padding: 0;
	position: relative;
}

/* Hairline samo između kategorija prve razine. */
.product-categories > li.cat-item + li.cat-item {
	border-top: 1px solid var(--ath-line);
}

/* ---- Redak kategorije: naziv + broj + strelica, uvijek u jednom redu. ---- */
.product-categories .ath-cat-row {
	display: flex;
	align-items: center;
	flex-wrap: nowrap;
	gap: 6px;
	padding: 8px 8px;
	margin: 1px 0;
	border-radius: 8px;
	transition: background-color 0.16s var(--ath-ease);
}

.product-categories .ath-cat-row:hover {
	background-color: var(--ath-hover);
}

.product-categories .children .ath-cat-row {
	padding: 6px 8px;
}

.product-categories .ath-cat-row > a {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--ath-ink);
	text-decoration: none;
	font-size: 12.5px;
	line-height: 1.35;
	font-weight: 700;
	letter-spacing: 0.005em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: color 0.16s var(--ath-ease);
}

.product-categories .children .ath-cat-row > a {
	font-size: 11.5px;
	font-weight: 500;
	color: var(--ath-grey);
}

.product-categories .ath-cat-row > a:hover {
	color: var(--ath-accent);
}

.product-categories .ath-cat-row > a:focus-visible {
	outline: 2px solid var(--ath-accent);
	outline-offset: 2px;
	border-radius: 4px;
}

/* ---- Broj proizvoda ---- */
.product-categories .ath-cat-count,
.product-categories .count {
	flex: 0 0 auto;
	font-size: 10px;
	font-weight: 600;
	line-height: 1;
	color: var(--ath-muted);
	font-variant-numeric: tabular-nums;
	padding: 3px 6px;
	border-radius: 999px;
	background-color: var(--ath-chip);
	white-space: nowrap;
}

.product-categories .ath-cat-count[data-empty="1"] {
	opacity: 0.5;
}

/* ---- Strelica (span, ne button — da je ne diraju stilovi teme za gumbe) ---- */
.product-categories .ath-cat-toggle {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: none;
	box-shadow: none;
	color: var(--ath-ink);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: color 0.16s var(--ath-ease);
}

.product-categories .ath-cat-toggle:hover {
	background: none;
	color: var(--ath-accent);
}

.product-categories .ath-cat-toggle:focus-visible {
	outline: 2px solid var(--ath-accent);
	outline-offset: 1px;
}

.product-categories .ath-cat-toggle svg {
	display: block;
	width: 11px;
	height: 11px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 0.22s var(--ath-ease);
	pointer-events: none;
}

.product-categories li.ath-cat-open > .ath-cat-row > .ath-cat-toggle svg {
	transform: rotate(180deg);
}

/* ---- Aktivna kategorija ---- */
.product-categories li.current-cat > .ath-cat-row {
	background-color: var(--ath-tint);
}

.product-categories li.current-cat > .ath-cat-row > a,
.product-categories li.current-cat > .ath-cat-row > .ath-cat-toggle {
	color: var(--ath-accent);
}

.product-categories li.current-cat > .ath-cat-row > a {
	font-weight: 700;
}

.product-categories li.current-cat > .ath-cat-row .ath-cat-count {
	background-color: rgba(198, 41, 31, 0.10);
	color: var(--ath-accent);
	opacity: 1;
}

/* ---- Podkategorije: tanka vodilica umjesto uvlaka po razini ---- */
.product-categories ul.children {
	list-style: none;
	margin: 0 0 4px 9px;
	padding: 0 0 0 9px;
	border-left: 1px solid var(--ath-line);
	display: none;
}

.product-categories li.ath-cat-open > ul.children {
	display: block;
	animation: ath-cat-in 0.2s var(--ath-ease) both;
}

@keyframes ath-cat-in {
	from {
		opacity: 0;
		transform: translateY(-3px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ---- Fallback dok JS ne odradi (ili ako ne odradi): i tada sve u jednom redu. ---- */
.product-categories li.cat-item:not(.ath-cat-ready) {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	padding: 8px 8px;
}

.product-categories li.cat-item:not(.ath-cat-ready) > a {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--ath-ink);
	font-size: 12.5px;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.product-categories li.cat-item:not(.ath-cat-ready) > ul.children {
	flex-basis: 100%;
}

@media (prefers-reduced-motion: reduce) {

	.product-categories .ath-cat-toggle svg,
	.product-categories .ath-cat-row {
		transition-duration: 0.01ms;
	}

	.product-categories li.ath-cat-open > ul.children {
		animation: none;
	}
}

/* Veca dodirna povrsina za strelicu na tabletu i mobitelu. */
@media (max-width: 1024px) {

	.product-categories .ath-cat-toggle {
		width: 30px;
		height: 30px;
		margin-right: -4px;
	}
}

/* ---- Poruka kad u kategoriji jos nema proizvoda ---- */
.ath-empty-grid {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	padding: 32px 28px;
	border: 1px dashed #E2DCD7;
	border-radius: 16px;
	background-color: #FFFFFF;
	font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
	color: #55504C;
}

.ath-empty-grid strong {
	font-family: Archivo, Inter, system-ui, sans-serif;
	font-size: 17px;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: #1A1A1A;
}

.ath-empty-grid span {
	font-size: 13px;
	line-height: 1.5;
}

.ath-empty-grid-link {
	margin-top: 8px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #C6291F;
	text-decoration: none;
	border-bottom: 1px solid rgba(198, 41, 31, 0.3);
	padding-bottom: 2px;
	transition: color 0.16s ease, border-color 0.16s ease;
}

.ath-empty-grid-link:hover {
	color: #A32218;
	border-bottom-color: #A32218;
}
