/* Sans: variable Geist ships latin + latin-ext + cyrillic in one woff2,
   so RU and EN render in the same font instead of falling back to a
   system sans for Cyrillic. Replaces the legacy ``@fontsource/geist-sans``
   (latin-only) imports — see --font-sans below for the family rename. */
@import '@fontsource-variable/geist';
@import '@fontsource/geist-mono/400.css';
@import '@fontsource/geist-mono/500.css';
@import '@fontsource/geist-mono/600.css';
/* Geist Mono cyrillic subsets — same family name, additional unicode-range
   declarations so Russian text renders in Geist Mono instead of falling
   back to Cascadia/Consolas. */
@import '@fontsource/geist-mono/cyrillic-400.css';
@import '@fontsource/geist-mono/cyrillic-500.css';
@import '@fontsource/geist-mono/cyrillic-600.css';
@import '@fontsource/newsreader/300-italic.css';
@import '@fontsource/newsreader/400.css';
@import '@fontsource/newsreader/400-italic.css';
@import '@fontsource/newsreader/500.css';
@import '@fontsource/newsreader/500-italic.css';
@import '@fontsource/newsreader/600.css';
@import 'tailwindcss';

@theme {
	/* === AURORA: dark default ("Aurora") === */
	--color-background: #050613;
	--color-background-deep: #02030a;
	--color-foreground: #f3f1ff;
	--color-muted: rgba(255, 255, 255, 0.04);
	--color-muted-foreground: #b6b2d4;
	--color-border: rgba(255, 255, 255, 0.08);

	/* Glass surfaces — replace solid card */
	--color-glass: rgba(255, 255, 255, 0.04);
	--color-glass-strong: rgba(255, 255, 255, 0.07);
	--color-glass-elev: rgba(255, 255, 255, 0.10);
	--color-highlight: rgba(255, 255, 255, 0.14);
	--color-input-bg: rgba(255, 255, 255, 0.04);
	--color-rule-strong: rgba(255, 255, 255, 0.16);

	/* Accent palette — soft pastel constellation */
	--color-primary: #b8a7ff;       /* lavender — main accent */
	--color-primary-foreground: #02030a;
	--color-orchid: #ff9ec4;
	--color-mint:   #7ee8c4;
	--color-citrus: #f0e16a;
	--color-coral:  #ff8a78;
	--color-sky:    #8ec9ff;

	--color-accent: rgba(255, 255, 255, 0.07);
	--color-accent-foreground: #f3f1ff;
	--color-destructive: #ff8a78;

	/* Card mapping (kept for backward compat with components that read --color-card) */
	--color-card: rgba(255, 255, 255, 0.04);
	--color-card-foreground: #f3f1ff;

	/* Status surfaces */
	--color-success-bg: rgba(126, 232, 196, 0.12);
	--color-success-fg: #7ee8c4;
	--color-warning-bg: rgba(240, 225, 106, 0.12);
	--color-warning-fg: #f0e16a;
	--color-error-bg:   rgba(255, 138, 120, 0.12);
	--color-error-fg:   #ff8a78;

	/* Glow tokens — used for focus rings, hover halos */
	--color-glow:        rgba(184, 167, 255, 0.20);
	--color-glow-strong: rgba(184, 167, 255, 0.45);

	/* Sidebar tokens */
	--color-sidebar: rgba(255, 255, 255, 0.04);
	--color-sidebar-active: rgba(255, 255, 255, 0.10);

	/* Shadow recipe for floating glass */
	--shadow-card: 0 1px 0 rgba(255,255,255,0.07) inset, 0 30px 60px -20px rgba(0,0,0,0.6);

	/* Typography */
	--font-sans: 'Geist Variable', 'Geist', 'Geist Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	--font-mono: 'Geist Mono', ui-monospace, 'Cascadia Code', 'Consolas', monospace;
	--font-display: 'Newsreader', ui-serif, Georgia, serif;

	--radius: 1rem;

	/* z-index scale (unchanged) */
	--z-base: 1;
	--z-sticky: 10;
	--z-dropdown: 30;
	--z-overlay: 40;
	--z-modal: 50;
	--z-tooltip: 60;
	--z-toast: 70;
}

