/* Kilagbe -- Search geo selection panel (Khatian Book-style), 1.0.0 (2026-10-08).
 * 1.0.4 (2026-10-10): UI-only -- slightly smaller font sizes across the panel
 *   (title/current/badge/search-input/option text); no layout/markup/logic
 *   change. Mobile <=560px sizes (16px search-input, 15px option) left as-is
 *   on purpose (iOS zoom guard / touch-target size).
 * 1.0.5 (2026-10-10): UI-only -- trimmed the excess vertical whitespace
 *   around each line of text that 1.0.4's smaller font left behind. Head
 *   60->52px, search row 41->36px, option row min-height 50->40px (mobile
 *   48->40px) with tighter padding/line-height; list-row heights reduced to
 *   match at all 3 breakpoints; Khatian Type chip 44->36px. No grid
 *   structure, markup, class, or breakpoint added/removed -- only existing
 *   row-height/padding/line-height values changed.
 * 1.0.1 (2026-10-09): added .kgp-panel.is-disabled (locked) state for
 *   District/Upazila/Mouza, reusing kilagbe-khatian-search.css's muted tokens.
 * 1.0.2 (2026-10-09): fixed-size layout -- .kgp-panel is now a 3-row CSS grid
 *   (head / search / list-or-empty) with fixed row heights, so typing a
 *   search, a changing result count, a selection, or an empty result never
 *   changes a box's outer size or position. .kgp-list and .kgp-empty share
 *   the same (3rd) row and overlap rather than stack; the locked-state
 *   .kgp-empty spans rows 2-4 since it has no search/list siblings.
 * 1.0.3 (2026-10-09): Khatian Type only -- compact chip grid for its 5 short
 *   items (was a tall, mostly-empty single column), and the box now stays
 *   hidden until বিভাগ->জেলা->উপজেলা are all selected, read from উপজেলার
 *   own existing .is-selected state via :has() (no PHP/JS change).
 * Presentation layer only. Data/order come from kilagbe-geo-panel.php.
 * Loaded only on /khatian-search/, after kilagbe-khatian-search.css.
 * Kilagbe tokens: #0E6B4F green, #0A4E3A dark green, #E7F2ED mint, #E4E1D8 border, #1B231F text, #5C6B64 muted.
 */

/* The 1.2.0 layer visually hides every .facetwp-type-dropdown wrapper (it draws
 * popups beside them). A facet that hosts a server-rendered .kgp-panel must stay
 * visible -- only its native select is hidden. */
.kilagbe-khatian-search .kilagbe-khatian-field .facetwp-facet.facetwp-type-dropdown:has(.kgp-panel),
.kilagbe-khatian-search .kilagbe-khatian-field.kgp-field .facetwp-facet.facetwp-type-dropdown {
	position: static;
	width: auto;
	height: auto;
	margin: 0;
	padding: 0;
	overflow: visible;
	clip: auto;
	clip-path: none;
	white-space: normal;
}

/* The panel carries its own title + count badge. */
.kilagbe-khatian-search .kilagbe-khatian-field:has(.kgp-panel) > .kilagbe-khatian-field-label,
.kilagbe-khatian-search .kilagbe-khatian-field.kgp-field > .kilagbe-khatian-field-label {
	display: none;
}

.kilagbe-khatian-search .kgp-native {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: 0 !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	clip-path: inset(50%) !important;
	border: 0 !important;
	white-space: nowrap !important;
}

.kilagbe-khatian-search .kgp-panel {
	display: grid;
	grid-template-rows: 52px 36px 360px; /* head / search / list-or-empty -- fixed so the box never resizes */
	background: #fff;
	border: 1px solid #D5E6DC;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(27, 35, 31, 0.05);
	color: #1B231F;
	min-width: 0;
}

