/* LHE Medication List – enhanced view (DataTables).
   Inherits the site's font (Poppins on legacyhealthendowment.org); the teal
   accent matches the site's primary brand colour. Override any token on
   .lhe-medlist--enhanced from the theme's custom CSS. */

.lhe-medlist--enhanced {
	--lhe-accent: #0080a3;
	--lhe-accent-ink: #ffffff;
	--lhe-ink: #121212;
	--lhe-muted: #54595f;
	--lhe-line: #e3e6e8;
	--lhe-zebra: #f7f9fa;
	--lhe-hover: #eef7f9;
	--lhe-new-bg: #e2efda;
	--lhe-new-ink: #2f6b38;
	--lhe-radius: 10px;
	--lhe-control-h: 2.75rem;
	color: var(--lhe-ink);
	font-size: 1rem;
	line-height: 1.45;
	min-width: 0;
	max-width: 100%;
}
.lhe-medlist--enhanced *,
.lhe-medlist--enhanced *::before,
.lhe-medlist--enhanced *::after { box-sizing: border-box; }

/* Header */
.lhe-medlist__header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 0.5rem 1.5rem;
	margin-bottom: 1.25rem;
}
.lhe-medlist--enhanced h2.lhe-medlist__title { margin: 0 0 0.15em; padding: 0; font-size: 1.6rem; font-weight: 600; letter-spacing: 0; line-height: 1.15; color: var(--lhe-ink); }
.lhe-medlist--enhanced p.lhe-medlist__dek { margin: 0; color: var(--lhe-muted); font-size: 1rem; line-height: 1.45; }
.lhe-medlist--enhanced p.lhe-medlist__updated {
	margin: 0;
	line-height: 1.4;
	padding: 0.3em 0.8em;
	border-radius: 999px;
	background: var(--lhe-zebra);
	border: 1px solid var(--lhe-line);
	color: var(--lhe-muted);
	font-size: 0.85rem;
	white-space: nowrap;
}

/* Toolbar */
.lhe-medlist__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.75rem;
}
.lhe-medlist__search {
	position: relative;
	flex: 1 1 260px;
	display: flex;
	align-items: center;
}
.lhe-medlist__search svg {
	position: absolute;
	left: 0.85rem;
	color: var(--lhe-muted);
	pointer-events: none;
}
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__search input.lhe-medlist__input[type="search"],
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__select select[data-lhe-form] {
	width: 100%;
	height: var(--lhe-control-h);
	min-height: var(--lhe-control-h);
	margin: 0;
	padding: 0 0.9rem;
	box-shadow: none;
	outline: none;
	border: 1px solid var(--lhe-line);
	border-radius: var(--lhe-radius);
	background: #fff;
	color: var(--lhe-ink);
	font: inherit;
	font-size: 0.95rem;
	line-height: 1.3;
	transition: border-color 0.15s, box-shadow 0.15s;
}
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__search input.lhe-medlist__input[type="search"] { padding-left: 2.6rem; -webkit-appearance: none; appearance: none; }
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__search input.lhe-medlist__input[type="search"]::-webkit-search-decoration,
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__search input.lhe-medlist__input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__search input.lhe-medlist__input[type="search"]:focus,
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__select select[data-lhe-form]:focus {
	outline: none;
	border-color: var(--lhe-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--lhe-accent) 20%, transparent);
}
.lhe-medlist__select { flex: 0 1 220px; }
.lhe-medlist--enhanced .lhe-medlist__toolbar .lhe-medlist__select select[data-lhe-form] {
	-webkit-appearance: none;
	appearance: none;
	padding-right: 2.4rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2354595f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.85rem center;
	background-size: 1rem;
}
.lhe-medlist--enhanced label.lhe-medlist__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	height: var(--lhe-control-h);
	min-height: var(--lhe-control-h);
	margin: 0;
	padding: 0 0.9rem;
	border: 1px solid var(--lhe-line);
	border-radius: var(--lhe-radius);
	background: #fff;
	font-size: 0.95rem;
	cursor: pointer;
	user-select: none;
}
.lhe-medlist--enhanced label.lhe-medlist__toggle input[type="checkbox"] { -webkit-appearance: checkbox; appearance: auto; width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--lhe-accent); cursor: pointer; }
.lhe-medlist--enhanced label.lhe-medlist__toggle:has(input:checked) { border-color: var(--lhe-new-ink); background: var(--lhe-new-bg); color: var(--lhe-new-ink); }
.lhe-medlist--enhanced p.lhe-medlist__count { margin: 0 0 0.5rem; color: var(--lhe-muted); font-size: 0.875rem; line-height: 1.4; min-height: 1.2em; }