/* === AURORA: light theme ("Pearl") overrides === */
[data-theme="light"] {
	--color-background: #f5f3ff;
	--color-background-deep: #ede9fe;
	--color-foreground: #1a1530;
	--color-muted: rgba(20, 15, 60, 0.04);
	--color-muted-foreground: #3a3560;
	--color-border: rgba(20, 15, 60, 0.08);

	--color-glass: rgba(255, 255, 255, 0.55);
	--color-glass-strong: rgba(255, 255, 255, 0.65);
	--color-glass-elev: rgba(255, 255, 255, 0.80);
	--color-highlight: rgba(255, 255, 255, 0.9);
	--color-input-bg: rgba(255, 255, 255, 0.85);
	--color-rule-strong: rgba(20, 15, 60, 0.16);

	--color-primary: #6d4ce0;
	--color-primary-foreground: #ffffff;
	--color-orchid: #d63384;
	--color-mint:   #008a64;
	--color-citrus: #a07a00;
	--color-coral:  #e0512f;
	--color-sky:    #1f6fcc;

	--color-accent: rgba(20, 15, 60, 0.04);
	--color-accent-foreground: #1a1530;
	--color-destructive: #e0512f;

	--color-card: rgba(255, 255, 255, 0.55);
	--color-card-foreground: #1a1530;

	--color-success-bg: rgba(0, 138, 100, 0.10);
	--color-success-fg: #008a64;
	--color-warning-bg: rgba(160, 122, 0, 0.10);
	--color-warning-fg: #a07a00;
	--color-error-bg:   rgba(224, 81, 47, 0.10);
	--color-error-fg:   #e0512f;

	--color-glow:        rgba(109, 76, 224, 0.18);
	--color-glow-strong: rgba(109, 76, 224, 0.40);

	--color-sidebar: rgba(255, 255, 255, 0.55);
	--color-sidebar-active: rgba(255, 255, 255, 0.85);

	--shadow-card: 0 1px 0 rgba(255,255,255,0.5) inset, 0 20px 40px -16px rgba(80, 50, 180, 0.18);
}

/* Legacy alias — many components still read [data-theme="dark"] */
[data-theme="dark"] {
	/* defaults already match :root — no overrides needed, declaration kept for color-scheme */
}

body {
	font-family: var(--font-sans);
	background-color: var(--color-background);
	color: var(--color-foreground);
	transition: background-color 0.3s ease, color 0.3s ease;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	letter-spacing: -0.005em;
	min-height: 100vh;
	overflow-x: hidden;
}

/* === Aurora atmosphere — vivid blurred blobs behind everything === */
body::before {
	content: '';
	position: fixed;
	inset: -20vh -10vw;
	background:
		radial-gradient(40vw 40vw at 12% 18%, rgba(184, 167, 255, 0.55), transparent 60%),
		radial-gradient(35vw 35vw at 88% 22%, rgba(255, 158, 196, 0.45), transparent 60%),
		radial-gradient(50vw 35vw at 78% 88%, rgba(126, 232, 196, 0.40), transparent 60%),
		radial-gradient(40vw 30vw at 6% 92%, rgba(142, 201, 255, 0.42), transparent 60%);
	filter: blur(60px) saturate(140%);
	pointer-events: none;
	z-index: -2;
	animation: aurora-drift 28s ease-in-out infinite alternate;
}

body::after {
	content: '';
	position: fixed;
	inset: 0;
	z-index: -1;
	background: radial-gradient(circle at 50% 50%, transparent 30%, var(--color-background-deep) 100%);
	pointer-events: none;
	opacity: 0.7;
}

@keyframes aurora-drift {
	from { transform: translate(0, 0) scale(1); }
	to   { transform: translate(-2%, 1%) scale(1.05); }
}

[data-theme="light"] body::before { opacity: 0.85; }

