/**
 * Unison Table — shared styles (front end + editor).
 *
 * Minimal, stylish, neutral. Inherits the theme's typography while keeping a
 * clean, lightweight table aesthetic.
 */

.ut-block {
	--ut-border: rgba( 0, 0, 0, 0.16 );
	--ut-border-strong: rgba( 0, 0, 0, 0.28 );
	--ut-text: #1a1a1a;
	--ut-muted: #6b6b6b;
	--ut-accent: #2563eb;
	--ut-row-hover: rgba( 0, 0, 0, 0.025 );
	--ut-radius: 0;

	margin-top: 1.5em;
	margin-bottom: 1.5em;
	color: var( --ut-text );
	font-size: 0.95rem;
}

/* ---------- Toolbar / search ---------- */

.ut-toolbar {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 0.6em;
}

.ut-search {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.ut-search::before {
	content: "";
	position: absolute;
	left: 0.7em;
	width: 14px;
	height: 14px;
	pointer-events: none;
	opacity: 0.45;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	/* Inline magnifier icon. */
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E" );
}

.ut-search__input {
	width: 11rem;
	max-width: 100%;
	padding: 0.42em 0.7em 0.42em 2.1em;
	font-size: 0.85rem;
	line-height: 1.2;
	color: var( --ut-text );
	background: transparent;
	border: 1px solid var( --ut-border );
	border-radius: 0;
	outline: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, width 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ut-search__input::placeholder {
	color: var( --ut-muted );
	opacity: 0.8;
}

.ut-search__input:focus {
	border-color: var( --ut-accent );
	box-shadow: 0 0 0 3px rgba( 37, 99, 235, 0.12 );
	width: 13rem;
}

/* ---------- Table ---------- */

.ut-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.ut-table {
	width: 100%;
	border-collapse: collapse;
	margin: 0;
	background: transparent;
	font-variant-numeric: tabular-nums;
}

.ut-table th,
.ut-table td {
	padding: 0.7em 1em;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var( --ut-border );
}

.ut-table thead th {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #fafafa;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var( --ut-muted );
	border-bottom: 1px solid var( --ut-border );
	white-space: nowrap;
}

.ut-table tbody tr:last-child td {
	border-bottom: none;
}

.ut-table tbody tr {
	transition: background-color 0.12s ease;
}

.ut-table tbody tr:hover {
	background: var( --ut-row-hover );
}

/* ---------- Sortable headers ---------- */

.ut-sort {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	width: 100%;
	margin: 0;
	padding: 0;
	font: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	color: inherit;
	background: none;
	border: 0;
	cursor: pointer;
	user-select: none;
}

.ut-sort:hover {
	color: var( --ut-text );
}

.ut-sort:focus-visible {
	outline: 2px solid var( --ut-accent );
	outline-offset: 2px;
}

.ut-arrow {
	width: 0.8em;
	height: 0.8em;
	flex: 0 0 auto;
	opacity: 0;
	transition: opacity 0.15s ease, transform 0.15s ease;
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6 -6l6 6'/%3E%3C/svg%3E" );
}

.ut-sort:hover .ut-arrow {
	opacity: 0.35;
}

.ut-th.is-sorted .ut-sort {
	color: var( --ut-text );
}

.ut-th.is-sorted .ut-arrow {
	opacity: 0.9;
}

.ut-th.is-desc .ut-arrow {
	transform: rotate( 180deg );
}

/* ---------- Caption ---------- */

.ut-caption {
	margin-top: 0.7em;
	font-size: 0.82rem;
	color: var( --ut-muted );
	text-align: center;
}

/* ---------- Dark-ish theme awareness ---------- */

@media ( prefers-color-scheme: dark ) {
	.ut-block {
		--ut-border: rgba( 255, 255, 255, 0.12 );
		--ut-border-strong: rgba( 255, 255, 255, 0.24 );
		--ut-text: #f2f2f2;
		--ut-muted: #a3a3a3;
		--ut-row-hover: rgba( 255, 255, 255, 0.04 );
	}

	.ut-table thead th {
		background: rgba( 255, 255, 255, 0.04 );
	}

	.ut-search::before,
	.ut-arrow {
		filter: invert( 1 );
	}
}
