/*
 * AngelAgent web client — muse-inspired design system (2026-12-03).
 *
 * Layout language (mirrors muse.ai's chat surface): a quiet light sidebar
 * (identity, sessions, area navigation) beside a centered conversation column
 * with message cards, and a rounded composer anchored at the bottom.
 *
 * The palette stays deliberately monochrome-plus-one-accent so tenant
 * white-label (--brand, set at runtime from the tenant's brand color) always
 * looks intentional. Structure: tokens, shell, sidebar, chat, composer,
 * panels, forms, status/empty states, responsive.
 */

:root {
	--bg: #ffffff;
	--sidebar: #f7f7f8;
	--soft: #f3f4f6;
	--soft-2: #ececee;
	--border: #e5e7eb;
	--border-strong: #d1d5db;
	--text: #111827;
	--text-soft: #374151;
	--muted: #6b7280;
	--faint: #9ca3af;
	--brand: #6d28d9;
	--brand-soft: color-mix(in srgb, var(--brand) 10%, white);
	--danger: #b91c1c;
	--ok: #047857;
	--warn: #b45309;
	--radius-s: 8px;
	--radius-m: 12px;
	--radius-l: 16px;
	--radius-xl: 24px;
	--shadow: 0 1px 2px rgb(16 24 40 / 0.05);
	--font:
		-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter,
		"Helvetica Neue", Arial, sans-serif;
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.55;
	color: var(--text);
	background: var(--bg);
	display: flex;
	overflow: hidden;
}

/* ---------- shell ---------- */

aside#sessionsPane {
	width: 302px;
	min-width: 302px;
	height: 100dvh;
	overflow-y: auto;
	background: var(--sidebar);
	border-right: 1px solid var(--border);
	padding: 14px 12px 18px;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

main {
	flex: 1;
	height: 100dvh;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
}

.view {
	width: 100%;
	max-width: 880px;
	margin: 0 auto;
	padding: 22px 26px 40px;
	display: flex;
	flex-direction: column;
	gap: 18px;
	flex: 1;
}

.view.hidden {
	display: none;
}

/* The chat view hugs the viewport so the composer can sit at the bottom. */
#view-console {
	min-height: 0;
}

/* ---------- sidebar: identity card ---------- */

header {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
}

#brand strong {
	font-size: 15px;
	font-weight: 650;
	letter-spacing: -0.01em;
}

#logo {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: var(--brand);
	color: #fff;
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 16px;
	flex: none;
}

#tenantName {
	font-size: 12px;
	color: var(--muted);
	display: block;
}

.brand-col {
	display: flex;
	flex-direction: column;
	line-height: 1.25;
	min-width: 0;
}

.brand-col .tagline {
	font-size: 11.5px;
	color: var(--faint);
}

/* ---------- sidebar: area navigation (descriptive labels) ---------- */

nav {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

nav .nav {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 1px;
	width: 100%;
	text-align: left;
	padding: 9px 12px;
	border: 0;
	border-radius: var(--radius-m);
	background: transparent;
	color: var(--text-soft);
	font: inherit;
	cursor: pointer;
}

nav .nav:hover {
	background: var(--soft-2);
}

nav .nav.active {
	background: #fff;
	color: var(--text);
	box-shadow: var(--shadow);
	font-weight: 600;
}

nav .nav .nav-title {
	font-size: 13.5px;
	font-weight: 600;
}

nav .nav .nav-sub {
	font-size: 11px;
	color: var(--muted);
	font-weight: 400;
}

nav .nav.ghost {
	opacity: 0.95;
}

.sidebar-divider {
	height: 1px;
	background: var(--border);
	margin: 2px 4px;
}

.sidebar-label {
	font-size: 11px;
	font-weight: 650;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--faint);
	padding: 0 12px;
}

/* ---------- sidebar: session list (muse's chat rows) ---------- */

#sessions {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
	flex: 1;
}

#sessions li {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 9px 10px;
	border-radius: var(--radius-m);
	cursor: pointer;
	min-width: 0;
}

#sessions li:hover {
	background: var(--soft-2);
}

#sessions li.active {
	background: #fff;
	box-shadow: var(--shadow);
}

.session-avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--brand-soft);
	color: var(--brand);
	font-size: 12px;
	font-weight: 700;
	display: grid;
	place-items: center;
	flex: none;
}

.session-col {
	min-width: 0;
	display: flex;
	flex-direction: column;
	line-height: 1.3;
}

