/*
 * Panopticar design tokens — the single source of truth for the visual system
 * (docs/ui-style-guide.md). EVERYTHING downstream reads these CSS custom
 * properties, so a redesign (or a new brand theme beyond Andel) is a matter of
 * editing values here. This is what makes the UI editable from Claude Design.
 *
 * Load order: global.css (this file: tokens + base) → custom.css (components +
 * Andel theme) → responsive.css (breakpoints). Bootstrap 5 + Bootstrap Icons +
 * Inter are loaded from the CDN before these (see src/app.html).
 */

:root {
	/* --- Brand & interactive accent --- */
	--color-accent: #0059f7; /* links, tags, active accents, progress */
	--color-accent-hover: #1f6cc4;
	--color-dark: #000000; /* primary / dark button fill (default theme) */
	--color-dark-hover: #333333;
	--color-dark-active: #222222;

	/* --- Neutrals --- */
	--color-bg: #f7f7f8; /* app canvas — near-white, the content floats on it */
	--color-surface: #ffffff; /* cards, modals, drawers */
	--color-surface-2: #f8f9fb; /* subheads, hovers, modal footer */
	--color-text: #10192e;
	--color-heading: #1c2740;
	--color-muted: #5b6472;
	--color-placeholder: #6b7280;
	--color-border: #e5e7eb;
	--color-border-2: #eef0f3;
	--color-field-border: #dfe2e8;
	--color-focus: #0f172a;
	--color-focus-glow: rgba(15, 23, 42, 0.08);

	/* --- Semantic (status palette — one edit here recolours badges, KPI tones,
	   deltas, dots and traffic lights app-wide). Green now reads GREEN (the old
	   teal #1bc5bd read as "info"); each colour ships solid + soft + ink. --- */
	--color-success: #12b76a;
	--color-success-soft: #e6f6ee;
	--color-warning: #f79009;
	--color-warning-soft: #fdf1df;
	--color-danger: #ef4444;
	--color-danger-soft: #fdebeb;
	--color-info: #2e90fa;
	--color-info-soft: #e8f2fe;
	/* "Ink" = the accessible on-light text tone of each semantic colour. Use
	   these for coloured numbers/labels on white (badges, KPI values); the base
	   tokens above are too light to read as text. */
	/* AA sobre blanco y sobre el lienzo (≥4,5:1; el anterior #0e8a54 se quedaba en 4,4). */
	--color-success-ink: #0b6b45;
	--color-warning-ink: #a15c07;
	--color-danger-ink: #b42318;
	--color-info-ink: #175cd3;
	--color-violet: #7c5cfc;
	--color-violet-soft: #efeafe;
	--color-violet-ink: #5b3df0;

	/* Semantic aliases — "primary" is the interactive accent (blue, or Andel
	   orange under body.andel); "muted-2" is a lighter caption grey. Consolidated
	   here so the many components that referenced them stop silently falling back
	   to their own hard-coded values (docs/ui-style-guide.md §2). */
	--color-primary: var(--color-accent);
	--color-primary-soft: #e6eeff;
	/* Gris de pie de foto: a 3,1:1 no se leía (notas de octubre de 2026); #656d7c da 5,2:1 sobre
	   blanco y 4,9:1 sobre el lienzo, y sigue siendo más claro que --color-muted. */
	--color-muted-2: #656d7c;

	/* --- Typography --- */
	--font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
	--font-mono: 'SFMono-Regular', ui-monospace, 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
	--fw-light: 300;
	--fw-normal: 400;
	--fw-bold: 500;
	--fw-bolder: 600;
	--fw-boldest: 700;
	--fw-heavy: 800;
	/* Type scale — every component reads these instead of ad-hoc rem values, so
	   the whole app's typography moves together (docs/ui-style-guide.md §3). */
	--text-xs: 0.72rem; /* uppercase labels, table headers, captions-in-chrome */
	--text-sm: 0.8rem; /* metas, hints, secondary cells */
	--text-base: 0.9rem; /* body, table cells, buttons, inputs */
	--text-md: 1rem; /* card titles, emphasised body */
	--text-lg: 1.125rem; /* modal titles, hero stats */
	--text-title: 2.3rem; /* page title (std-page-header) */

	/* --- Shape --- */
	--radius-card: 16px;
	--radius-modal: 18px;
	--radius-input: 10px;
	--radius-symbol: 0.7rem;
	--radius-pill: 999px;
	--radius-btn: var(--radius-pill); /* buttons are pills (segmented groups opt out) */
	--radius: var(--radius-input); /* generic default radius (chips, small blocks) */

	/* --- Elevation (layered, soft — one edit here restyles depth app-wide) --- */
	--shadow-rest: 0 1px 2px rgba(16, 25, 46, 0.04), 0 1px 3px rgba(16, 25, 46, 0.05);
	--shadow-card-hover: 0 4px 12px rgba(16, 25, 46, 0.07), 0 12px 28px rgba(16, 25, 46, 0.09);
	--shadow-btn-hover: 0 6px 16px rgba(15, 23, 42, 0.18);
	--shadow-modal: 0 24px 60px rgba(15, 23, 42, 0.22);
	--shadow-drawer: 0 1px 9px -3px rgba(0, 0, 0, 0.25);

	/* --- Focus ring (accessible, brand-tinted — used by :focus-visible) ---
	   3 px macizos con un filo blanco por dentro: se ve sobre blanco, sobre el menú oscuro y sobre
	   un botón de color (al 35 % no llegaba al 3:1 que pide WCAG 2.2 para el foco). */
	--ring: 0 0 0 2px #fff, 0 0 0 5px rgba(0, 89, 247, 0.9);

	/* --- Motion --- */
	--motion-fast: 0.18s ease;
	--motion-base: 0.2s ease;
	--motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

	/* --- Z-index ladder --- */
	--z-header: 1030;
	--z-sidebar: 1040;
	--z-drawer: 1045;
	--z-modal-backdrop: 1075;
	--z-modal: 1080;
	--z-side-panel: 1090;
	--z-snackbar: 2000;

	/* --- Layout --- */
	--sidebar-width: 252px; /* expanded overlay — compact but roomy enough for the longest label */
	--sidebar-rail: 64px; /* collapsed floating rail (icons only; expands over the content on hover) */
	--page-padding: 2rem;
	--tap-target: 40px;

	/* --- Theme-able surfaces (overridden by body.andel in custom.css) --- */
	--aside-bg: #0a0a0c; /* floating rounded rail — near-black */
	--aside-gap: 12px; /* breathing room around the floating rail */
	--active-accent: var(--color-accent);

	/* Bootstrap runtime variables re-pointed at the tokens, so any component
	   style that reads var(--bs-*) (borders, dots, chips) lands on OUR palette. */
	--bs-success: var(--color-success);
	--bs-warning: var(--color-warning);
	--bs-danger: var(--color-danger);
	--bs-info: var(--color-info);
	--bs-body-color: var(--color-text);
	--bs-border-color: var(--color-border);
}

