@import "tailwindcss";
@import "@fontsource/dm-mono/400.css";
@import "@fontsource/dm-mono/500.css";
@import "@fontsource/dm-sans/400.css";
@import "@fontsource/dm-sans/500.css";
@import "@fontsource/dm-sans/600.css";

/* ─── Tailwind v4 theme bridge ─── */
@theme inline {
	--color-background: var(--bg);
	--color-foreground: var(--text-1);
	--color-card: var(--bg-2);
	--color-card-foreground: var(--text-1);
	--color-muted: var(--bg-3);
	--color-muted-foreground: var(--text-3);
	--color-primary: var(--accent);
	--color-primary-foreground: #ffffff;
	--color-secondary: var(--bg-3);
	--color-secondary-foreground: var(--text-2);
	--color-border: var(--border);
	--color-ring: var(--accent);
	--radius-sm: 6px;
	--radius-md: 8px;
	--radius-lg: 12px;
	--radius-xl: 16px;
}

/* ─── Theme tokens ─── */
:root,
[data-theme="dark"] {
	color-scheme: dark;
	--bg: #0b0d12;
	--bg-2: #121722;
	--bg-3: #1b2331;
	--surface: rgba(148, 163, 184, 0.08);
	--border: rgba(148, 163, 184, 0.18);
	--border-2: rgba(148, 163, 184, 0.28);
	--text-1: #f3f6ff;
	--text-2: #c3cddd;
	--text-3: #95a4bb;
	--text-4: #7787a0;
	--accent: #6366f1;
	--accent-text: #d6ddff;
	--accent-soft: #c7d2fe;
	--accent-dim: rgba(129, 140, 248, 0.18);
	--accent-dim-hover: rgba(129, 140, 248, 0.24);
	--accent-subtle: rgba(129, 140, 248, 0.14);
	--accent-muted: #a5b4fc;
	--accent-glow: rgba(129, 140, 248, 0.4);
	--accent-border: rgba(129, 140, 248, 0.4);
	--accent-border-strong: rgba(165, 180, 252, 0.56);
	--accent-spinner-track: rgba(129, 140, 248, 0.26);
	--dim-text: #a7b4c8;
	--dim-icon: rgba(167, 180, 200, 0.75);
	--card-base-bg: rgba(148, 163, 184, 0.08);
	--card-base-border: rgba(148, 163, 184, 0.18);
	--sidebar-bg: linear-gradient(180deg, #121722 0%, #0d1017 100%);
	--grid-line: rgba(129, 140, 248, 0.05);
	--glow: rgba(99, 102, 241, 0.1);
	--scrollbar: rgba(99, 102, 241, 0.2);
	--card-hover: rgba(129, 140, 248, 0.12);
}

[data-theme="light"] {
	color-scheme: light;
	--bg: #f8f8fc;
	--bg-2: #ffffff;
	--bg-3: #f0f0f8;
	--surface: rgba(0, 0, 0, 0.02);
	--border: rgba(0, 0, 0, 0.08);
	--border-2: rgba(0, 0, 0, 0.14);
	--text-1: #1a1a2e;
	--text-2: #374151;
	--text-3: #6b7280;
	--text-4: #9ca3af;
	--accent: #4f46e5;
	--accent-text: #4f46e5;
	--accent-soft: #6366f1;
	--accent-dim: rgba(79, 70, 229, 0.08);
	--accent-dim-hover: rgba(79, 70, 229, 0.12);
	--accent-subtle: rgba(79, 70, 229, 0.1);
	--accent-muted: #6366f1;
	--accent-glow: rgba(79, 70, 229, 0.28);
	--accent-border: rgba(79, 70, 229, 0.25);
	--accent-border-strong: rgba(79, 70, 229, 0.35);
	--accent-spinner-track: rgba(79, 70, 229, 0.18);
	--dim-text: #4b5563;
	--dim-icon: rgba(75, 85, 99, 0.6);
	--card-base-bg: rgba(15, 23, 42, 0.03);
	--card-base-border: rgba(15, 23, 42, 0.08);
	--sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f4f4fc 100%);
	--grid-line: rgba(79, 70, 229, 0.04);
	--glow: rgba(79, 70, 229, 0.06);
	--scrollbar: rgba(79, 70, 229, 0.2);
	--card-hover: rgba(79, 70, 229, 0.04);
}

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

html {
	font-family: "DM Sans", system-ui, sans-serif;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text-1);
	-webkit-font-smoothing: antialiased;
	transition:
		background 0.2s ease,
		color 0.2s ease;
}

#root {
	height: 100svh;
	display: flex;
	overflow: hidden;
}

/* ─── Grid background overlay ─── */
body::before {
	content: "";
	position: fixed;
	inset: 0;
	background-image:
		linear-gradient(var(--grid-line) 1px, transparent 1px),
		linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
	background-size: 32px 32px;
	pointer-events: none;
	z-index: 0;
}

/* ─── Glow ─── */
body::after {
	content: "";
	position: fixed;
	top: -20%;
	left: -10%;
	width: 60%;
	height: 70%;
	background: radial-gradient(ellipse at top left, var(--glow) 0%, transparent 70%);
	pointer-events: none;
	z-index: 0;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
	width: 5px;
	height: 5px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: var(--scrollbar);
	border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
	background: var(--accent);
	opacity: 0.5;
}

/* ─── Focus ─── */
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* ─── Utility classes using theme tokens ─── */
.theme-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
}

.theme-card:hover {
	background: var(--card-hover);
	border-color: var(--accent-border);
}

.theme-input {
	background: var(--surface);
	border: 1px solid var(--border-2);
	color: var(--text-1);
	border-radius: 10px;
	transition: border-color 0.15s;
}

.theme-input:focus {
	border-color: var(--accent);
	outline: none;
}

@keyframes skeleton-shimmer {
	0% {
		background-position: 200% 0;
	}

	100% {
		background-position: -200% 0;
	}
}

.theme-skeleton {
	background-image: linear-gradient(
		90deg,
		var(--skeleton-base) 0%,
		var(--skeleton-highlight) 50%,
		var(--skeleton-base) 100%
	);
	background-size: 200% 100%;
	animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

.theme-skeleton--accent {
	background-image: linear-gradient(
		90deg,
		var(--skeleton-accent-base) 0%,
		var(--skeleton-accent-highlight) 50%,
		var(--skeleton-accent-base) 100%
	);
}

@media (prefers-reduced-motion: reduce) {
	.theme-skeleton,
	.theme-skeleton--accent {
		animation: none;
		background-position: 50% 0;
	}
}

/* ─── Responsive container ─── */
/* Base: padding + centering only. Width is a CSS variable so modifiers cascade. */
.page-container {
	--page-max-width: 56rem;
	padding: 2rem;
	max-width: var(--page-max-width);
	margin: 0 auto;
	width: 100%;
}

/* Detail pages — WorkspaceDetail, SessionDetail, WebhookManager */
.page-container--wide {
	--page-max-width: 72rem;
}

/* Dashboard and full-grid pages — Dashboard, PeerDetail */
.page-container--xl {
	--page-max-width: 88rem;
}

@media (max-width: 640px) {
	.page-container {
		padding: 1rem;
	}
}