.session-title {
	font-size: 13px;
	font-weight: 550;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.session-meta {
	font-size: 11px;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

#newChat,
#sideChat {
	width: 100%;
	border: 1px solid var(--border);
	background: #fff;
	border-radius: var(--radius-m);
	padding: 9px 12px;
	font: inherit;
	font-size: 13px;
	font-weight: 550;
	color: var(--text-soft);
	cursor: pointer;
	box-shadow: var(--shadow);
}

#newChat:hover,
#sideChat:hover {
	border-color: var(--border-strong);
}

#sideChat {
	margin-top: 6px;
}

.sidebar-actions {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

/* ---------- sidebar: session internals + footer ---------- */

details#sessionTools,
details#demoTools {
	border: 1px solid var(--border);
	border-radius: var(--radius-m);
	background: #fff;
	padding: 8px 12px;
}

details#sessionTools summary,
details#demoTools summary {
	cursor: pointer;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--text-soft);
}

details#sessionTools button,
details#demoTools button {
	margin-top: 6px;
}

.sidebar-foot {
	margin-top: auto;
	font-size: 11px;
	color: var(--faint);
	padding: 4px 12px;
	overflow-wrap: anywhere;
	line-height: 1.4;
}

/* ---------- chat head (muse: "Chat with X" + status line) ---------- */

.chat-head {
	padding-top: 6px;
}

.chat-head h1 {
	margin: 0;
	font-size: 21px;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.chat-status {
	color: var(--muted);
	font-size: 12.5px;
	margin-top: 2px;
}

.chat-status .dot {
	color: var(--ok);
}

/* ---------- messages (muse: avatar + meta + card) ---------- */

#messages {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 18px;
	padding: 6px 2px 12px;
	min-height: 120px;
}

.msg-row {
	display: flex;
	gap: 12px;
	align-items: flex-start;
}

.msg-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	flex: none;
	display: grid;
	place-items: center;
	font-size: 13px;
	font-weight: 700;
	color: #fff;
	background: var(--brand);
}

.msg-row.user .msg-avatar {
	background: #4b5563;
}

.msg-col {
	min-width: 0;
	flex: 1;
}

.msg-meta {
	display: flex;
	gap: 8px;
	align-items: baseline;
	margin-bottom: 3px;
}

.msg-name {
	font-size: 13px;
	font-weight: 650;
}

.msg-time {
	font-size: 11px;
	color: var(--faint);
}

.msg-card {
	border: 1px solid var(--border);
	border-radius: var(--radius-l);
	padding: 11px 15px;
	background: #fff;
	box-shadow: var(--shadow);
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.msg-row.user .msg-card {
	background: var(--soft);
	border-color: transparent;
}

.msg-actions {
	display: flex;
	gap: 10px;
	margin-top: 5px;
	opacity: 0.55;
}

.msg-row:hover .msg-actions {
	opacity: 1;
}

.msg-actions button {
	border: 0;
	background: none;
	color: var(--muted);
	font-size: 11.5px;
	cursor: pointer;
	padding: 2px 4px;
	border-radius: 6px;
}

.msg-actions button:hover {
	background: var(--soft-2);
	color: var(--text-soft);
}

/* legacy content classes (kept for streaming/council nodes) */
.msg {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

.msg.assistant {
	color: var(--text);
}

.msg.user {
	color: var(--text-soft);
}

/* ---------- composer (muse: rounded box, + circle, send circle) ---------- */

form#composer {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-xl);
	padding: 10px 12px;
	background: #fff;
	box-shadow: var(--shadow);
}

form#composer:focus-within {
	border-color: var(--brand);
	box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea#input {
	flex: 1;
	border: 0;
	outline: none;
	resize: none;
	font: inherit;
	font-size: 15px;
	line-height: 1.5;
	background: transparent;
	color: var(--text);
	max-height: 180px;
}

textarea#input::placeholder {
	color: var(--faint);
}

.icon-btn {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 1px solid var(--border);
	background: #fff;
	color: var(--text-soft);
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
	display: grid;
	place-items: center;
	flex: none;
}

.icon-btn:hover {
	background: var(--soft);
}

form#composer button[type="submit"] {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 0;
	background: var(--brand);
	color: #fff;
	font-size: 16px;
	cursor: pointer;
	display: grid;
	place-items: center;
	flex: none;
}

form#composer button[type="submit"]:hover {
	filter: brightness(1.08);
}

.composer-hint {
	font-size: 11.5px;
	color: var(--faint);
	text-align: center;
	margin-top: -8px;
}

/* ---------- mode row (chat actions) ---------- */

