/* Buttons, badges, inputs, skeletons, empty and error states, tooltips. */

/* --- buttons --------------------------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s2);
	height: 32px;
	padding: 0 var(--s3);
	border: 1px solid var(--line);
	border-radius: var(--r2);
	background: var(--surface-2);
	color: var(--text);
	cursor: pointer;
	white-space: nowrap;
	transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { border-color: var(--line); background: var(--surface-2); }

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--on-accent);
	font-weight: 580;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }

.btn-danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn-danger:hover { background: var(--bad-weak); border-color: var(--bad); }

.btn-sm { height: 26px; padding: 0 var(--s2); font-size: var(--t-caption); }
.btn-icon { width: 32px; padding: 0; }

.btn.is-on { border-color: var(--accent); background: var(--accent-weak); color: var(--text); }

.btn-link {
	background: none;
	border: 0;
	padding: 0;
	height: auto;
	color: var(--accent);
	cursor: pointer;
	text-align: left;
}
.btn-link:hover { text-decoration: underline; background: none; }

/* --- switch ---------------------------------------------------------------------------- */

.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
	width: 36px; height: 20px;
	border-radius: var(--r-pill);
	background: var(--surface-3);
	border: 1px solid var(--line-strong);
	position: relative;
	transition: background .14s ease, border-color .14s ease;
	flex-shrink: 0;
}
.switch-track::after {
	content: "";
	position: absolute;
	top: 2px; left: 2px;
	width: 14px; height: 14px;
	border-radius: var(--r-pill);
	background: var(--muted);
	transition: transform .14s ease, background .14s ease;
}
.switch input:checked + .switch-track { background: var(--accent-weak); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* --- badges ---------------------------------------------------------------------------- */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px var(--s2);
	border-radius: var(--r-pill);
	border: 1px solid var(--line);
	background: var(--surface-2);
	color: var(--text-2);
	font-size: var(--t-caption);
	font-weight: 560;
	letter-spacing: .02em;
	white-space: nowrap;
	line-height: 1.5;
}

.badge::before {
	content: "";
	width: 6px; height: 6px;
	border-radius: var(--r-pill);
	background: currentColor;
	flex-shrink: 0;
}
.badge.is-plain::before { display: none; }

.badge-neutral, .badge-draft { color: var(--draft); }
.badge-info, .badge-training, .badge-frozen { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-weak); }
.badge-ready, .badge-good, .badge-done { color: var(--good); border-color: rgba(74, 210, 149, .35); background: var(--good-weak); }
.badge-attention, .badge-warning { color: var(--warn); border-color: rgba(232, 180, 87, .35); background: var(--warn-weak); }
.badge-failed, .badge-bad { color: var(--bad); border-color: rgba(242, 119, 127, .35); background: var(--bad-weak); }

.badge-sm { font-size: 10px; padding: 1px 6px; }

/* --- inputs ---------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field > label, .field-label {
	font-size: var(--t-label);
	font-weight: 560;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--muted);
}

input[type="text"], input[type="search"], input[type="number"], select, textarea {
	height: 32px;
	padding: 0 var(--s3);
	border: 1px solid var(--line);
	border-radius: var(--r2);
	background: var(--surface-2);
	color: var(--text);
	min-width: 0;
}
textarea { height: auto; padding: var(--s2) var(--s3); line-height: var(--lh-body); }
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: var(--line-strong); }
select { cursor: pointer; }
input:disabled, select:disabled { opacity: .5; cursor: default; }

.input-search { min-width: 240px; }

/* --- skeletons ------------------------------------------------------------------------- */

@keyframes sk-pulse { 0%, 100% { opacity: .55; } 50% { opacity: .9; } }

.sk {
	background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
	border-radius: var(--r1);
	animation: sk-pulse 1.4s ease-in-out infinite;
}
.sk-line { height: 11px; }
.sk-line.is-lg { height: 18px; }
.sk-line.is-sm { height: 9px; }
.sk-block { height: 180px; border-radius: var(--r2); }
.sk-stack { display: flex; flex-direction: column; gap: var(--s2); }
.sk-row { display: flex; align-items: center; gap: var(--s4); padding: var(--s3) 0; }

