/*
 * IRIS supportlet brand v1.0.0
 * Component classes built on the tokens in brand.tokens.css.
 * Load order: brand.tokens.css → brand.css → themes/<sub-brand>.css (optional override)
 */
@import url('./brand.tokens.css');

/* ── Reset / base ────────────────────────────────────────────────────── */
*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: var(--font-sans);
	background: var(--surface-muted);
	color: var(--text);
	line-height: 1.5;
}

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

/* ── App shell (header + main) ───────────────────────────────────────── */
.app-shell {
	min-height: 100vh;
}

.app-header {
	background: var(--brand-dark);
	color: var(--text-on-dark);
	padding: 0 2rem;
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: var(--shadow-header);
}

.app-header-inner {
	max-width: var(--container-max);
	margin: 0 auto;
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: var(--header-height);
}

.app-brand {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.app-brand .app-logo {
	height: 32px;
	width: auto;
	background: #fff;
	padding: 4px 8px;
	border: 1px solid rgba(255, 255, 255, 0.9);
	border-radius: 6px;
}

.app-brand-text h1 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--text-on-dark);
	letter-spacing: -0.01em;
	line-height: 1.2;
}

.app-brand-text .app-subtitle {
	font-size: 0.75rem;
	color: var(--text-on-dark-muted);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.app-version-label {
	font-size: 0.65rem;
	color: var(--text-on-dark-faint);
	align-self: flex-end;
	margin-left: 0.5rem;
	font-family: var(--font-mono);
}

.app-auth {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.app-auth .app-user {
	font-size: 0.875rem;
	color: rgba(255, 255, 255, 0.8);
}

/* Stack client + authenticated-user (or any second line) under each other.
 * Populate the second line from the X-Forwarded-User header set by the
 * forwardAuth middleware (see brand README "Surfacing the authenticated user"). */
.app-user-block {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	line-height: 1.3;
}

.app-user-detail {
	font-size: 0.7rem;
	color: var(--text-on-dark-faint);
	font-family: var(--font-mono);
	letter-spacing: 0.01em;
}

.app-main {
	max-width: var(--container-max);
	margin: 0 auto;
	padding: 2rem;
}

.app-main--centered {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	min-height: calc(100vh - var(--header-height));
}

/* ── Section heading ─────────────────────────────────────────────────── */
.section-heading {
	margin: 0 0 0.75rem 0;
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--brand-primary);
}

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
	background: var(--surface);
	border-radius: var(--radius-card);
	padding: 1.5rem;
	box-shadow: var(--shadow-card);
}

.stat-card {
	background: var(--surface);
	border-radius: var(--radius-card);
	padding: 1.25rem 1.5rem;
	box-shadow: var(--shadow-card);
	border-left: 4px solid var(--brand-primary);
}

.stat-card .stat-value {
	display: block;
	font-size: 2rem;
	font-weight: 700;
	color: var(--text);
	line-height: 1.2;
}

