/**
 * Manta Genetic Panels - frontend styles.
 * RTL-first. Card layout echoing the site /tests/ archive cards.
 * Brand palette (AMG Elementor kit): #283891 blue, #3C3C3C text, #F8991C orange.
 */

.mgp-wrap {
	--mgp-brand: #283891;
	--mgp-brand-dark: #1d2a6e;
	--mgp-accent: #f8991c;
	--mgp-ink: #3c3c3c;
	--mgp-muted: #7a7f8c;
	--mgp-line: #e4e7ef;
	--mgp-card-bg: #ffffff;
	--mgp-chip-bg: #eef1fb;
	--mgp-chip-border: #d3daf3;

	max-width: 1040px;
	margin: 0 auto;
	font-family: "Heebo", "Assistant", -apple-system, "Segoe UI", Arial, sans-serif;
	color: var(--mgp-ink);
	font-size: 16px;
	line-height: 1.55;
	box-sizing: border-box;
}

.mgp-wrap *,
.mgp-wrap *::before,
.mgp-wrap *::after {
	box-sizing: inherit;
}

/* ---------- Toolbar (search + count) ---------- */

.mgp-toolbar {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
	margin-bottom: 20px;
}

/* Flex row (icon + input + clear). No absolute positioning, so nothing can
   overlap the placeholder in RTL. */