/* Form controls — Aurora-native defaults */
input, select, textarea {
	color: var(--color-foreground);
	background-color: var(--color-input-bg);
	border: 1px solid var(--color-rule-strong);
	border-radius: 0.625rem;
	font-family: var(--font-sans);
	transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Default text inputs / search / textarea: comfortable padding.
   `<input type="checkbox">` and `<input type="radio">` are excluded so
   they keep their native compact sizing. Any explicit `padding`/`p-*`
   utility from a callsite still wins. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
textarea {
	padding: 0.55rem 0.85rem;
	font-size: 0.875rem;
}

select {
	padding: 0.55rem 2.2rem 0.55rem 0.85rem;
	font-size: 0.875rem;
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f6c92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 12px;
}

input:hover:not(:focus-visible):not([disabled]),
select:hover:not(:focus-visible):not([disabled]),
textarea:hover:not(:focus-visible):not([disabled]) {
	border-color: var(--color-rule-strong);
	background-color: var(--color-glass-strong);
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
	outline: none;
	border-color: var(--color-primary);
	box-shadow: 0 0 0 3px var(--color-glow);
}

input::placeholder, textarea::placeholder {
	color: var(--color-muted-foreground);
}

button:focus-visible, a:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
	border-radius: 0.5rem;
}

/* Override browser autofill in dark mode */
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus,
[data-theme="dark"] select:-webkit-autofill {
	-webkit-box-shadow: 0 0 0 1000px #0d0e1c inset !important;
	-webkit-text-fill-color: #f3f1ff !important;
	caret-color: #f3f1ff;
}

[data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-rule-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-muted-foreground); }

/* === Glass surface utility — used by cards, panels, sidebar === */
.glass {
	background: var(--color-glass);
	backdrop-filter: blur(28px) saturate(160%);
	-webkit-backdrop-filter: blur(28px) saturate(160%);
	border: 1px solid var(--color-border);
	border-radius: 22px;
	box-shadow: var(--shadow-card);
	position: relative;
}
.glass::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: inherit;
	pointer-events: none;
	background: linear-gradient(180deg, var(--color-highlight), transparent 30%);
	opacity: 0.4;
}
.glass-strong {
	background: var(--color-glass-strong);
}
.glass-elev {
	background: var(--color-glass-elev);
}

/* Selection */
::selection { background: var(--color-primary); color: var(--color-primary-foreground); }

/* === Animations === */
@keyframes fadeSlideIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

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

@keyframes pulseGlow {
	0%, 100% { box-shadow: 0 0 4px var(--color-glow); }
	50% { box-shadow: 0 0 16px var(--color-glow-strong); }
}

