/* _shared/ui/model_browser/style.css */

/*
 * ==============================================================================
 * MODULE: Model Browser Window Styles
 * DESCRIPTION:
 * Dark-theme styling for the shared model selector page rendered by the macOS
 * (hs.webview), Windows (WebView2) and Linux (WebKitGTK) drivers: one table
 * grouped by backend, greyed where a backend cannot run, with a visible focus
 * ring on every row and button for keyboard use.
 * ==============================================================================
 */

:root {
	--bg: #1e1e1e;
	--bg-alt: #262629;
	--bg-head: #2d2d30;
	--row-hover: #2f3137;
	--row-sel: #094771;
	--row-sel-border: #1f6feb;
	--text: #d4d4d6;
	--text-dim: #8a8a90;
	--border: #3a3a3d;
	--accent: #4ea1ff;
	--installed: #3fb950;
	--chip-chat: #2d4a63;
	--chip-completion: #4a3a2d;
}

* {
	box-sizing: border-box;
}

html,
body {
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
	font-size: 13px;
	height: 100%;
	margin: 0;
	-webkit-font-smoothing: antialiased;
}

body {
	display: flex;
	flex-direction: column;
}

/* ===== Toolbar ===== */
#toolbar {
	align-items: center;
	background: var(--bg-alt);
	border-bottom: 1px solid var(--border);
	display: flex;
	flex: 0 0 auto;
	gap: 12px;
	padding: 10px 14px;
}

#search {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	flex: 1 1 auto;
	font-size: 13px;
	outline: none;
	padding: 7px 11px;
}

#search:focus {
	border-color: var(--accent);
}

#count {
	color: var(--text-dim);
	font-size: 12px;
	white-space: nowrap;
}

/* ===== Table ===== */
#table-wrap {
	flex: 1 1 auto;
	overflow: auto;
	position: relative;
}

table {
	border-collapse: collapse;
	table-layout: fixed;
	width: 100%;
}

thead th {
	background: var(--bg-head);
	border-bottom: 1px solid var(--border);
	color: var(--text-dim);
	cursor: pointer;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.4px;
	padding: 9px 10px;
	position: sticky;
	text-align: left;
	text-transform: uppercase;
	top: 0;
	user-select: none;
	white-space: nowrap;
	z-index: 1;
}

thead th:hover {
	color: var(--text);
}

thead th.sorted-asc::after {
	color: var(--accent);
	content: ' ▲';
}

thead th.sorted-desc::after {
	color: var(--accent);
	content: ' ▼';
}

.col-current {
	text-align: center;
	width: 64px;
}
.col-status {
	text-align: center;
	width: 140px;
}
.col-actions {
	width: 230px;
}
.col-num {
	text-align: right;
	width: 88px;
}

tbody td {
	border-bottom: 1px solid #2a2a2d;
	overflow: hidden;
	padding: 8px 10px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

tbody td.num {
	color: var(--text-dim);
	font-variant-numeric: tabular-nums;
	text-align: right;
}

tbody td.center {
	text-align: center;
}

tbody tr {
	cursor: pointer;
}

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

tbody tr.selected {
	background: var(--row-sel);
	box-shadow: inset 2px 0 0 var(--row-sel-border);
}

tbody tr.active .name-cell::after {
	color: var(--accent);
	content: '●';
	font-size: 10px;
	margin-left: 7px;
	vertical-align: middle;
}

.name-cell {
	color: var(--text);
	font-weight: 600;
}

.dot {
	background: var(--theme-grey-555);
	border-radius: 50%;
	display: inline-block;
	height: 9px;
	width: 9px;
}

.dot.on {
	background: var(--installed);
	box-shadow: 0 0 5px rgba(63, 185, 80, 0.6);
}

.chip {
	background: var(--chip-chat);
	border-radius: 10px;
	color: #cfe3f5;
	display: inline-block;
	font-size: 11px;
	padding: 2px 8px;
}

.chip.completion {
	background: var(--chip-completion);
	color: #f0dcc0;
}

.src-link {
	color: var(--text-dim);
	font-size: 14px;
	text-decoration: none;
}

.src-link:hover {
	color: var(--accent);
}

#empty {
	color: var(--text-dim);
	font-size: 13px;
	padding: 28px 14px;
	text-align: center;
}