/* Header: title + selected value, count badge on the right */
.kilagbe-khatian-search .kgp-head {
	grid-row: 1;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
	height: 52px;
	padding: 7px 12px 6px;
	background: linear-gradient(180deg, #E1F3EA 0%, #F3FAF6 100%);
	border-bottom: 1px solid #E4E1D8;
	box-sizing: border-box;
}

.kilagbe-khatian-search .kgp-head-main {
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

.kilagbe-khatian-search .kgp-title {
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	color: #1B231F;
}

.kilagbe-khatian-search .kgp-current {
	display: flex;
	align-items: center;
	gap: 5px;
	min-width: 0;
	font-size: 12px;
	line-height: 1.3;
	color: #7A8780;
}

.kilagbe-khatian-search .kgp-current-text {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.kilagbe-khatian-search .kgp-current-icon {
	display: none;
	flex: 0 0 14px;
	width: 14px;
	height: 14px;
	color: #0E6B4F;
}

.kilagbe-khatian-search .kgp-panel.is-selected .kgp-current {
	color: #0E6B4F;
	font-weight: 600;
}

.kilagbe-khatian-search .kgp-panel.is-selected .kgp-current-icon {
	display: inline-block;
}

.kilagbe-khatian-search .kgp-badge {
	flex: 0 0 auto;
	font-size: 11px;
	font-weight: 500;
	line-height: 1.5;
	color: #5C6B64;
	background: #fff;
	border: 1px solid #E4E1D8;
	border-radius: 999px;
	padding: 2px 10px;
	white-space: nowrap;
}

/* In-panel search */
.kilagbe-khatian-search .kgp-search {
	grid-row: 2;
	display: flex;
	align-items: center;
	gap: 8px;
	height: 36px;
	margin: 0;
	padding: 0 12px;
	background: #fff;
	border-bottom: 1px solid #E4E1D8;
	cursor: text;
	box-sizing: border-box;
}

.kilagbe-khatian-search .kgp-search:focus-within {
	box-shadow: inset 0 -2px 0 #0E6B4F;
}

.kilagbe-khatian-search .kgp-search-icon {
	flex: 0 0 16px;
	width: 16px;
	height: 16px;
	color: #8A958F;
}

.kilagbe-khatian-search .kgp-panel .kgp-search-input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	margin: 0;
	padding: 8px 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	outline: none;
	font: inherit;
	font-size: 13px;
	line-height: 1.3;
	color: #1B231F;
	-webkit-appearance: none;
	appearance: none;
}

.kilagbe-khatian-search .kgp-panel .kgp-search-input::placeholder {
	color: #8A958F;
	opacity: 1;
}

/* Option list */
.kilagbe-khatian-search .kgp-panel .kgp-list {
	grid-row: 3;
	list-style: none;
	margin: 0;
	padding: 0;
	height: 100%;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: #C9D3CE transparent;
}

.kilagbe-khatian-search .kgp-panel .kgp-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-height: 40px;
	margin: 0;
	padding: 7px 12px 7px 13px;
	border-bottom: 1px solid #EEF1EF;
	border-left: 3px solid transparent;
	font-size: 14px;
	line-height: 1.25;
	color: #1B231F;
	cursor: pointer;
	transition: background-color 120ms ease;
}

.kilagbe-khatian-search .kgp-panel .kgp-option:last-child {
	border-bottom: 0;
}

.kilagbe-khatian-search .kgp-panel .kgp-option[hidden] {
	display: none;
}

.kilagbe-khatian-search .kgp-panel .kgp-option:hover {
	background: #F5FAF7;
}

.kilagbe-khatian-search .kgp-panel .kgp-option:focus {
	outline: none;
}

.kilagbe-khatian-search .kgp-panel .kgp-option:focus-visible {
	box-shadow: inset 0 0 0 2px rgba(14, 107, 79, 0.45);
}

.kilagbe-khatian-search .kgp-panel .kgp-option[aria-selected="true"] {
	background: #E7F2ED;
	border-left-color: #0E6B4F;
	color: #0A4E3A;
	font-weight: 600;
}

.kilagbe-khatian-search .kgp-option-label {
	min-width: 0;
	overflow-wrap: anywhere;
}

.kilagbe-khatian-search .kgp-check {
	flex: 0 0 16px;
	width: 16px;
	height: 16px;
	color: #0E6B4F;
	visibility: hidden;
}

.kilagbe-khatian-search .kgp-option[aria-selected="true"] .kgp-check {
	visibility: visible;
}

.kilagbe-khatian-search .kgp-empty {
	grid-row: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px 12px;
	font-size: 13px;
	color: #5C6B64;
	text-align: center;
	box-sizing: border-box;
}

.kilagbe-khatian-search .kgp-empty[hidden] {
	display: none;
}

/* Locked state (required parent not chosen yet) -- District/Upazila/Mouza only;
 * Division and Khatian Type never get this class. Same muted tokens as
 * kilagbe-khatian-search.css's .kg-panel.is-disabled, for cross-system
 * consistency. */
.kilagbe-khatian-search .kgp-panel.is-disabled {
	cursor: not-allowed;
}

.kilagbe-khatian-search .kgp-panel.is-disabled .kgp-head {
	background: #F3F4F2;
	cursor: not-allowed;
}

.kilagbe-khatian-search .kgp-panel.is-disabled .kgp-title,
.kilagbe-khatian-search .kgp-panel.is-disabled .kgp-current,
.kilagbe-khatian-search .kgp-panel.is-disabled .kgp-current-text {
	color: #8A958F;
}

.kilagbe-khatian-search .kgp-panel.is-disabled .kgp-badge {
	color: #8A958F;
	border-color: #E4E1D8;
}

.kilagbe-khatian-search .kgp-panel.is-disabled .kgp-empty {
	grid-row: 2 / 4;
	border-top: 1px solid #E4E1D8;
	background: #F9FAF9;
	color: #8A958F;
}

/* Tablet: grid already drops to 2 columns at 900px (existing CSS). */
@media (max-width: 900px) {
	.kilagbe-khatian-search .kgp-panel {
		grid-template-rows: 52px 36px 320px;
	}
}

/* Mobile: one column, comfortable touch targets, no iOS input zoom. */
@media (max-width: 560px) {
	.kilagbe-khatian-search .kgp-panel {
		grid-template-rows: 52px 36px 260px;
	}

	.kilagbe-khatian-search .kgp-panel .kgp-option {
		min-height: 40px;
		font-size: 15px;
	}

	.kilagbe-khatian-search .kgp-panel .kgp-search-input {
		font-size: 16px;
	}
}

/* Khatian Type: compact chip grid instead of a tall single column -- only 5
 * short items (BS/RS/CS/PS/Namjari), which looked like a lot of empty space
 * under the fixed-height list row. Hover/selected colors are unchanged
 * (inherited from the base .kgp-option rules below); only shape/size/layout
 * are overridden here, scoped to this one facet. */
.kilagbe-khatian-search .kgp-panel[data-facet="khatian_type"] .kgp-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
	align-content: start;
	gap: 8px;
	padding: 10px;
	box-sizing: border-box;
}

.kilagbe-khatian-search .kgp-panel[data-facet="khatian_type"] .kgp-option {
	min-height: 0;
	height: 36px;
	margin: 0;
	padding: 0 10px;
	justify-content: center;
	gap: 4px;
	font-size: 13px;
	border: 1px solid #E4E1D8;
	border-radius: 999px;
}

.kilagbe-khatian-search .kgp-panel[data-facet="khatian_type"] .kgp-option:hover {
	border-color: #0E6B4F;
}

.kilagbe-khatian-search .kgp-panel[data-facet="khatian_type"] .kgp-option[aria-selected="true"] {
	border-color: #0E6B4F;
}

.kilagbe-khatian-search .kgp-panel[data-facet="khatian_type"] .kgp-check {
	flex: 0 0 14px;
	width: 14px;
	height: 14px;
}
