/*
 * UPMED search boxes (website and the UPMED apps).
 */

.upmed-sb { position: relative; font-family: inherit; }
.upmed-sb-field {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0 0.35rem 0 0.9rem;
	background: #fff;
	border: 1px solid #c9d3da;
	border-radius: 999px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, width 0.2s ease;
}
.upmed-sb-field:focus-within { border-color: var(--wp--preset--color--brand, #00aeef); box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.2); }
.upmed-sb-icon { display: flex; color: var(--wp--preset--color--muted, #726868); flex: none; }
.upmed-sb.is-loading .upmed-sb-icon { animation: upmed-sb-pulse 0.9s ease-in-out infinite; color: var(--wp--preset--color--brand, #00aeef); }
@keyframes upmed-sb-pulse { 50% { opacity: 0.35; } }
.upmed-sb input[type="search"] {
	flex: 1;
	min-width: 0;
	width: 100%;
	border: 0 !important;
	box-shadow: none !important;
	outline: 0;
	background: transparent;
	padding: 0.55rem 0 !important;
	font: inherit;
	font-size: 0.95rem;
	color: var(--wp--preset--color--ink, #2b2727);
	-webkit-appearance: none;
	appearance: none;
}
.upmed-sb input[type="search"]::placeholder { color: #8a8282; }
.upmed-sb-go {
	flex: none;
	margin: 0.3rem 0;
	padding: 0.5rem 1.15rem;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--brand-dark, #0077a8);
	color: #fff;
	font: inherit;
	font-weight: 600;
	font-size: 0.95rem;
	cursor: pointer;
}
.upmed-sb-go:hover { background: var(--wp--preset--color--brand-deep, #005f87); }
.upmed-sb-kbd {
	flex: none;
	margin-right: 0.35rem;
	padding: 0 0.4rem;
	border: 1px solid var(--wp--preset--color--line, #e4eaee);
	border-radius: 5px;
	font: 600 0.75rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
	color: var(--wp--preset--color--muted, #726868);
}
.upmed-sb-field:focus-within .upmed-sb-kbd { display: none; }
.upmed-sb-close, .upmed-sb-toggle { display: none; }

/* Suggestions */
.upmed-sb-panel {
	position: absolute;
	top: calc(100% + 0.4rem);
	left: 0;
	z-index: 80;
	width: 100%;
	min-width: min(26rem, calc(100vw - 2rem));
	max-height: min(70vh, 34rem);
	overflow-y: auto;
	padding: 0.35rem;
	background: #fff;
	border: 1px solid var(--wp--preset--color--line, #e4eaee);
	border-radius: 14px;
	box-shadow: 0 12px 36px rgba(20, 40, 60, 0.16);
	text-align: left;
}
.upmed-sb-panel[hidden] { display: none; }
.upmed-sb-group + .upmed-sb-group { border-top: 1px solid var(--wp--preset--color--line, #e4eaee); margin-top: 0.25rem; padding-top: 0.25rem; }
.upmed-sb-label { padding: 0.45rem 0.7rem 0.2rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--wp--preset--color--muted, #726868); }
.upmed-sb-opt {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.45rem 0.7rem;
	border-radius: 10px;
	color: var(--wp--preset--color--ink, #2b2727) !important;
	text-decoration: none !important;
}
.upmed-sb-opt:hover, .upmed-sb-opt.is-active { background: var(--wp--preset--color--brand-soft, #e8f7fd); }
.upmed-sb-img--none { display: block; background: var(--wp--preset--color--brand-soft, #e8f7fd); }
.upmed-sb-img { flex: none; width: 36px; height: 36px; object-fit: contain; border: 1px solid var(--wp--preset--color--line, #e4eaee); border-radius: 6px; background: #fff; }
.upmed-sb-txt { min-width: 0; display: flex; flex-direction: column; }
.upmed-sb-t { font-size: 0.93rem; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.upmed-sb-t mark { background: transparent; color: var(--wp--preset--color--brand-dark, #0077a8); font-weight: 700; }
.upmed-sb-m { font-size: 0.78rem; color: var(--wp--preset--color--muted, #726868); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upmed-sb-more { display: block; padding: 0.3rem 0.7rem 0.45rem; font-size: 0.85rem; font-weight: 600; color: var(--wp--preset--color--brand-dark, #0077a8) !important; text-decoration: none !important; }
.upmed-sb-more:hover { text-decoration: underline !important; }
.upmed-sb-all {
	display: block;
	width: 100%;
	margin-top: 0.3rem;
	padding: 0.65rem 0.7rem;
	border: 0;
	border-top: 1px solid var(--wp--preset--color--line, #e4eaee);
	border-radius: 0 0 10px 10px;
	background: none;
	font: inherit;
	font-size: 0.9rem;
	text-align: left;
	color: var(--wp--preset--color--brand-dark, #0077a8);
	cursor: pointer;
}
.upmed-sb-all:hover, .upmed-sb-all.is-active { background: var(--wp--preset--color--brand-soft, #e8f7fd); }
.upmed-sb-empty { margin: 0; padding: 0.75rem 0.7rem; font-size: 0.9rem; color: var(--wp--preset--color--muted, #726868); }

/* Header box: compact, grows when used */
.upmed-sb-wrap { position: relative; flex: none; }
.upmed-sb--header .upmed-sb-field { width: 13.5rem; }
.upmed-sb--header .upmed-sb-panel { left: auto; right: 0; width: 26rem; }

/* Homepage hero box */
.upmed-sb-hero { margin-top: 1.5rem; max-width: 36rem; }
.upmed-sb--hero .upmed-sb-field { padding: 0.25rem 0.4rem 0.25rem 1.2rem; border-color: #b9d9e7; box-shadow: 0 6px 24px rgba(0, 119, 168, 0.1); }
.upmed-sb--hero input[type="search"] { font-size: 1.05rem; padding: 0.75rem 0 !important; }
.upmed-sb--hero .upmed-sb-go { padding: 0.7rem 1.4rem; font-size: 1rem; }
.upmed-sb-popular { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.8rem 0 0; font-size: 0.85rem; }
.upmed-sb-popular span { color: var(--wp--preset--color--muted, #726868); margin-right: 0.15rem; }
.upmed-sb-popular a { padding: 0.2rem 0.7rem; border-radius: 999px; background: #fff; border: 1px solid #d3eef9; color: var(--wp--preset--color--brand-dark, #0077a8); text-decoration: none; font-weight: 500; }
.upmed-sb-popular a:hover { border-color: var(--wp--preset--color--brand, #00aeef); }

/* Category page box and results page box */
.upmed-sb-archive { max-width: 34rem; margin-top: 1rem; }
.upmed-sb-page { max-width: 40rem; margin-top: 0.75rem; }
.upmed-sb-scope { margin: 0.6rem 0 0; font-size: 0.9rem; color: var(--wp--preset--color--muted, #726868); }

/* Smaller screens: the header box becomes an icon that opens full-screen search */
@media (max-width: 1280px) {
	.upmed-sb-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 2.4rem;
		height: 2.4rem;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: transparent;
		color: var(--wp--preset--color--ink, #2b2727);
		cursor: pointer;
	}
	.upmed-sb-toggle:hover { background: var(--wp--preset--color--brand-soft, #e8f7fd); }
	.upmed-sb--header { display: none; }
	html.upmed-sb-open { overflow: hidden; }
	html.upmed-sb-open .upmed-sb--header {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 100000;
		padding: 1rem;
		background: #fff;
	}
	html.upmed-sb-open .upmed-sb--header .upmed-sb-field,
	html.upmed-sb-open .upmed-sb--header .upmed-sb-field:focus-within { width: 100%; }
	html.upmed-sb-open .upmed-sb--header input[type="search"] { font-size: 1rem; padding: 0.7rem 0 !important; }
	.upmed-sb--header .upmed-sb-kbd { display: none; }
	html.upmed-sb-open .upmed-sb-close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex: none;
		width: 2.2rem;
		height: 2.2rem;
		border: 0;
		border-radius: 50%;
		background: var(--wp--preset--color--surface, #f7fafc);
		font-size: 1.5rem;
		line-height: 1;
		color: var(--wp--preset--color--muted, #726868);
		cursor: pointer;
	}
	html.upmed-sb-open .upmed-sb--header .upmed-sb-panel {
		position: static;
		width: 100%;
		min-width: 0;
		max-height: calc(100vh - 5.5rem);
		margin-top: 0.75rem;
		border: 0;
		box-shadow: none;
		padding: 0;
	}
}
@media (max-width: 599px) {
	.upmed-sb-hero { margin-top: 1.1rem; }
	.upmed-sb--hero .upmed-sb-go { padding: 0.65rem 1rem; }
	.upmed-sb-popular { font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
	.upmed-sb-field { transition: none; }
	.upmed-sb.is-loading .upmed-sb-icon { animation: none; }
}