/* Table */
.lhe-medlist__tablewrap {
	border: 1px solid var(--lhe-line);
	border-radius: var(--lhe-radius);
	overflow-x: auto;
	overflow-y: hidden;
	background: #fff;
	min-width: 0;
	max-width: 100%;
}
.lhe-medlist--enhanced table.lhe-medlist__table.dataTable {
	width: 100% !important;
	margin: 0 !important;
	border-collapse: separate;
	border-spacing: 0;
	border: 0;
	font-size: 0.95rem;
	background: transparent;
}
.lhe-medlist--enhanced table.dataTable thead > tr > th {
	position: sticky;
	top: 0;
	z-index: 1;
	padding: 0.8rem 1rem;
	border: 0;
	border-bottom: 2px solid var(--lhe-line);
	background: #fff;
	color: var(--lhe-muted);
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-align: left;
	line-height: 1.3;
}
.lhe-medlist--enhanced table.dataTable thead > tr > th.dt-orderable-asc:hover,
.lhe-medlist--enhanced table.dataTable thead > tr > th.dt-orderable-desc:hover { outline: none; background: var(--lhe-zebra); }
.lhe-medlist--enhanced table.dataTable thead > tr > th span.dt-column-order { color: var(--lhe-accent); }
.lhe-medlist--enhanced table.dataTable tbody > tr > td {
	padding: 0.7rem 1rem;
	border: 0;
	border-bottom: 1px solid var(--lhe-line);
	vertical-align: top;
	line-height: 1.4;
	background: transparent;
	box-shadow: none !important;
}
.lhe-medlist--enhanced table.dataTable tbody > tr:last-child > td { border-bottom: 0; }
.lhe-medlist--enhanced table.dataTable tbody > tr:nth-child(even) > td { background: var(--lhe-zebra); }
.lhe-medlist--enhanced table.dataTable tbody > tr:hover > td { background: var(--lhe-hover); }
.lhe-medlist--enhanced table.dataTable tbody > tr > td:first-child { font-weight: 500; }
.lhe-medlist--enhanced table.dataTable tbody > tr.lhe-new > td,
.lhe-medlist--enhanced table.dataTable tbody > tr.lhe-new:nth-child(even) > td { background: var(--lhe-new-bg); }
.lhe-medlist--enhanced table.dataTable tbody > tr.lhe-new:hover > td { background: color-mix(in srgb, var(--lhe-new-bg) 80%, #fff); }
.lhe-medlist--enhanced .lhe-col-new { display: none; }
.lhe-medlist--enhanced table.dataTable tbody tr.dt-hasChild td.dt-control::before { background-color: var(--lhe-accent); }

.lhe-medlist__table:not(.dataTable) .lhe-col-new { display: none; }

.lhe-medlist--enhanced .lhe-badge {
	display: inline-block;
	margin-left: 0.4em;
	padding: 0.1em 0.55em;
	border-radius: 999px;
	background: var(--lhe-new-ink);
	color: #fff;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	vertical-align: middle;
}

/* Empty state */
.lhe-medlist--enhanced table.dataTable td.dt-empty {
	padding: 2.5rem 1rem;
	color: var(--lhe-muted);
	text-align: center;
}

/* DataTables' own controls are switched off; this footer drives paging. */
.lhe-medlist--enhanced div.dt-container .dt-layout-row { margin: 0; }
.lhe-medlist--enhanced div.dt-container .dt-layout-cell { padding: 0; }
.lhe-medlist__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1rem;
	margin-top: 0.9rem;
	color: var(--lhe-muted);
	font-size: 0.875rem;
}
.lhe-medlist__footer[hidden] { display: none; }
.lhe-medlist__length { display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.lhe-medlist__length > span { flex: none; }
.lhe-medlist--enhanced .lhe-medlist__footer .lhe-medlist__length select[data-lhe-length] {
	height: 2.25rem;
	min-height: 2.25rem;
	width: auto;
	box-shadow: none;
	margin: 0;
	padding: 0.25rem 2rem 0.25rem 0.75rem;
	border: 1px solid var(--lhe-line);
	border-radius: 999px;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2354595f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.7rem center / 0.9rem;
	color: var(--lhe-ink);
	font: inherit;
	font-size: 0.875rem;
	line-height: 1.2;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
}
.lhe-medlist--enhanced .lhe-medlist__footer .lhe-medlist__length select[data-lhe-length]:focus { outline: none; border-color: var(--lhe-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lhe-accent) 20%, transparent); }
.lhe-medlist__pager { display: inline-flex; align-items: center; gap: 0.25rem; }
.lhe-medlist__pager[hidden] { display: none; }
.lhe-medlist--enhanced .lhe-medlist__footer .lhe-medlist__pager button {
	display: inline-flex;
	height: 2.25rem;
	box-shadow: none;
	text-transform: none;
	letter-spacing: 0;
	align-items: center;
	gap: 0.3rem;
	min-height: 2.25rem;
	margin: 0;
	padding: 0.25rem 0.9rem;
	border: 1px solid var(--lhe-line);
	border-radius: 999px;
	background: #fff;
	color: var(--lhe-ink);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.lhe-medlist--enhanced .lhe-medlist__footer .lhe-medlist__pager button:hover:not(:disabled) { border-color: var(--lhe-accent); color: var(--lhe-accent); background: var(--lhe-hover); }
.lhe-medlist--enhanced .lhe-medlist__footer .lhe-medlist__pager button:focus-visible { outline: 2px solid var(--lhe-accent); outline-offset: 2px; }
.lhe-medlist--enhanced .lhe-medlist__footer .lhe-medlist__pager button:disabled { opacity: 0.4; cursor: default; }
.lhe-medlist__pager svg { width: 1em; height: 1em; }
.lhe-medlist__range { min-width: 7.5rem; padding: 0 0.5rem; text-align: center; font-variant-numeric: tabular-nums; color: var(--lhe-ink); }

.lhe-medlist--enhanced p.lhe-medlist__source { margin: 0.75rem 0 0; color: var(--lhe-muted); font-size: 0.85rem; text-align: right; }
.lhe-medlist__source span { text-transform: uppercase; letter-spacing: 0.04em; }

/* Responsive child rows */
.lhe-medlist--enhanced table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }
.lhe-medlist--enhanced table.dataTable > tbody > tr.child ul.dtr-details > li { border-bottom-color: var(--lhe-line); padding: 0.4rem 0; }
.lhe-medlist--enhanced table.dataTable > tbody > tr.child span.dtr-title { min-width: 6rem; color: var(--lhe-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

@media (max-width: 640px) {
	.lhe-medlist__title { font-size: 1.35rem; }
	.lhe-medlist__select { flex: 1 1 100%; }
	.lhe-medlist__toggle { flex: 1 1 auto; justify-content: center; }
	.lhe-medlist--enhanced table.dataTable thead > tr > th,
	.lhe-medlist--enhanced table.dataTable tbody > tr > td { padding-left: 0.75rem; padding-right: 0.75rem; }
	.lhe-medlist__footer { justify-content: center; }
	.lhe-medlist__pager { width: 100%; justify-content: space-between; }
	.lhe-medlist__range { flex: 1; }
}

/* Print: show the whole list, hide controls */
@media print {
	.lhe-medlist__toolbar,
	.lhe-medlist__footer,
	.lhe-medlist--enhanced .dt-control::before { display: none !important; }
	.lhe-medlist__tablewrap { border: 0; }
	.lhe-medlist--enhanced table.dataTable thead > tr > th { position: static; }
	.lhe-medlist--enhanced table.dataTable tbody > tr { break-inside: avoid; }
}
