/**
 * TS Filtros — barra horizontal.
 * Herda tipografia do tema de propósito; só controla estrutura, espaço e estado.
 */

.tsf-bar {
	--tsf-border: rgba(0, 0, 0, .16);
	--tsf-muted: rgba(0, 0, 0, .55);
	--tsf-surface: #fff;
	--tsf-radius: 4px;

	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 24px;
	padding: 0 0 16px;
	border-bottom: 1px solid var(--tsf-border);
	position: relative;
	z-index: 20;
}

.tsf-bar--sticky {
	position: sticky;
	top: 0;
	background: var(--tsf-surface);
	padding-top: 12px;
}

.tsf-bar__group {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
}

.tsf-bar__group--end {
	margin-left: auto;
}

/* --- Botões da barra --- */

.tsf-drop {
	position: relative;
}

.tsf-drop__toggle,
.tsf-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	border: 1px solid var(--tsf-border);
	border-radius: var(--tsf-radius);
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: .82em;
	letter-spacing: .08em;
	text-transform: uppercase;
	text-decoration: none;
	line-height: 1.1;
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.tsf-drop__toggle:hover,
.tsf-toggle:hover {
	border-color: currentColor;
}

.tsf-drop.is-active .tsf-drop__toggle {
	border-color: var(--tsf-accent, #111);
	box-shadow: inset 0 0 0 1px var(--tsf-accent, #111);
}

.tsf-drop.is-open .tsf-drop__toggle {
	border-color: var(--tsf-accent, #111);
}

.tsf-drop__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--tsf-accent, #111);
	color: #fff;
	font-size: .75em;
	letter-spacing: 0;
}

.tsf-caret {
	width: 8px;
	height: 8px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg) translate(-2px, -2px);
	transition: transform .18s ease;
}

.tsf-drop.is-open .tsf-caret {
	transform: rotate(225deg) translate(-1px, -1px);
}

/* Botão de promoções ligado: cheio, como no layout de referência. */
.tsf-toggle.is-on {
	background: var(--tsf-accent, #111);
	border-color: var(--tsf-accent, #111);
	color: #fff;
}

.tsf-clear {
	padding: 10px 6px;
	font-size: .82em;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--tsf-muted);
	text-decoration: none;
	border-bottom: 1px solid transparent;
}

.tsf-clear:hover {
	color: inherit;
	border-bottom-color: currentColor;
}

/* --- Painéis --- */

.tsf-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	min-width: 260px;
	max-width: min(92vw, 420px);
	padding: 18px 20px 20px;
	background: var(--tsf-surface);
	border: 1px solid var(--tsf-border);
	border-radius: var(--tsf-radius);
	box-shadow: 0 12px 28px -18px rgba(0, 0, 0, .45);
	z-index: 30;
}

.tsf-panel[hidden] {
	display: none;
}

.tsf-bar__group--end .tsf-panel {
	left: auto;
	right: 0;
}

/* Cabeçalho fica parado enquanto a lista rola. */
.tsf-panel__head {
	position: sticky;
	top: 0;
	z-index: 1;
	background: var(--tsf-surface);
	padding: 0 0 12px;
	margin: 0;
}

.tsf-panel__title {
	margin: 0;
	font-size: .78em;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--tsf-muted);
}

.tsf-search {
	width: 100%;
	margin-top: 10px;
	padding: 8px 10px;
	border: 1px solid var(--tsf-border);
	border-radius: var(--tsf-radius);
	font: inherit;
	font-size: .88em;
	background: transparent;
	color: inherit;
}

.tsf-panel__scroll {
	max-height: min(52vh, 420px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding-right: 4px;
}

.tsf-panel__empty {
	padding: 14px 2px;
	font-size: .85em;
	color: var(--tsf-muted);
}

/* --- Swatches de cor --- */

.tsf-panel--swatches {
	min-width: 400px;
	max-width: min(92vw, 520px);
}

.tsf-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
	gap: 18px 10px;
	align-content: start;
}

.tsf-swatch {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	text-align: center;
	text-decoration: none;
	color: inherit;
	font-size: .78em;
	line-height: 1.25;
}

.tsf-swatch__dot {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, .18);
	box-shadow: 0 0 0 0 transparent;
	transition: box-shadow .15s ease;
}

