/**
 * Mobile / tablet: filter becomes a bottom sheet.
 * Loaded with media="(max-width: 767px)" or "(max-width: 1024px)" from settings.
 */

.tbf-wrap.tbf-has-sheet .tbf-float {
	display: inline-flex !important;
	position: fixed;
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	left: 50%;
	transform: translateX(-50%);
	z-index: 99990;
	align-items: center;
	gap: 8px;
	padding: 12px 20px;
	border: none;
	border-radius: 999px;
	background: var(--tbf-accent);
	color: #fff;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25);
	cursor: pointer;
	direction: rtl;
	-webkit-tap-highlight-color: transparent;
}

.tbf-wrap.tbf-has-sheet .tbf-float.tbf-float--off,
html.tbf-has-view-bar .tbf-wrap.tbf-has-sheet .tbf-float,
html:has(.tbf-view__filter) .tbf-wrap.tbf-has-sheet .tbf-float {
	display: none !important;
}

.tbf-view .tbf-view__filter {
	display: inline-flex !important;
	align-items: center;
	gap: 6px;
	height: 38px;
	padding: 0 14px;
	border: 1px solid var(--tbf-list-border);
	border-radius: 8px;
	background: #fff;
	color: var(--tbf-list-title-color);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

.tbf-float__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: #fff;
	color: var(--tbf-accent);
	font-size: 12px;
	font-weight: 700;
	box-sizing: border-box;
}

.tbf-view__filter .tbf-float__count {
	background: var(--tbf-view-accent);
	color: #fff;
}

.tbf-float__count[hidden] {
	display: none !important;
}

/* Sheet */
.tbf-wrap.tbf-has-sheet .tbf-sheet {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	max-height: 85vh;
	max-height: 85dvh;
	background: #fff;
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.2);
	transform: translateY(105%);
	visibility: hidden;
	transition: transform 0.25s ease, visibility 0s linear 0.25s;
	direction: rtl;
}

.tbf-wrap.tbf-has-sheet.tbf-sheet-open .tbf-sheet {
	transform: translateY(0);
	visibility: visible;
	transition: transform 0.25s ease, visibility 0s;
}

.tbf-wrap.tbf-has-sheet .tbf-sheet-backdrop {
	display: block !important;
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: rgba(15, 23, 42, 0.45);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.tbf-wrap.tbf-has-sheet .tbf-sheet-backdrop[hidden] {
	display: none !important;
}

.tbf-wrap.tbf-has-sheet.tbf-sheet-open .tbf-sheet-backdrop {
	opacity: 1;
}

.tbf-wrap.tbf-has-sheet .tbf-sheet__head {
	display: flex !important;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px 10px;
	border-bottom: 1px solid var(--tbf-border);
}

.tbf-wrap.tbf-has-sheet .tbf-sheet__head::before {
	content: '';
	position: absolute;
	top: 6px;
	left: 50%;
	width: 40px;
	height: 4px;
	margin-left: -20px;
	border-radius: 999px;
	background: #cbd5e0;
}

.tbf-sheet__title {
	font-size: 15px;
	font-weight: 700;
	color: var(--tbf-text);
}

.tbf-wrap .tbf-sheet__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0 !important;
	border: none !important;
	border-radius: 50%;
	background: #f1f5f9 !important;
	color: var(--tbf-text) !important;
	cursor: pointer;
}

.tbf-wrap.tbf-has-sheet .tbf-filter {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	padding: 8px 8px 12px;
}

/* Bigger touch targets */
.tbf-wrap.tbf-has-sheet .tbf-row {
	min-height: 44px;
}

.tbf-wrap.tbf-has-sheet .tbf-parent-check,
.tbf-wrap.tbf-has-sheet .tbf-parent-toggle {
	min-height: 44px;
}

.tbf-wrap.tbf-has-sheet .tbf-sheet__foot {
	display: flex !important;
	gap: 10px;
	padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--tbf-border);
	background: #fff;
}

.tbf-wrap .tbf-sheet__clear,
.tbf-wrap .tbf-sheet__apply {
	height: 46px;
	border-radius: 10px;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}

.tbf-wrap .tbf-sheet__clear {
	flex: 0 0 auto;
	padding: 0 18px;
	border: 1px solid var(--tbf-border) !important;
	background: #fff !important;
	color: var(--tbf-text) !important;
}

.tbf-wrap .tbf-sheet__apply {
	flex: 1 1 auto;
	border: none !important;
	background: var(--tbf-accent) !important;
	color: #fff !important;
}

html.tbf-sheet-locked,
html.tbf-sheet-locked body {
	overflow: hidden !important;
}

/* No pending bar inside the sheet (nothing applies until the button) */
.tbf-wrap.tbf-has-sheet .tbf-filter[data-tbf-pending]::after {
	display: none;
}