.mgp-wrap .mgp-search {
	flex: 1 1 320px;
	display: flex;
	align-items: center;
	gap: 10px;
	background: #fff;
	border: 1px solid var(--mgp-line);
	border-radius: 10px;
	padding: 0 14px;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.mgp-wrap .mgp-search:focus-within {
	border-color: var(--mgp-brand);
	box-shadow: 0 0 0 3px rgba(40, 56, 145, .12);
}

.mgp-wrap .mgp-search__icon {
	flex: 0 0 auto;
	color: var(--mgp-muted);
}

.mgp-wrap .mgp-search__input {
	flex: 1 1 auto;
	min-width: 0;
	width: 100%;
	border: 0;
	outline: 0;
	background: transparent;
	padding: 13px 0;
	margin: 0;
	font: inherit;
	color: inherit;
	box-shadow: none;
}

.mgp-wrap .mgp-search__clear {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 5px;
	border: 0;
	border-radius: 6px;
	background: none;
	color: var(--mgp-muted);
	cursor: pointer;
	transition: color .12s ease, background-color .12s ease;
}

.mgp-wrap .mgp-search__clear:hover {
	color: var(--mgp-brand);
	background: #f1f3fb;
}

/* Respect the hidden attribute (class display would otherwise override it). */
.mgp-wrap .mgp-search__clear[hidden] {
	display: none;
}

/* Exact-match toggle. */
.mgp-wrap .mgp-exact {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin: 0;
	cursor: pointer;
	color: var(--mgp-ink);
	font-size: 14.5px;
	font-weight: 500;
	white-space: nowrap;
	user-select: none;
}

.mgp-wrap .mgp-exact input {
	width: 17px;
	height: 17px;
	margin: 0;
	cursor: pointer;
	accent-color: var(--mgp-brand);
	flex: 0 0 auto;
}

.mgp-count {
	margin: 0;
	color: var(--mgp-muted);
	font-size: 15px;
	white-space: nowrap;
	font-weight: 500;
}

/* ---------- Cards ---------- */

.mgp-cards {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.mgp-card {
	background: var(--mgp-card-bg);
	border: 1px solid var(--mgp-line);
	border-inline-start: 5px solid var(--mgp-brand);
	border-radius: 10px;
	padding: 18px 24px;
	box-shadow: 0 1px 4px rgba(20, 30, 70, .06);
	transition: box-shadow .15s ease;

	/* Skip layout and paint for cards that are off-screen. A gene search can
	   open many panels at once (thousands of gene chips); without this the
	   browser lays out all of them and the page stalls for seconds. Measured
	   on this dataset: 51ms -> 6.4ms per full layout pass. */
	content-visibility: auto;
	contain-intrinsic-size: auto 92px;
}

.mgp-card.is-open {
	box-shadow: 0 3px 14px rgba(20, 30, 70, .12);
}

/* Single line when collapsed: name (start) + fields + toggle (end). */
.mgp-card__row {
	display: flex;
	align-items: center;
	gap: 14px 30px;
	flex-wrap: wrap;
}

/* Title block: label ("test name / description") above the name, matching the
   other fields which each have a label above their value. */
.mgp-card__title {
	flex: 1 1 240px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	min-width: 0;
}

/* Name as a div (not a heading) so the Elementor theme Kit typography can't
   override / hide it. Styled explicitly with high specificity. */
.mgp-wrap .mgp-card__name {
	margin: 0;
	padding: 0;
	color: var(--mgp-brand);
	font-family: inherit;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.3;
	text-align: start;
	letter-spacing: 0;
}

.mgp-card__fields {
	display: flex;
	gap: 30px;
	flex-wrap: wrap;
	flex: 0 1 auto;
}

.mgp-field {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.mgp-field__label {
	font-size: 13px;
	font-weight: 600;
	color: var(--mgp-muted);
	white-space: nowrap;
}

.mgp-field__value {
	font-size: 16px;
	color: var(--mgp-ink);
	font-weight: 500;
	unicode-bidi: plaintext;
}

.mgp-wrap[dir="rtl"] .mgp-field__value {
	text-align: right;
}

.mgp-wrap[dir="ltr"] .mgp-field__value {
	text-align: left;
}

.mgp-field__value--count {
	color: var(--mgp-brand);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* Show all / close toggle. */
.mgp-more {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 4px;
	background: none;
	border: 0;
	cursor: pointer;
	color: var(--mgp-brand);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
}

.mgp-more:hover .mgp-more__text {
	text-decoration: underline;
}

.mgp-more__caret {
	flex: 0 0 auto;
	transition: transform .18s ease;
}

.mgp-card.is-open .mgp-more__caret {
	transform: rotate(180deg);
}

/* Genes area: hidden until the card is open. */
.mgp-card__genes {
	display: none;
	margin-top: 16px;
	padding-top: 14px;
	border-top: 1px solid var(--mgp-line);
}

.mgp-card.is-open .mgp-card__genes {
	display: block;
}

.mgp-genes__label {
	font-size: 13px;
	font-weight: 600;
	color: var(--mgp-muted);
}

.mgp-genes-full {
	direction: ltr;
	text-align: left;
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	margin-top: 8px;
}

.mgp-gene {
	background: var(--mgp-chip-bg);
	border: 1px solid var(--mgp-chip-border);
	border-radius: 6px;
	padding: 3px 9px;
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 13px;
	color: var(--mgp-brand-dark);
	white-space: nowrap;
}

.mgp-gene.is-match {
	border-color: var(--mgp-brand);
	background: #e3e8fb;
}

/* Exact mode: the whole chip is the match, so highlight the chip itself. */
.mgp-gene.is-exact {
	background: var(--mgp-accent);
	border-color: var(--mgp-accent);
	color: #fff;
	font-weight: 700;
}

.mgp-hl {
	background: var(--mgp-accent);
	color: #fff;
	border-radius: 3px;
	padding: 0 2px;
}

/* ---------- States ---------- */

.mgp-card.is-hidden {
	display: none;
}

.mgp-empty {
	text-align: center;
	color: var(--mgp-muted);
	padding: 32px 16px;
	margin: 0;
	font-size: 16px;
}

/* ---------- Mobile ---------- */

@media (max-width: 600px) {
	.mgp-wrap {
		font-size: 15px;
	}

	.mgp-card {
		padding: 16px 18px;
	}

	.mgp-card__row {
		gap: 12px 22px;
	}

	.mgp-card__fields {
		gap: 20px;
	}

	.mgp-card__title {
		flex-basis: 100%;
	}

	.mgp-card__name {
		font-size: 18px;
	}

	.mgp-more {
		margin-inline-start: auto;
	}
}