/* --- Base elements --- */
html,
body {
	height: 100%;
}
body {
	margin: 0;
	background: var(--color-bg);
	color: var(--color-text);
	font-family: var(--font-sans);
	font-size: 0.925rem;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
	color: var(--color-heading);
	font-weight: var(--fw-heavy);
}
h4,
h5,
h6 {
	color: var(--color-heading);
	font-weight: var(--fw-boldest);
}

a {
	color: var(--color-accent);
	text-decoration: none;
}
a:hover {
	color: var(--color-accent-hover);
}

/* --- Bootstrap-utility harmonisation ------------------------------------- */
/* The scattered raw utilities (text-muted, text-danger, bg-success dots…) are
   remapped to the tokens, so pages that reach for Bootstrap directly still land
   on the SAME palette as the ds-* components. One system, whatever the class. */
.text-muted {
	color: var(--color-muted) !important;
}
.text-muted-2 {
	color: var(--color-muted-2) !important;
}
/* Las ayudas de los campos y el «secundario» de Bootstrap, al mismo gris legible (5,98:1). */
.form-text,
.text-secondary {
	color: var(--color-muted) !important;
}
.text-success {
	color: var(--color-success-ink) !important;
}
.text-warning {
	color: var(--color-warning-ink) !important;
}
.text-danger {
	color: var(--color-danger-ink) !important;
}
.text-info {
	color: var(--color-info-ink) !important;
}
.bg-success {
	background-color: var(--color-success) !important;
}
.bg-warning {
	background-color: var(--color-warning) !important;
}
.bg-danger {
	background-color: var(--color-danger) !important;
}
.bg-info {
	background-color: var(--color-info) !important;
}
/* Raw Bootstrap status badges land on the ds-badge look (soft bg + ink text). */
.badge.text-bg-success {
	background-color: var(--color-success-soft) !important;
	color: var(--color-success-ink) !important;
}
.badge.text-bg-warning {
	background-color: var(--color-warning-soft) !important;
	color: var(--color-warning-ink) !important;
}
.badge.text-bg-danger {
	background-color: var(--color-danger-soft) !important;
	color: var(--color-danger-ink) !important;
}
.badge.text-bg-info {
	background-color: var(--color-info-soft) !important;
	color: var(--color-info-ink) !important;
}
.badge.text-bg-secondary,
.badge.text-bg-light {
	background-color: var(--color-border-2) !important;
	color: var(--color-muted) !important;
}

/* Consistent, brand-tinted keyboard focus ring across every interactive
   element — one rule so accessibility styling never drifts per page. Mouse
   clicks stay clean (":focus-visible" only fires for keyboard/AT). */
:focus-visible {
	outline: none;
	box-shadow: var(--ring);
}
a:focus-visible,
button:focus-visible,
[role='button']:focus-visible,
.btn:focus-visible,
.aside__link:focus-visible {
	outline: none;
	box-shadow: var(--ring);
}
body.andel {
	--ring: 0 0 0 2px #fff, 0 0 0 5px rgba(206, 114, 18, 0.9);
}
