﻿/*
	EUtility design system: components.css
	---------------------------------------
	The shared parts, as .ds-* classes. They read only --ds-* tokens, so each app's theme.css changes how they look.
	A theme may also restyle them for its ornaments (House's gold double-line buttons, IOU's underline-only fields).
	Bootstrap apps keep Bootstrap's own markup for buttons, fields and tables (bootstrap.css makes it match) and use
	these classes for the parts Bootstrap doesn't have: the header, error panel, empty state and no-access page.

	Contents: header, page, labels, panel, buttons, fields, table, badge, error panel, empty state, no-access page.
*/

/* ---------- Header ----------
	<header class="ds-header">
		<div class="ds-header-inner">
			<a class="ds-brand" href="/">App name</a>
			<nav class="ds-nav"><a href="/" aria-current="page">Home</a><a href="/help">Help</a></nav>
			<div class="ds-header-end"><span class="ds-avatar">EB</span></div>
		</div>
	</header>
*/

.ds-header {
	background: var(--ds-header-bg);
	color: var(--ds-on-header);
	border-bottom: 1px solid var(--ds-line);
}

.ds-header-inner {
	display: flex;
	align-items: center;
	gap: var(--ds-space-4);
	max-width: var(--ds-content-width);
	height: var(--ds-header-height);
	margin: 0 auto;
	padding: 0 var(--ds-space-5);
}

.ds-brand {
	display: inline-flex;
	align-items: center;
	gap: var(--ds-space-2);
	color: inherit;
	font-family: var(--ds-font-display);
	font-weight: var(--ds-display-weight);
	font-size: var(--ds-text-lg);
	text-decoration: none;
	white-space: nowrap;
}

.ds-brand:hover {
	color: inherit;
}

/* Scrolls sideways on a narrow screen rather than wrapping under the brand */
.ds-nav {
	display: flex;
	gap: var(--ds-space-4);
	min-width: 0;
	overflow-x: auto;
}

.ds-nav a {
	padding: var(--ds-space-1) 0;
	color: inherit;
	opacity: 0.75;
	font-family: var(--ds-font-label);
	font-size: var(--ds-text-xs);
	letter-spacing: var(--ds-label-tracking);
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	transition: opacity var(--ds-duration-fast) var(--ds-ease);
}

.ds-nav a:hover,
.ds-nav a[aria-current] {
	color: inherit;
	opacity: 1;
}

.ds-nav a[aria-current] {
	box-shadow: inset 0 -2px 0 var(--ds-accent);
}

.ds-header-end {
	display: flex;
	align-items: center;
	gap: var(--ds-space-3);
	margin-left: auto;
}

/* The signed-in user's initials */
.ds-avatar {
	display: inline-grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border: 1px solid var(--ds-accent);
	border-radius: 50%;
	font-size: var(--ds-text-xs);
	letter-spacing: 0.05em;
}

/* ---------- Page ---------- */

.ds-main {
	max-width: var(--ds-content-width);
	margin: 0 auto;
	padding: var(--ds-space-6) var(--ds-space-5) var(--ds-space-7);
}

.ds-title {
	margin: 0 0 var(--ds-space-1);
	font-family: var(--ds-font-display);
	font-style: var(--ds-display-style);
	font-weight: var(--ds-display-weight);
	font-size: var(--ds-text-2xl);
	line-height: 1.2;
}

/* The line under a page's title */
.ds-lede {
	margin: 0 0 var(--ds-space-5);
	color: var(--ds-muted);
}

/* ---------- Labels: small uppercase text above a section or value ---------- */

.ds-label {
	margin: 0 0 var(--ds-space-2);
	font-family: var(--ds-font-label);
	font-size: var(--ds-text-xs);
	font-weight: 400;
	letter-spacing: var(--ds-label-tracking);
	text-transform: uppercase;
	color: var(--ds-accent-text);
}

/* ---------- Panel ---------- */

.ds-panel {
	margin-bottom: var(--ds-space-5);
	padding: var(--ds-space-4) var(--ds-space-5);
	background: var(--ds-surface);
	border: 1px solid var(--ds-line);
	border-radius: var(--ds-radius-lg);
}

.ds-panel-title {
	margin: 0 0 var(--ds-space-2);
	font-family: var(--ds-font-label);
	font-size: var(--ds-text-xs);
	font-weight: 600;
	letter-spacing: var(--ds-label-tracking);
	text-transform: uppercase;
	color: var(--ds-muted);
}

/* ---------- Buttons: <button class="ds-btn ds-btn-primary"> (also on <a>) ---------- */