@media (prefers-reduced-motion: reduce) {
	.sk { animation: none; }
}

/* --- empty / error --------------------------------------------------------------------- */

.state {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--s3);
	padding: var(--s8) var(--s5);
	text-align: center;
	color: var(--muted);
}
.state-title { font-size: var(--t-title); font-weight: 600; color: var(--text); }
.state p { max-width: 46ch; line-height: var(--lh-body); }
.state-actions { display: flex; gap: var(--s2); margin-top: var(--s1); }

.state.is-error .state-title { color: var(--bad); }
.state-code {
	font-family: var(--mono);
	font-size: var(--t-caption);
	color: var(--muted);
	background: var(--surface-2);
	border: 1px solid var(--line);
	border-radius: var(--r1);
	padding: 2px var(--s2);
}

.state-details { width: 100%; max-width: 70ch; text-align: left; }
.state-details summary { cursor: pointer; color: var(--muted); font-size: var(--t-caption); }
.state-details pre {
	margin: var(--s2) 0 0;
	padding: var(--s3);
	background: var(--surface-2);
	border: 1px solid var(--line);
	border-radius: var(--r2);
	overflow: auto;
	max-height: 240px;
	font-family: var(--mono);
	font-size: 11px;
	line-height: 1.5;
	color: var(--text-2);
}

/* --- notes ----------------------------------------------------------------------------- */

.note {
	display: flex;
	gap: var(--s3);
	padding: var(--s3) var(--s4);
	border: 1px solid var(--line);
	border-left: 3px solid var(--muted);
	border-radius: var(--r2);
	background: var(--surface-2);
	color: var(--text-2);
	line-height: var(--lh-body);
}
.note.is-warn { border-left-color: var(--warn); }
.note.is-bad { border-left-color: var(--bad); }
.note.is-info { border-left-color: var(--accent); }

.panel-note { color: var(--muted); line-height: var(--lh-body); }

/* --- live freshness -------------------------------------------------------------------- */

.freshness {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	font-size: var(--t-caption);
	color: var(--faint);
	white-space: nowrap;
}
.freshness::before {
	content: "";
	width: 5px; height: 5px;
	border-radius: var(--r-pill);
	background: var(--good);
}
.freshness.is-stale::before { background: var(--warn); }
.freshness.is-off::before { background: var(--faint); }

/* --- tooltip --------------------------------------------------------------------------- */

.tip {
	position: fixed;
	z-index: var(--z-tooltip);
	pointer-events: none;
	background: var(--surface-3);
	border: 1px solid var(--line-strong);
	border-radius: var(--r2);
	box-shadow: var(--shadow-2);
	padding: var(--s2) var(--s3);
	font-size: var(--t-caption);
	line-height: 1.5;
	color: var(--text);
	max-width: 280px;
	white-space: pre-line;
}
.tip[hidden] { display: none; }
.tip-title { font-weight: 600; margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; }
.tip-key { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.tip-swatch { width: 8px; height: 2px; border-radius: 1px; display: inline-block; }
.tip-val { font-variant-numeric: tabular-nums; }

/* --- chips ----------------------------------------------------------------------------- */

.chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px var(--s2);
	border: 1px solid var(--line);
	border-radius: var(--r-pill);
	background: var(--surface-2);
	color: var(--text-2);
	font-size: var(--t-caption);
}

/* --- mini bar -------------------------------------------------------------------------- */

.bar {
	height: 5px;
	border-radius: var(--r-pill);
	background: var(--surface-3);
	overflow: hidden;
}
.bar > span {
	display: block;
	height: 100%;
	border-radius: var(--r-pill);
	background: var(--accent);
	transition: width .35s ease;
}
.bar.is-empty > span { background: transparent; }
.bar.is-good > span { background: var(--good); }