.tsf-swatch__dot[data-empty] {
	background: repeating-linear-gradient(45deg, #eee, #eee 4px, #fff 4px, #fff 8px);
}

.tsf-swatch.is-on .tsf-swatch__dot {
	box-shadow: 0 0 0 2px var(--tsf-surface), 0 0 0 4px var(--tsf-accent, #111);
}

.tsf-swatch.is-on .tsf-swatch__name {
	font-weight: 600;
}

.tsf-swatch__name {
	word-break: break-word;
}

/* --- Lista comum (tamanho, ordenação...) --- */

.tsf-options {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tsf-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 6px;
	border-radius: var(--tsf-radius);
	text-decoration: none;
	color: inherit;
	font-size: .9em;
}

.tsf-option:hover {
	background: rgba(0, 0, 0, .04);
}

.tsf-box {
	flex: none;
	width: 16px;
	height: 16px;
	border: 1px solid var(--tsf-border);
	border-radius: 3px;
	position: relative;
}

.tsf-option.is-on .tsf-box {
	background: var(--tsf-accent, #111);
	border-color: var(--tsf-accent, #111);
}

.tsf-option.is-on .tsf-box::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 1px;
	width: 4px;
	height: 9px;
	border-right: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(45deg);
}

.tsf-drop--sort .tsf-box {
	border-radius: 50%;
}

.tsf-drop--sort .tsf-option.is-on .tsf-box::after {
	display: none;
}

.tsf-option__name {
	flex: 1 1 auto;
}

.tsf-count {
	color: var(--tsf-muted);
	font-size: .85em;
	font-variant-numeric: tabular-nums;
}

/* --- Preço --- */

.tsf-price__inputs {
	display: flex;
	gap: 12px;
}

.tsf-price__inputs label {
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: .78em;
	color: var(--tsf-muted);
}

.tsf-price__inputs input {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--tsf-border);
	border-radius: var(--tsf-radius);
	font: inherit;
	font-size: .9em;
	background: transparent;
	color: inherit;
}

.tsf-price__hint {
	margin: 10px 0 0;
	font-size: .78em;
	color: var(--tsf-muted);
}

.tsf-price__actions {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-top: 14px;
}

.tsf-btn {
	padding: 9px 18px;
	border: 0;
	border-radius: var(--tsf-radius);
	background: var(--tsf-accent, #111);
	color: #fff;
	font: inherit;
	font-size: .82em;
	letter-spacing: .06em;
	text-transform: uppercase;
	cursor: pointer;
}

.tsf-link {
	color: var(--tsf-muted);
	font-size: .82em;
	text-decoration: underline;
}

/* --- Chips --- */

.tsf-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: -12px 0 20px;
}

.tsf-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border: 1px solid var(--tsf-border, rgba(0, 0, 0, .16));
	border-radius: 999px;
	font-size: .82em;
	text-decoration: none;
	color: inherit;
}

.tsf-chip:hover {
	border-color: currentColor;
}

.tsf-chip__x {
	font-size: 1.1em;
	line-height: 1;
	opacity: .6;
}

.tsf-group {
	margin: 14px 0 6px;
	padding-top: 12px;
	border-top: 1px solid var(--tsf-border);
	font-size: .72em;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--tsf-muted);
}

.tsf-group:first-child {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

/* --- Estado de carregamento --- */

.tsf-loading {
	opacity: .45;
	transition: opacity .2s ease;
	pointer-events: none;
}

.tsf-empty {
	padding: 40px 0;
	text-align: center;
	color: rgba(0, 0, 0, .6);
}

/* --- Foco visível --- */

.tsf-drop__toggle:focus-visible,
.tsf-toggle:focus-visible,
.tsf-option:focus-visible,
.tsf-swatch:focus-visible,
.tsf-chip:focus-visible,
.tsf-clear:focus-visible,
.tsf-btn:focus-visible {
	outline: 2px solid var(--tsf-accent, #111);
	outline-offset: 2px;
}

/* --- Mobile --- */

@media (max-width: 782px) {
	.tsf-bar {
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: visible;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.tsf-bar::-webkit-scrollbar {
		display: none;
	}

	.tsf-bar__group {
		flex-wrap: nowrap;
	}

	.tsf-bar__group--end {
		margin-left: 0;
	}

	.tsf-drop__toggle,
	.tsf-toggle {
		white-space: nowrap;
	}

	/* Painel vira folha centralizada, para não estourar a borda da tela. */
	/* Folha descolada das bordas: sobra margem no rodapé mesmo em tela com gesto. */
	.tsf-panel,
	.tsf-panel--swatches {
		position: fixed;
		top: auto;
		bottom: calc(16px + env(safe-area-inset-bottom, 0px));
		left: 12px;
		right: 12px;
		min-width: 0;
		max-width: none;
		max-height: calc(70vh - env(safe-area-inset-bottom, 0px));
		overflow-y: auto;
		border-radius: 12px;
		box-shadow: 0 -8px 40px -12px rgba(0, 0, 0, .4);
	}

	.tsf-panel__scroll {
		max-height: 46vh;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tsf-caret,
	.tsf-loading,
	.tsf-swatch__dot {
		transition: none;
	}
}