.stat-card .stat-label {
	font-size: 0.8rem;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.status-card {
	text-align: center;
	padding: 4rem 2rem;
	background: var(--surface);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
}

.status-card.is-error {
	border-left: 4px solid var(--danger);
}
.status-card.is-warn {
	border-left: 4px solid var(--warn-soft);
}
.status-card.is-success {
	border-left: 4px solid var(--success);
}
.status-card.is-info {
	border-left: 4px solid var(--brand-primary);
}

.status-card h2 {
	margin: 0 0 0.75rem 0;
	color: var(--text);
	font-size: 1.25rem;
}

.status-card p {
	color: var(--text-muted);
	margin: 0 0 1.5rem 0;
}

.status-card .hint {
	font-size: 0.85rem;
	color: var(--text-faint);
	margin-top: 1rem;
}

/* ── Info box (left-stripe panel for inline notes) ───────────────────── */
.info-box {
	background: var(--surface-muted);
	border-left: 4px solid var(--brand-primary);
	padding: 1rem 1.25rem;
	border-radius: var(--radius-small);
	margin-bottom: 1.5rem;
}

.info-box p {
	margin: 0;
	font-size: 0.9rem;
	color: var(--text-muted);
}

.info-box strong {
	color: var(--text);
}

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert {
	padding: 0.875rem 1.125rem;
	border-radius: var(--radius-input);
	margin-bottom: 1.5rem;
	font-size: 0.9rem;
	line-height: 1.5;
	border: 1px solid transparent;
}

.alert.is-error {
	background: var(--danger-tint);
	border-color: var(--danger);
	color: var(--danger);
}
.alert.is-warn {
	background: var(--warn-tint);
	border-color: var(--warn-soft);
	color: var(--warn-strong);
}
.alert.is-success {
	background: var(--success-tint);
	border-color: var(--success);
	color: var(--success-hover);
}
.alert.is-info {
	background: var(--brand-primary-tint);
	border-color: var(--brand-primary);
	color: var(--brand-primary-hover);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.6em 1.75em;
	border: none;
	border-radius: var(--radius-pill);
	font-family: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
}

.btn:disabled {
	cursor: not-allowed;
	opacity: 0.5;
}

.btn-primary {
	background: var(--brand-primary);
	color: var(--text-on-dark);
}
.btn-primary:hover:not(:disabled) {
	background: var(--brand-primary-hover);
	transform: translateY(-1px);
	box-shadow: var(--shadow-button-hover);
}

.btn-secondary {
	background: var(--surface-muted);
	color: var(--text);
	border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
	background: var(--border);
	border-color: var(--border-strong);
}

.btn-outline {
	background: transparent;
	color: var(--text-on-dark);
	border: 1.5px solid rgba(255, 255, 255, 0.4);
}
.btn-outline:hover:not(:disabled) {
	border-color: var(--text-on-dark);
	background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
	background: var(--danger);
	color: var(--text-on-dark);
}
.btn-danger:hover:not(:disabled) {
	background: var(--danger-hover);
	transform: translateY(-1px);
}

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-group {
	margin-bottom: 1.5rem;
}

.form-group label {
	display: block;
	font-weight: 600;
	color: var(--text);
	margin-bottom: 0.75rem;
	font-size: 0.875rem;
}

.button-group {
	display: flex;
	gap: 0.75rem;
	margin-top: 2rem;
}

.text-input,
.search-input {
	width: 100%;
	padding: 0.5rem 1rem;
	border: 1.5px solid var(--border);
	border-radius: var(--radius-input);
	font-family: inherit;
	font-size: 0.9rem;
	color: var(--text);
	background: var(--surface);
	outline: none;
	transition: border-color 0.15s;
}

.text-input:focus,
.search-input:focus {
	border-color: var(--brand-primary);
}

.text-input::placeholder,
.search-input::placeholder {
	color: var(--text-faint);
}

/* ── Toggle switch ───────────────────────────────────────────────────── */
.toggle-container {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.toggle-switch {
	position: relative;
	width: 60px;
	height: 32px;
	flex-shrink: 0;
}

.toggle-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-switch .slider {
	position: absolute;
	cursor: pointer;
	inset: 0;
	background: var(--border-strong);
	transition: 0.3s;
	border-radius: 32px;
}

.toggle-switch .slider::before {
	content: '';
	position: absolute;
	height: 24px;
	width: 24px;
	left: 4px;
	bottom: 4px;
	background: var(--surface);
	transition: 0.3s;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .slider {
	background: var(--brand-primary);
}

.toggle-switch input:checked + .slider::before {
	transform: translateX(28px);
}

.toggle-switch input:disabled + .slider {
	cursor: not-allowed;
	opacity: 0.5;
}

.toggle-label {
	font-size: 1rem;
	font-weight: 600;
	color: var(--text);
}

.toggle-label.is-on {
	color: var(--brand-primary);
}

.toggle-label.is-off {
	color: var(--text-muted);
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.brand-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	font-size: 0.85rem;
}

.brand-table th {
	background: var(--brand-dark);
	color: var(--text-on-dark);
	padding: 0.625rem 1rem;
	text-align: left;
	font-weight: 600;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.brand-table th:first-child {
	border-radius: var(--radius-input) 0 0 0;
}
.brand-table th:last-child {
	border-radius: 0 var(--radius-input) 0 0;
}

.brand-table td {
	padding: 0.5rem 1rem;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}

.brand-table tbody tr:hover td {
	background: var(--surface-muted);
}

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
	display: inline-block;
	padding: 0.2rem 0.6rem;
	border-radius: var(--radius-pill);
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.badge.is-success {
	background: var(--success-tint);
	color: var(--success-hover);
}
.badge.is-error {
	background: var(--danger-tint);
	color: var(--danger);
}
.badge.is-warn {
	background: var(--warn-tint);
	color: var(--warn-strong);
}
.badge.is-info {
	background: var(--brand-primary-tint);
	color: var(--brand-primary);
}
.badge.is-neutral {
	background: var(--surface-muted);
	color: var(--text-muted);
}

/* ── Dialog ──────────────────────────────────────────────────────────── */
.dialog-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	backdrop-filter: blur(2px);
}

.dialog {
	background: var(--surface);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-dialog);
	width: 480px;
	max-width: 90vw;
	overflow: hidden;
}

.dialog-header {
	background: var(--brand-dark);
	color: var(--text-on-dark);
	padding: 1rem 1.5rem;
	font-size: 0.9rem;
	font-weight: 600;
}

.dialog-body {
	padding: 1.5rem;
}

.dialog-body p {
	margin: 0 0 1rem 0;
	color: var(--text);
	font-size: 0.9rem;
}

.dialog-footer {
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--border);
	background: var(--surface-muted);
}

/* ── Spinner ─────────────────────────────────────────────────────────── */
.spinner {
	width: 32px;
	height: 32px;
	border: 3px solid var(--border);
	border-top-color: var(--brand-primary);
	border-radius: 50%;
	margin: 0 auto 1rem;
	animation: brand-spin 0.8s linear infinite;
}

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

/* ── Utilities ───────────────────────────────────────────────────────── */
.muted {
	color: var(--text-muted);
}
.faint {
	color: var(--text-faint);
}
.mono {
	font-family: var(--font-mono);
}
.text-center {
	text-align: center;
}
.flex-1 {
	flex: 1;
}