/* ===== Footer ===== */
#footer {
	align-items: center;
	background: var(--bg-alt);
	border-top: 1px solid var(--border);
	display: flex;
	flex: 0 0 auto;
	gap: 12px;
	justify-content: space-between;
	padding: 10px 14px;
}

#hint {
	color: var(--text-dim);
	font-size: 12px;
}

#btn-use {
	background: var(--accent);
	border: none;
	border-radius: 6px;
	color: #06243f;
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	padding: 8px 18px;
}

#btn-use:disabled {
	background: #3a3a3d;
	color: var(--text-dim);
	cursor: default;
}

/* ===== Selector additions ===== */
#backend-filter {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	font-size: 13px;
	padding: 6px 8px;
}

#backend-filter-label {
	color: var(--text-dim);
	font-size: 12px;
}

#current {
	background: var(--bg-alt);
	border-bottom: 1px solid var(--border);
	color: var(--text);
	flex: 0 0 auto;
	font-weight: 600;
	padding: 8px 14px;
}

tbody tr.group th {
	background: var(--bg-head);
	color: var(--text);
	font-size: 12px;
	padding: 8px 10px;
	text-align: left;
}

/* The whole header opens and closes its group; its tools keep their own cursor. */
tbody tr.group th,
tbody tr.group .group-toggle {
	cursor: pointer;
}

tbody tr.group .group-tools {
	cursor: default;
}

tbody tr.group .group-toggle {
	border-radius: 4px;
	display: inline-block;
	font-weight: 600;
	padding: 2px 4px;
}

tbody tr.group .group-toggle:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 0;
}

tbody tr.group .chevron {
	display: inline-block;
	transition: transform 0.12s ease;
	width: 1em;
}

tbody tr.group.expanded .chevron {
	transform: rotate(90deg);
}

tbody tr.group .group-count,
tbody tr.group .group-active {
	color: var(--text-dim);
	font-weight: 400;
	margin-left: 8px;
}

tbody tr.group .group-active {
	color: var(--accent);
}

/* The thin line between the local backends and the remote API. */
tbody.group-separator td {
	border-bottom: 0;
	border-top: 1px solid var(--border);
	height: 0;
	padding: 0;
}

tbody tr.group.unavailable th,
tbody tr.unavailable {
	color: var(--text-dim);
}

tbody tr.group .reason {
	color: var(--text-dim);
	font-weight: 400;
	margin-left: 8px;
}

tbody tr.unavailable,
tbody tr.missing {
	cursor: default;
}

tbody tr.unavailable td {
	opacity: 0.55;
}

/* The way out of an unavailable row (its key, its runtime) stays legible. */
tbody tr.unavailable td.col-actions {
	opacity: 1;
}

tbody tr:focus,
button:focus-visible,
thead th:focus-visible,
#backend-filter:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.sub {
	color: var(--text-dim);
	display: block;
	font-size: 11px;
}

.mark.on {
	color: var(--accent);
	font-weight: 700;
}

.chip.default {
	background: var(--theme-green-dark);
	color: var(--text);
}

.status.remote {
	color: var(--accent);
}

.act {
	background: var(--bg-head);
	border: 1px solid var(--border);
	border-radius: 5px;
	color: var(--text);
	cursor: pointer;
	font-size: 12px;
	margin-right: 4px;
	padding: 3px 9px;
}

.act:hover {
	border-color: var(--accent);
}

.act.danger:hover {
	border-color: var(--theme-danger);
	color: var(--theme-hue-f87171);
}

.act.link {
	padding: 3px 7px;
}

#footer-actions {
	display: flex;
	gap: 8px;
}

#btn-disable,
#btn-add-custom {
	background: var(--bg-head);
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	cursor: pointer;
	font-size: 13px;
	padding: 8px 14px;
}

[hidden] {
	display: none !important;
}