@keyframes countUp {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes aurora-rise {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes aurora-pulse-glow-mint {
	0%, 100% {
		box-shadow:
			0 0 4px color-mix(in srgb, var(--color-mint) 60%, transparent),
			0 0 0 0 color-mix(in srgb, var(--color-mint) 0%, transparent);
	}
	50% {
		box-shadow:
			0 0 10px color-mix(in srgb, var(--color-mint) 80%, transparent),
			0 0 0 4px color-mix(in srgb, var(--color-mint) 25%, transparent);
	}
}
@keyframes aurora-pulse-glow-citrus {
	0%, 100% {
		box-shadow:
			0 0 4px color-mix(in srgb, var(--color-citrus) 60%, transparent),
			0 0 0 0 color-mix(in srgb, var(--color-citrus) 0%, transparent);
	}
	50% {
		box-shadow:
			0 0 10px color-mix(in srgb, var(--color-citrus) 80%, transparent),
			0 0 0 4px color-mix(in srgb, var(--color-citrus) 25%, transparent);
	}
}
@keyframes aurora-pulse-glow-coral {
	0%, 100% {
		box-shadow:
			0 0 4px color-mix(in srgb, var(--color-coral) 60%, transparent),
			0 0 0 0 color-mix(in srgb, var(--color-coral) 0%, transparent);
	}
	50% {
		box-shadow:
			0 0 10px color-mix(in srgb, var(--color-coral) 80%, transparent),
			0 0 0 4px color-mix(in srgb, var(--color-coral) 25%, transparent);
	}
}

.animate-fade-slide-in {
	animation: fadeSlideIn 0.4s ease-out forwards;
}

.animate-shimmer {
	background: linear-gradient(90deg, var(--color-muted) 25%, var(--color-border) 50%, var(--color-muted) 75%);
	background-size: 200% 100%;
	animation: shimmer 1.5s ease-in-out infinite;
}

.animate-pulse-glow {
	animation: pulseGlow 2s ease-in-out infinite;
}

.animate-count-up {
	animation: countUp 0.5s ease-out both;
}

.animate-rise {
	animation: aurora-rise 0.6s cubic-bezier(.2,.7,.2,1) both;
}

/* Stagger children utility */
.stagger-children > * {
	animation: aurora-rise 0.55s cubic-bezier(.2,.7,.2,1) both;
}

/* === List stack — used by list pages (providers, trackers, configs, etc.) ===
   Full-bleed rows that stretch to the main column width. Pair with .list-row
   inside each Card for the 3-zone layout (identity · meta-strip · actions). */
.list-stack {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.list-row {
	display: flex;
	align-items: center;
	gap: 1rem;
	min-width: 0;
}
.list-row__identity {
	min-width: 0;
	flex: 0 0 auto;
	max-width: 28rem;
}
@media (max-width: 1023px) {
	.list-row__identity { flex: 1 1 auto; }
}
.list-row__actions {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
}

/* Secondary text under the name — visible only when meta-strip is hidden
   (i.e. on narrow screens). On lg+ the meta-strip takes over. */
.list-row__secondary {
	display: block;
}
@media (min-width: 1024px) {
	.list-row__secondary { display: none; }
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

.font-mono {
	font-family: var(--font-mono);
}

.font-display {
	font-family: var(--font-display);
}

/* Card highlight for cross-entity navigation */
@keyframes cardHighlight {
	0%, 100% { box-shadow: none; }
	25%, 75% { box-shadow: 0 0 0 3px var(--color-primary), 0 0 20px var(--color-glow-strong); }
}

/* Dim overlay behind highlighted card */
.nav-dim-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	z-index: 10;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease-in-out;
}

.nav-dim-overlay.active {
	opacity: 1;
}

/* Live pulse dot — for "live" / armed indicators.
   Pulse is a self-contained box-shadow glow on the dot. No transform,
   no pseudo-element — the dot's own bounding box never changes, so
   ancestors with overflow:hidden can only clip the (decorative) glow,
   never the dot itself. */
.aurora-pulse {
	width: 8px; height: 8px;
	border-radius: 50%;
	background: var(--color-mint);
	display: inline-block;
	flex-shrink: 0;
	animation: aurora-pulse-glow-mint 1.6s ease-in-out infinite;
}
.aurora-pulse.warn {
	background: var(--color-citrus);
	animation-name: aurora-pulse-glow-citrus;
}
.aurora-pulse.error {
	background: var(--color-coral);
	animation-name: aurora-pulse-glow-coral;
}
.aurora-pulse.idle {
	background: var(--color-muted-foreground);
	box-shadow: none;
	opacity: 0.5;
	animation: none;
}

/* === Reduced-motion: kill drift, pulses, shimmers, stagger entrances === */
@media (prefers-reduced-motion: reduce) {
	body::before { animation: none !important; }
	.animate-fade-slide-in,
	.animate-shimmer,
	.animate-pulse-glow,
	.animate-count-up,
	.animate-rise,
	.stagger-children > *,
	.aurora-pulse,
	.aurora-pulse.warn,
	.aurora-pulse.error {
		animation: none !important;
	}
	.stat-card,
	.paginator-btn,
	.signal-row,
	.provider-row {
		transition: none !important;
	}
	* {
		scroll-behavior: auto !important;
	}
}

/* Shared toggle switch — used by provider config forms, tracking-config
   extraTrackingFields, and anywhere else we render a boolean field.
   Kept global so adding a new ConfigField type='toggle' caller doesn't
   need to copy the CSS into its scoped <style>. */
.toggle-switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	height: 1.75rem;
}

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

.toggle-switch .toggle-track {
	position: relative;
	width: 2.5rem;
	height: 1.375rem;
	background: var(--color-border);
	border-radius: 9999px;
	transition: background 0.2s ease;
}

.toggle-switch .toggle-track::after {
	content: '';
	position: absolute;
	top: 0.1875rem;
	left: 0.1875rem;
	width: 1rem;
	height: 1rem;
	background: var(--color-foreground);
	border-radius: 50%;
	transition: transform 0.2s ease;
}

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

.toggle-switch input:checked + .toggle-track::after {
	transform: translateX(1.125rem);
	background: var(--color-primary-foreground);
}
