/* Tour filters sidebar (TourFilters\FilterRenderer) — Country Tours and
   Tour Results (list). Desktop: a column beside the tour list, same card
   language as the tour cards. Tablet / phone (≤1024px): a "ตัวกรอง" button
   that opens the panel as a bottom drawer.
   Selectors carry `.tpo-root .tpo-tf` so the theme's global button / input
   rules (borders, hover colours, padding) never reach these controls. */

.tpo-tf {
	--tpo-tf-accent: var(--tpo-ct-accent, var(--e-global-color-primary, #2563eb));
	--tpo-tf-border: var(--tpo-ct-border, color-mix(in srgb, var(--e-global-color-text, #64748b) 14%, transparent));
	--tpo-tf-muted: var(--tpo-ct-muted, color-mix(in srgb, var(--e-global-color-text, #334155) 62%, transparent));
	--tpo-tf-soft: color-mix(in srgb, var(--tpo-tf-accent) 8%, #fff);
	font-family: inherit;
	color: var(--e-global-color-text, inherit);
}

/* Layout: filters | tours (or tours | filters). */
.tpo-ct__layout.has-filters {
	display: grid;
	grid-template-columns: var(--tpo-tf-width, 300px) minmax(0, 1fr);
	gap: var(--tpo-tf-gap, 20px);
	align-items: start;
}

.tpo-ct__layout.has-filters.is-filters-right {
	grid-template-columns: minmax(0, 1fr) var(--tpo-tf-width, 300px);
}

.tpo-ct__layout.has-filters.is-filters-right > .tpo-tf {
	order: 2;
}

.tpo-ct__main {
	min-width: 0;
}

/* Narrower card columns beside the sidebar (Elementor values still win). */
.tpo-root.tpo-ct:has(.tpo-ct__layout.has-filters) {
	--tpo-ct-media-width: 280px;
	--tpo-ct-aside-width: 232px;
}

/* Card beside the sidebar (desktop): title kept to two lines, tighter
   chips / buttons (the photo stays a 1:1 square like everywhere else). */
@media (min-width: 1025px) {
	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__card-title {
		display: -webkit-box;
		overflow: hidden;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		font-size: 1.0625rem;
	}

	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__body {
		padding: 18px 20px;
	}

	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__date {
		padding: 4px 10px;
		font-size: 0.8125rem;
	}

	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__aside {
		padding: 18px 16px;
	}

	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__docs--many a.tpo-ct__pdf {
		padding-left: 6px;
		padding-right: 6px;
		font-size: 0.8125rem;
	}
}

/* —— Panel —— */

.tpo-root .tpo-tf__panel {
	padding: 18px 18px 8px;
	border: 1px solid var(--tpo-tf-border);
	border-radius: var(--tpo-ct-radius, 18px);
	background: #fff;
}

.tpo-tf__toggle,
.tpo-tf__close,
.tpo-tf__backdrop {
	display: none;
}

.tpo-tf__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--tpo-tf-border);
}

.tpo-tf__title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.3;
}

.tpo-tf__actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.tpo-root .tpo-tf .tpo-tf__btn,
.tpo-root .tpo-tf .tpo-tf__btn:visited {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: auto;
	height: auto;
	min-height: 32px;
	margin: 0;
	padding: 5px 12px;
	border: 1px solid var(--tpo-tf-accent);
	border-radius: 999px;
	background: var(--tpo-tf-accent);
	box-shadow: none;
	color: #fff;
	font-family: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, filter 0.2s ease;
}

.tpo-root .tpo-tf .tpo-tf__btn:hover,
.tpo-root .tpo-tf .tpo-tf__btn:focus-visible {
	border-color: var(--tpo-tf-accent);
	background: var(--tpo-tf-accent);
	color: #fff;
	filter: brightness(1.08);
}

.tpo-root .tpo-tf .tpo-tf__btn--clear,
.tpo-root .tpo-tf .tpo-tf__btn--clear:visited {
	background: transparent;
	color: var(--tpo-tf-accent);
}

.tpo-root .tpo-tf .tpo-tf__btn--clear:hover,
.tpo-root .tpo-tf .tpo-tf__btn--clear:focus-visible {
	background: var(--tpo-tf-soft);
	color: var(--tpo-tf-accent);
	filter: none;
}

/* Groups: divided list (no box per group). */
.tpo-tf__groups {
	display: flex;
	flex-direction: column;
}

.tpo-tf__group {
	border-bottom: 1px solid var(--tpo-tf-border);
}

.tpo-tf__group:last-child {
	border-bottom: 0;
}

.tpo-tf__group-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 2px;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
	list-style: none;
	user-select: none;
}

.tpo-tf__group-title::-webkit-details-marker {
	display: none;
}

.tpo-tf__group-title:hover {
	color: var(--tpo-tf-accent);
}

.tpo-tf__icon--chevron {
	flex: 0 0 auto;
	color: var(--tpo-tf-muted);
	transition: transform 0.2s ease;
}

.tpo-tf__group[open] .tpo-tf__icon--chevron {
	transform: rotate(180deg);
}

.tpo-tf__group-body {
	padding: 0 2px 14px;
}

.tpo-tf__options {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tpo-tf__group-body:not(.is-expanded) .tpo-tf__option:nth-child(n + 7) {
	display: none;
}

.tpo-tf__check {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 32px;
	padding: 4px 6px;
	margin: 0 -6px;
	border-radius: 8px;
	font-size: 0.875rem;
	line-height: 1.35;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.tpo-tf__check:hover {
	background: var(--tpo-tf-soft);
}

.tpo-root .tpo-tf .tpo-tf__check input {
	flex: 0 0 auto;
	width: 17px;
	height: 17px;
	margin: 0;
	accent-color: var(--tpo-tf-accent);
	cursor: pointer;
}

.tpo-tf__label {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

.tpo-tf__count {
	flex: 0 0 auto;
	min-width: 26px;
	padding: 1px 7px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--e-global-color-text, #334155) 6%, transparent);
	color: var(--tpo-tf-muted);
	font-size: 0.75rem;
	line-height: 1.5;
	text-align: center;
}

.tpo-tf__check:has(input:checked) .tpo-tf__label {
	font-weight: 600;
}

.tpo-tf__check:has(input:checked) .tpo-tf__count {
	background: var(--tpo-tf-accent);
	color: #fff;
}

.tpo-tf__option.is-empty {
	opacity: 0.45;
}

.tpo-root .tpo-tf .tpo-tf__more {
	display: inline-flex;
	width: auto;
	height: auto;
	margin: 6px 0 0;
	padding: 2px 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--tpo-tf-accent);
	font-family: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	cursor: pointer;
}

.tpo-root .tpo-tf .tpo-tf__more:hover {
	background: none;
	color: var(--tpo-tf-accent);
	text-decoration: underline;
}

/* Price range. */
.tpo-tf__price {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	align-items: end;
	gap: 8px;
}

.tpo-tf__price-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.tpo-tf__price-label {
	color: var(--tpo-tf-muted);
	font-size: 0.75rem;
}

.tpo-root .tpo-tf .tpo-tf__input {
	width: 100%;
	min-width: 0;
	height: 38px;
	margin: 0;
	padding: 6px 10px;
	border: 1px solid var(--tpo-tf-border);
	border-radius: 10px;
	background: #fff;
	box-shadow: none;
	color: inherit;
	font-family: inherit;
	font-size: 0.875rem;
	line-height: 1.2;
	-moz-appearance: textfield;
	appearance: textfield;
}

.tpo-root .tpo-tf .tpo-tf__input::-webkit-outer-spin-button,
.tpo-root .tpo-tf .tpo-tf__input::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

.tpo-root .tpo-tf .tpo-tf__input:focus {
	border-color: var(--tpo-tf-accent);
	outline: 2px solid color-mix(in srgb, var(--tpo-tf-accent) 25%, transparent);
	outline-offset: 0;
}

.tpo-tf__price-sep {
	padding-bottom: 9px;
	color: var(--tpo-tf-muted);
}

.tpo-tf__form.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

/* Desktop: the sidebar stays in view while the tour list scrolls, below the
   site's fixed header (offset: Style → Filters sidebar → Sticky offset).
   A panel taller than the screen scrolls inside itself. */
@media (min-width: 1025px) {
	.tpo-ct__layout.has-filters > .tpo-tf {
		--tpo-tf-top: var(--tpo-tf-sticky-top, 84px);
		position: sticky;
		top: var(--tpo-tf-top);
		align-self: start;
	}

	body.admin-bar .tpo-ct__layout.has-filters > .tpo-tf {
		--tpo-tf-top: calc(var(--tpo-tf-sticky-top, 84px) + 32px);
	}

	.tpo-root .tpo-ct__layout.has-filters .tpo-tf__panel {
		max-height: calc(100vh - var(--tpo-tf-top) - 16px);
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-width: thin;
	}
}

/* —— Tablet / phone: button + bottom drawer —— */

@media (max-width: 1024px) {
	.tpo-ct__layout.has-filters,
	.tpo-ct__layout.has-filters.is-filters-right {
		display: block;
	}

	.tpo-root .tpo-tf .tpo-tf__toggle {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		width: auto;
		height: auto;
		min-height: 44px;
		margin: 0 0 14px;
		padding: 8px 18px;
		border: 1px solid var(--tpo-tf-border);
		border-radius: 999px;
		background: #fff;
		box-shadow: none;
		color: inherit;
		font-family: inherit;
		font-size: 0.9375rem;
		font-weight: 600;
		cursor: pointer;
	}

	.tpo-root .tpo-tf .tpo-tf__toggle:hover {
		border-color: var(--tpo-tf-accent);
		background: #fff;
		color: var(--tpo-tf-accent);
	}

	.tpo-tf__badge {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 22px;
		height: 22px;
		padding: 0 6px;
		border-radius: 999px;
		background: var(--tpo-tf-accent);
		color: #fff;
		font-size: 0.75rem;
	}

	.tpo-root .tpo-tf__panel {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 100001;
		max-height: 85vh;
		max-height: 85dvh;
		overflow: auto;
		overscroll-behavior: contain;
		padding: 0 18px max(16px, env(safe-area-inset-bottom));
		border: 0;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.18);
		transform: translateY(100%);
		visibility: hidden;
		transition: transform 0.28s ease, visibility 0s 0.28s;
	}

	.tpo-tf.is-open .tpo-tf__panel {
		transform: none;
		visibility: visible;
		transition: transform 0.28s ease, visibility 0s;
	}

	.tpo-tf__head {
		position: sticky;
		top: 0;
		z-index: 1;
		margin: 0 -18px;
		padding: 16px 18px 14px;
		background: #fff;
	}

	.tpo-root .tpo-tf .tpo-tf__close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 36px;
		height: 36px;
		margin: 0 0 0 2px;
		padding: 0;
		border: 0;
		border-radius: 999px;
		background: transparent;
		box-shadow: none;
		color: inherit;
		font-size: 1.25rem;
		cursor: pointer;
	}

	.tpo-root .tpo-tf .tpo-tf__close:hover {
		background: var(--tpo-tf-soft);
		color: inherit;
	}

	.tpo-tf__backdrop:not([hidden]) {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 100000;
		background: rgba(15, 23, 42, 0.45);
	}

	html.tpo-tf-lock,
	html.tpo-tf-lock body {
		overflow: hidden;
	}
}

@media (pointer: coarse) {
	.tpo-tf__check {
		min-height: 44px;
	}

	.tpo-root .tpo-tf .tpo-tf__btn {
		min-height: 44px;
		padding-left: 16px;
		padding-right: 16px;
	}

	.tpo-root .tpo-tf .tpo-tf__close {
		width: 44px;
		height: 44px;
	}

	.tpo-tf__group-title {
		min-height: 48px;
	}

	.tpo-root .tpo-tf .tpo-tf__input {
		height: 44px;
	}

	.tpo-root .tpo-tf .tpo-tf__more {
		min-height: 44px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tpo-root .tpo-tf__panel,
	.tpo-tf__icon--chevron {
		transition: none;
	}
}

/* Laptop (1025–1366): with the sidebar there is no room for three card
   columns — use the tablet card (photo | details, price + buttons as a row
   across the bottom), so the details are as tall as the square photo. */
@media (min-width: 1025px) and (max-width: 1366px) {
	.tpo-ct__layout.has-filters {
		--tpo-tf-width: 260px;
	}

	.tpo-ct__layout.has-filters .tpo-ct__card {
		grid-template-columns: var(--tpo-ct-media-width) minmax(0, 1fr);
	}

	.tpo-ct__layout.has-filters .tpo-ct__aside {
		grid-column: 1 / -1;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		padding: 14px 20px;
		border-left: 0;
		border-top: 1px solid var(--tpo-ct-border);
		text-align: left;
	}

	.tpo-ct__layout.has-filters .tpo-ct__price {
		align-items: flex-start;
	}

	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__btn {
		min-width: 180px;
	}

	.tpo-ct__layout.has-filters .tpo-ct__aside:has(.tpo-ct__docs) {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto auto;
		column-gap: 12px;
	}

	.tpo-root.tpo-ct .tpo-ct__layout.has-filters .tpo-ct__aside .tpo-ct__docs {
		grid-column: auto;
		margin: 0;
	}
}
