/**
 * Course archive controls (/kurse/ and category archives): search, sorting, grid/list switch.
 * LearnPress' markup, names and scripts are unchanged (Course_Cards::archive_controls(),
 * ::order_by_labels(), ::switch_layout()); this file only gives them the ABZiel form style.
 *
 * One control height (48 px), field borders --abz-line-input (3:1), radius --abz-radius-md,
 * navy for the active/pressed state, focus ring --abz-blue-600. Red stays reserved for the
 * primary action of the page.
 */

.lp-courses-bar.abz-course-controls {
	--abz-control-h: 48px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--abz-space-3);
	margin-bottom: var(--abz-space-8);
	font-family: var(--abz-font-text);
}

/* ---------- Search: field and button as one control ---------- */
.lp-courses-bar.abz-course-controls .search-courses {
	display: flex;
	flex: 0 1 400px;
	min-width: 0;
	margin: 0;
}

.lp-courses-bar.abz-course-controls .search-courses input[type="search"] {
	flex: 1 1 auto;
	width: auto;
	min-width: 0;
	max-width: none;
	height: var(--abz-control-h);
	margin: 0;
	padding: 0 var(--abz-space-4);
	background: var(--abz-white);
	border: 1px solid var(--abz-line-input);
	border-right: 0;
	border-radius: var(--abz-radius-md) 0 0 var(--abz-radius-md);
	box-shadow: none;
	color: var(--abz-navy-800);
	font-family: inherit;
	font-size: var(--abz-fs-16);
	line-height: 1.4;
	transition: border-color var(--abz-duration-fast) var(--abz-ease);
}

.lp-courses-bar.abz-course-controls .search-courses input[type="search"]::placeholder {
	color: var(--abz-text-muted);
	opacity: 1;
}

.lp-courses-bar.abz-course-controls .search-courses input[type="search"]:hover {
	border-color: var(--abz-navy-800);
}

.lp-courses-bar.abz-course-controls .search-courses button {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: var(--abz-control-h);
	height: var(--abz-control-h);
	margin: 0;
	padding: 0;
	background: var(--abz-navy-800);
	border: 1px solid var(--abz-navy-800);
	border-radius: 0 var(--abz-radius-md) var(--abz-radius-md) 0;
	box-shadow: none;
	color: var(--abz-white);
	cursor: pointer;
	transition: background-color var(--abz-duration-fast) var(--abz-ease), border-color var(--abz-duration-fast) var(--abz-ease);
}

.lp-courses-bar.abz-course-controls .search-courses button:hover {
	background: var(--abz-navy-900);
	border-color: var(--abz-navy-900);
}

.lp-courses-bar.abz-course-controls .search-courses button i {
	font-size: 18px;
	line-height: 1;
}

/* ---------- Right group: sort + view switch ---------- */
.lp-courses-bar.abz-course-controls .courses-order-by-wrapper {
	margin-left: auto;
}

.lp-courses-bar.abz-course-controls .courses-order-by {
	height: var(--abz-control-h);
	min-width: 200px;
	margin: 0;
	padding: 0 44px 0 var(--abz-space-4);
	background-color: var(--abz-white);
	/* Chevron (Lucide "chevron-down"), navy 800 */
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%230B2D6B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--abz-space-4) center;
	background-size: 18px 18px;
	border: 1px solid var(--abz-line-input);
	border-radius: var(--abz-radius-md);
	box-shadow: none;
	color: var(--abz-navy-800);
	font-family: inherit;
	font-size: var(--abz-fs-16);
	font-weight: var(--abz-weight-text);
	line-height: 1.4;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: border-color var(--abz-duration-fast) var(--abz-ease);
}

.lp-courses-bar.abz-course-controls .courses-order-by:hover {
	border-color: var(--abz-navy-800);
}

/* View switch: segmented control; the radios stay keyboard-operable (LearnPress hides them). */
.lp-courses-bar.abz-course-controls .abz-view-switch {
	display: flex;
	align-items: stretch;
}

.lp-courses-bar.abz-course-controls .abz-view-switch input[type="radio"] {
	display: block;
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
	opacity: 0;
}

.lp-courses-bar.abz-course-controls .abz-view-switch .switch-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--abz-control-h);
	height: var(--abz-control-h);
	margin: 0;
	padding: 0;
	background: var(--abz-white);
	border: 1px solid var(--abz-line-input);
	color: var(--abz-navy-800);
	cursor: pointer;
	transition: background-color var(--abz-duration-fast) var(--abz-ease), color var(--abz-duration-fast) var(--abz-ease);
}

.lp-courses-bar.abz-course-controls .abz-view-switch .switch-btn.grid {
	border-right: 0;
	border-radius: var(--abz-radius-md) 0 0 var(--abz-radius-md);
}

.lp-courses-bar.abz-course-controls .abz-view-switch .switch-btn.list {
	border-left: 1px solid var(--abz-line-input);
	border-radius: 0 var(--abz-radius-md) var(--abz-radius-md) 0;
}

.lp-courses-bar.abz-course-controls .abz-view-switch .switch-btn::before {
	margin: 0;
	color: inherit;
	font-size: 16px;
	line-height: 1;
}

.lp-courses-bar.abz-course-controls .abz-view-switch .switch-btn:hover {
	background: var(--abz-surface-subtle);
}

/* Active view: navy, as the current page in the pagination. (Both bar and switch classes:
   LearnPress' own active rule uses :nth-child selectors.) */
.lp-courses-bar.abz-course-controls .switch-layout.abz-view-switch input[type="radio"]:checked + .switch-btn {
	background: var(--abz-navy-800);
	border-color: var(--abz-navy-800);
	color: var(--abz-white);
}

.lp-courses-bar.abz-course-controls .switch-layout.abz-view-switch input[type="radio"]:checked + .switch-btn::before {
	color: var(--abz-white);
}

/* ---------- Focus ---------- */
.lp-courses-bar.abz-course-controls .search-courses input[type="search"]:focus-visible,
.lp-courses-bar.abz-course-controls .search-courses button:focus-visible,
.lp-courses-bar.abz-course-controls .courses-order-by:focus-visible,
.lp-courses-bar.abz-course-controls .abz-view-switch input[type="radio"]:focus-visible + .switch-btn {
	position: relative;
	z-index: 1;
	outline: 2px solid var(--abz-blue-600);
	outline-offset: 2px;
}

.lp-courses-bar.abz-course-controls .search-courses input[type="search"]:focus,
.lp-courses-bar.abz-course-controls .courses-order-by:focus {
	border-color: var(--abz-navy-800);
}

/* ---------- Small screens: search on its own row, sorting full width ---------- */
@media (max-width: 767px) {
	.abz-course-controls {
		margin-bottom: var(--abz-space-6);
	}

	.abz-course-controls .search-courses {
		flex: 1 1 100%;
	}

	.abz-course-controls .search-courses input[type="search"] {
		min-width: 0;
	}

	.abz-course-controls .courses-order-by-wrapper {
		flex: 1 1 100%;
		margin-left: 0;
	}

	.abz-course-controls .courses-order-by {
		width: 100%;
	}
}

/* As LearnPress: no view switch on small screens (both views show the same one-column list). */
@media (max-width: 768px) {
	.lp-courses-bar.abz-course-controls .abz-view-switch {
		display: none;
	}
}

/* While LearnPress loads the course list (AJAX), its placeholder keeps one screen of room so the
   footer does not jump up into view and back down again (layout shift). LearnPress removes the
   placeholder when the courses arrive. */
.abz-lp-main .lp-list-courses-default .loading-first {
	min-height: 100vh;
	min-height: 100svh;
}