.ds-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--ds-space-2);
	min-height: 40px;
	padding: var(--ds-space-2) var(--ds-space-4);
	border: 1px solid var(--ds-line-strong);
	border-radius: var(--ds-radius);
	background: transparent;
	color: var(--ds-text);
	font-family: var(--ds-font-body);
	font-size: var(--ds-text-sm);
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--ds-duration-fast) var(--ds-ease), border-color var(--ds-duration-fast) var(--ds-ease), color var(--ds-duration-fast) var(--ds-ease);
}

.ds-btn:hover {
	background: var(--ds-accent-tint);
	border-color: var(--ds-accent);
	color: var(--ds-text);
}

.ds-btn-primary {
	background: var(--ds-primary);
	border-color: var(--ds-primary);
	color: var(--ds-on-primary);
}

.ds-btn-primary:hover {
	background: color-mix(in srgb, var(--ds-primary) 85%, var(--ds-text));
	border-color: color-mix(in srgb, var(--ds-primary) 85%, var(--ds-text));
	color: var(--ds-on-primary);
}

/* Outlined, so it doesn't compete with the main button; filled on hover */
.ds-btn-danger {
	border-color: var(--ds-danger);
	color: var(--ds-danger);
}

.ds-btn-danger:hover {
	background: var(--ds-danger);
	border-color: var(--ds-danger);
	color: var(--ds-on-danger);
}

.ds-btn-sm {
	min-height: 32px;
	padding: var(--ds-space-1) var(--ds-space-3);
	font-size: var(--ds-text-xs);
}

.ds-btn:disabled,
.ds-btn[aria-disabled="true"] {
	opacity: 0.55;
	pointer-events: none;
	cursor: default;
}

/* ---------- Busy: <button class="ds-busy" aria-busy="true"> (busy.js adds it; also on <a> and <select>) ----------
	What was tapped, while its work is on the way: a spinner in the text's color before a button's or link's text, a
	slow fade on a select, and no second tap. Any button or link, not only .ds-btn (Bootstrap's .btn, a site's own).
	A theme may restyle it, e.g. a quiet fade instead of the spinner on small icon buttons. */

.ds-busy {
	cursor: progress;
	pointer-events: none;
}

button.ds-busy,
a.ds-busy {
	opacity: 0.8;
}

button.ds-busy::before,
a.ds-busy::before {
	content: "";
	display: inline-block;
	flex: none;
	width: 0.85em;
	height: 0.85em;
	margin-inline-end: 0.4em;
	vertical-align: -0.1em;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: ds-spin 0.7s linear infinite;
}

/* A flex button already spaces its parts */
.ds-btn.ds-busy::before {
	margin-inline-end: 0;
}

select.ds-busy {
	animation: ds-fade 0.7s ease-in-out infinite alternate;
}

@keyframes ds-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes ds-fade {
	from {
		opacity: 1;
	}

	to {
		opacity: 0.4;
	}
}

/* A row of buttons */
.ds-actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ds-space-2);
}

/* ---------- Fields ----------
	<label class="ds-field">
		<span class="ds-field-label">Note</span>
		<input class="ds-input">
		<span class="ds-field-help">Both of you see this.</span>
	</label>
	Add is-invalid to the .ds-field (or aria-invalid="true" to the input) for an error; its help text turns red.
*/

.ds-field {
	display: grid;
	gap: var(--ds-space-1);
	margin-bottom: var(--ds-space-4);
}

.ds-field-label {
	font-size: var(--ds-text-sm);
	font-weight: 500;
}

.ds-input {
	width: 100%;
	min-height: 40px;
	padding: var(--ds-space-2) var(--ds-space-3);
	background: var(--ds-surface);
	border: 1px solid var(--ds-line-strong);
	border-radius: var(--ds-radius);
	color: var(--ds-text);
	transition: border-color var(--ds-duration-fast) var(--ds-ease), box-shadow var(--ds-duration-fast) var(--ds-ease);
}

textarea.ds-input {
	min-height: 6em;
	resize: vertical;
}

.ds-input::placeholder {
	color: var(--ds-muted);
}

.ds-input:focus {
	outline: none;
	border-color: var(--ds-accent);
	box-shadow: 0 0 0 3px var(--ds-focus);
}

.ds-input:disabled {
	background: var(--ds-bg);
	color: var(--ds-muted);
}

.ds-field-help {
	font-size: var(--ds-text-xs);
	color: var(--ds-muted);
}

.ds-field.is-invalid .ds-input,
.ds-input[aria-invalid="true"] {
	border-color: var(--ds-danger);
}

.ds-field.is-invalid .ds-field-help {
	color: var(--ds-danger);
}

/* Blazor's own validation classes (EditForm, ValidationMessage) */
.invalid {
	border-color: var(--ds-danger) !important;
}