.mode-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 16px;
	align-items: center;
	font-size: 12.5px;
	color: var(--muted);
}

.mode-row label {
	display: flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}

/* ---------- buttons, forms, inputs ---------- */

button,
select {
	font: inherit;
}

button:not(.icon-btn):not(.nav):not(#newChat):not(#sideChat),
input[type="file"] + label {
	border: 1px solid var(--border-strong);
	background: #fff;
	color: var(--text-soft);
	border-radius: 10px;
	padding: 7px 13px;
	font-size: 13px;
	font-weight: 550;
	cursor: pointer;
}

button:not(.icon-btn):not(.nav):not(#newChat):not(#sideChat):hover {
	background: var(--soft);
}

input[type="text"],
input[type="number"],
input:not([type]),
select,
textarea {
	border: 1px solid var(--border-strong);
	border-radius: 10px;
	padding: 7px 11px;
	font: inherit;
	font-size: 13.5px;
	background: #fff;
	color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
	outline: 2px solid var(--brand-soft);
	border-color: var(--brand);
}

label {
	font-size: 12.5px;
	color: var(--text-soft);
}

.row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

/* ---------- panels (all non-chat views) ---------- */

.panel {
	border: 1px solid var(--border);
	border-radius: var(--radius-l);
	background: #fff;
	padding: 16px 18px;
	box-shadow: var(--shadow);
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.panel h2 {
	margin: 0;
	font-size: 16px;
	font-weight: 650;
	letter-spacing: -0.01em;
}

.panel h3 {
	margin: 0;
	font-size: 14px;
	font-weight: 650;
}

/* visible descriptive subtitle under panel headings (muse's status lines) */
.sub {
	margin: -8px 0 0;
	font-size: 12.5px;
	color: var(--muted);
}

.hint {
	font-weight: 400;
	font-size: 12px;
	color: var(--muted);
}

.view-intro {
	margin: 0;
	color: var(--muted);
	font-size: 13px;
	max-width: 62ch;
}

/* ---------- status, outputs, empty states ---------- */

.status {
	font-size: 12px;
	color: var(--muted);
	min-height: 1em;
}

.status:empty {
	min-height: 0;
}

.out {
	background: var(--soft);
	border: 1px solid var(--border);
	border-radius: var(--radius-m);
	padding: 10px 12px;
	font-size: 12px;
	overflow: auto;
	max-height: 260px;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

.empty {
	color: var(--faint);
	font-size: 12.5px;
	padding: 8px 2px;
}

ul:empty::after {
	content: attr(data-empty);
	color: var(--faint);
	font-size: 12.5px;
}

/* lists inside panels (facts, tasks, approvals, ...) */
.panel ul,
#approvals {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.panel ul li,
#approvals li {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 8px 11px;
	font-size: 13px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

#sessions ul {
	all: unset;
}

/* ---------- approvals (the decision surface — high visibility) ---------- */

#approvalsPanel {
	border: 1px solid var(--border-strong);
	background: linear-gradient(180deg, var(--brand-soft), #fff 42%);
}

#approvals li {
	background: #fff;
}

/* ---------- global banner (failures are never silent) ---------- */

.banner {
	margin: 0;
	padding: 11px 15px;
	border-radius: var(--radius-m);
	font-size: 13px;
	font-weight: 550;
	flex: none;
}

.banner.error {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: var(--danger);
}

.banner.warn {
	background: #fffbeb;
	border: 1px solid #fde68a;
	color: var(--warn);
}

/* ---------- tip banner (muse-style, bottom of console) ---------- */

.tip-banner {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	background: #fef9e7;
	border: 1px solid #f5e6b6;
	color: #7a5c00;
	border-radius: var(--radius-m);
	padding: 10px 13px;
	font-size: 12px;
}

.tip-banner .tip-icon {
	font-size: 15px;
	line-height: 1.3;
}

/* ---------- misc ---------- */

.hidden {
	display: none !important;
}

a {
	color: var(--brand);
}

code {
	background: var(--soft);
	border-radius: 5px;
	padding: 1px 5px;
	font-size: 0.92em;
}

mark {
	background: #fde68a;
	border-radius: 4px;
	padding: 0 3px;
}

@media (max-width: 980px) {
	body {
		flex-direction: column;
		overflow: auto;
	}
	aside#sessionsPane {
		width: 100%;
		min-width: 0;
		height: auto;
		border-right: 0;
		border-bottom: 1px solid var(--border);
	}
	main {
		height: auto;
	}
	.view {
		padding: 16px;
	}
}