.validation-message {
	font-size: var(--ds-text-sm);
	color: var(--ds-danger);
}

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

.ds-table {
	width: 100%;
	margin-bottom: var(--ds-space-5);
	border-collapse: collapse;
	font-size: var(--ds-text-sm);
	font-variant-numeric: tabular-nums;
}

.ds-table th,
.ds-table td {
	padding: var(--ds-space-2) var(--ds-space-3);
	text-align: left;
	vertical-align: top;
}

.ds-table th {
	font-family: var(--ds-font-label);
	font-size: var(--ds-text-xs);
	font-weight: 400;
	letter-spacing: var(--ds-label-tracking);
	text-transform: uppercase;
	color: var(--ds-muted);
	border-bottom: 1px solid var(--ds-line-strong);
}

.ds-table td {
	border-bottom: 1px solid var(--ds-line);
}

.ds-table tbody tr:hover td {
	background: var(--ds-accent-tint);
}

/* Numbers line up on the right */
.ds-table .ds-num,
.ds-num {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

/* ---------- Badge: <span class="ds-badge ds-badge-success">Paid</span> ---------- */

.ds-badge {
	display: inline-flex;
	align-items: center;
	padding: 2px var(--ds-space-2);
	border-radius: var(--ds-radius-sm);
	background: var(--ds-accent-tint);
	color: var(--ds-accent-text);
	font-family: var(--ds-font-label);
	font-size: var(--ds-text-xs);
	letter-spacing: var(--ds-label-tracking);
	text-transform: uppercase;
	line-height: 1.5;
	white-space: nowrap;
}

.ds-badge-success {
	background: color-mix(in srgb, var(--ds-success) 14%, var(--ds-bg));
	color: var(--ds-success);
}

.ds-badge-danger {
	background: var(--ds-danger-tint);
	color: var(--ds-danger);
}

.ds-badge-muted {
	background: var(--ds-surface);
	color: var(--ds-muted);
	box-shadow: inset 0 0 0 1px var(--ds-line);
}

/* ---------- Error panel: shown in place of content that failed ----------
	<div class="ds-error" role="alert">
		<p class="ds-error-title">Couldn't save</p>
		<p>The server didn't answer. Your changes are still here.</p>
		<p class="ds-error-detail">Request id 4f2a...</p>
		<div class="ds-actions"><button class="ds-btn ds-btn-sm">Try again</button></div>
	</div>
*/

.ds-error {
	max-width: 40rem;
	margin-bottom: var(--ds-space-5);
	padding: var(--ds-space-3) var(--ds-space-4);
	background: var(--ds-danger-tint);
	border: 1px solid var(--ds-danger);
	border-left-width: 4px;
	border-radius: var(--ds-radius);
}

.ds-error p {
	margin: 0 0 var(--ds-space-3);
	font-size: var(--ds-text-sm);
}

.ds-error .ds-error-title {
	margin-bottom: var(--ds-space-1);
	font-size: var(--ds-text-base);
	font-weight: 600;
	color: var(--ds-danger);
}

.ds-error .ds-error-detail {
	font-family: var(--ds-font-mono);
	font-size: var(--ds-text-xs);
	color: var(--ds-muted);
	overflow-wrap: anywhere;
}

/* ---------- Empty state: nothing to show yet ---------- */

.ds-empty {
	margin-bottom: var(--ds-space-5);
	padding: var(--ds-space-7) var(--ds-space-5);
	border: 1px dashed var(--ds-line-strong);
	border-radius: var(--ds-radius-lg);
	color: var(--ds-muted);
	text-align: center;
}

.ds-empty-title {
	margin: 0 0 var(--ds-space-2);
	font-family: var(--ds-font-display);
	font-style: var(--ds-display-style);
	font-weight: var(--ds-display-weight);
	font-size: var(--ds-text-lg);
	color: var(--ds-text);
}

.ds-empty .ds-actions {
	justify-content: center;
	margin-top: var(--ds-space-4);
}

/* ---------- No access: signed in, but without a role in this app ---------- */

.ds-no-access {
	max-width: 28rem;
	margin: var(--ds-space-8) auto;
	padding: var(--ds-space-6);
	background: var(--ds-surface);
	border: 1px solid var(--ds-line);
	border-radius: var(--ds-radius-lg);
	text-align: center;
}

.ds-no-access h1,
.ds-no-access .ds-no-access-title {
	margin: 0 0 var(--ds-space-3);
	font-family: var(--ds-font-display);
	font-style: var(--ds-display-style);
	font-weight: var(--ds-display-weight);
	font-size: var(--ds-text-xl);
}

.ds-no-access p {
	color: var(--ds-muted);
}

.ds-no-access .ds-actions {
	justify-content: center;
}
