/*
 * Docly design tokens — single source of truth.
 * Loaded FIRST by every page and intentionally outside any @layer, so these
 * values win over the legacy layered stylesheets. Components only consume
 * var(--ui-*) (or the legacy aliases at the end of :root).
 * Runtime overrides: the per-company accent is written inline on <html>
 * (--ui-brand, --ui-brand-hover, --ui-brand-contrast); the theme comes from
 * html[data-theme="light|dark|system"].
 */
@font-face {
  font-family: Inter;
  src: url("../../fonts/Inter.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  /* Typography: Inter is the only UI font. Document previews keep their own. */
  --ui-font: Inter, "Segoe UI", system-ui, sans-serif;
  --ui-font-mono: Consolas, "SFMono-Regular", monospace;
  --ui-text-xs: 11px; /* hard minimum: badges, captions */
  --ui-text-small: 12px; /* helper and muted text */
  --ui-text-body: 13px;
  --ui-text: 14px;
  --ui-text-large: 16px;
  --ui-section-heading: 17px;
  --ui-heading: 28px;
  --ui-weight-regular: 400;
  --ui-weight-medium: 500;
  --ui-weight-strong: 600;
  --ui-weight-bold: 700;

  /* Brand (per-company accent overrides these inline on <html>). */
  --ui-brand: #3b5bdb;
  --ui-brand-hover: #304ec4;
  --ui-brand-contrast: #fff;
  --ui-on-brand: var(--ui-brand-contrast);
  --ui-brand-text: var(--ui-brand);
  --ui-brand-soft: color-mix(in srgb, var(--ui-brand) 10%, var(--ui-surface));
  --ui-brand-softer: color-mix(in srgb, var(--ui-brand) 5%, var(--ui-surface));
  --ui-brand-line: color-mix(in srgb, var(--ui-brand) 28%, var(--ui-surface));
  --ui-brand-ring: color-mix(in srgb, var(--ui-brand) 22%, transparent);

  /* Neutral surfaces and text. */
  --ui-surface: #fff;
  --ui-surface-raised: #fff;
  --ui-canvas: #f3f5fe;
  --ui-soft: #f6f8fc;
  --ui-hover: #edf0fd;
  --ui-selected: var(--ui-brand-soft);
  --ui-line: #dfe5f7;
  --ui-line-strong: #c3cddf;
  --ui-ink: #243b5a;
  --ui-ink-strong: #152b46;
  --ui-muted: #566780; /* 5.3:1 on canvas, 5.8:1 on surface (AA) */
  --ui-subtle: #8292a4; /* icons/decoration only, never body text */
  --ui-focus: #4c6ef5;
  --ui-overlay: rgb(13 18 48 / 45%);
  --ui-sidebar: var(--ui-surface);
  --ui-input: var(--ui-surface);

  /* Status. */
  --ui-success: #286343;
  --ui-success-bg: #e7f3ec;
  --ui-success-strong: #15803d;
  --ui-danger: #a32e40;
  --ui-danger-bg: #fce9ea;
  --ui-danger-line: #efc6c6;
  --ui-warning: #805911;
  --ui-warning-bg: #fff3dc;
  --ui-info: #345b94;
  --ui-info-bg: #eaf1fc;
  --ui-neutral: #52637d;
  --ui-neutral-bg: #eef1f6;

  /* Chart palette (canonical: Docly clásico). Defined only here. */
  --ui-chart-contrato: #4c6ef5;
  --ui-chart-anexo: #12b886;
  --ui-chart-termino_relacion: #ff922b;
  --ui-chart-mutuo_acuerdo: #9775fa;
  --ui-chart-faltas: #dfb042;
  --ui-chart-other: #65809e;

  /* Spacing, sizing, radius. */
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-control-height: 36px;
  --ui-control-compact: 30px;
  --ui-row-compact: 44px;
  --ui-row-normal: 52px;
  --ui-radius-small: 4px;
  --ui-radius-control: 6px;
  --ui-radius-panel: 8px;
  --ui-radius-card: 12px;
  --ui-radius-dialog: 12px;
  --ui-radius-pill: 999px;

  /* Elevation. */
  --ui-shadow-color: 15 23 42;
  --ui-shadow-sm: 0 1px 2px rgb(var(--ui-shadow-color) / 6%);
  --ui-shadow-md: 0 8px 24px rgb(var(--ui-shadow-color) / 8%);
  --ui-shadow-lg: 0 24px 60px rgb(var(--ui-shadow-color) / 18%);

  /* Legacy aliases kept for older stylesheets (do not add new uses). */
  --space-background: var(--ui-canvas);
  --space-line: var(--ui-line);
  --space-brand: var(--ui-brand);
  --space-muted: var(--ui-muted);
  --space-ink: var(--ui-ink);
  --canvas: var(--ui-canvas);
  --surface: var(--ui-surface);
  --line: var(--ui-line);
  --ink: var(--ui-ink);
  --muted: var(--ui-muted);
  --brand: var(--ui-brand);
}

/* Alternative (non-classic) composition of the space edition. */
html[data-edition="space"]:not([data-design="docly-classic"]) {
  --ui-brand: #344b76;
  --ui-brand-hover: #273e62;
  --ui-canvas: #f9f9fb;
}

/* Dark theme: explicit preference. */
html[data-theme="dark"] {
  color-scheme: dark;
  --ui-brand-text: color-mix(in srgb, var(--ui-brand) 55%, #fff);
  --ui-brand-soft: color-mix(in srgb, var(--ui-brand) 24%, var(--ui-surface));
  --ui-brand-softer: color-mix(in srgb, var(--ui-brand) 12%, var(--ui-surface));
  --ui-brand-line: color-mix(in srgb, var(--ui-brand) 45%, var(--ui-surface));
  --ui-brand-ring: color-mix(in srgb, var(--ui-brand) 40%, transparent);
  --ui-surface: #172033;
  --ui-surface-raised: #1d283d;
  --ui-canvas: #0f1626;
  --ui-soft: #1b2538;
  --ui-hover: #222e45;
  --ui-line: #2c3a54;
  --ui-line-strong: #3d4d6b;
  --ui-ink: #e3e9f4;
  --ui-ink-strong: #f4f7fc;
  --ui-muted: #a3b1c7;
  --ui-subtle: #7d8ca5;
  --ui-focus: #8ea9ff;
  --ui-overlay: rgb(0 0 0 / 60%);
  --ui-input: #131b2c;
  --ui-success: #6fd19a;
  --ui-success-bg: #16352a;
  --ui-success-strong: #6fd19a;
  --ui-danger: #ff8f9c;
  --ui-danger-bg: #3d1d24;
  --ui-danger-line: #6b2f39;
  --ui-warning: #f2c46b;
  --ui-warning-bg: #3a2e14;
  --ui-info: #8db4f5;
  --ui-info-bg: #1a2a45;
  --ui-neutral: #b0bccd;
  --ui-neutral-bg: #243046;
  --ui-shadow-color: 0 0 0;
  --ui-shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --ui-shadow-md: 0 8px 24px rgb(0 0 0 / 35%);
  --ui-shadow-lg: 0 24px 60px rgb(0 0 0 / 50%);
}

/* Dark theme: follow the operating system. Same values as above. */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --ui-brand-text: color-mix(in srgb, var(--ui-brand) 55%, #fff);
    --ui-brand-soft: color-mix(in srgb, var(--ui-brand) 24%, var(--ui-surface));
    --ui-brand-softer: color-mix(in srgb, var(--ui-brand) 12%, var(--ui-surface));
    --ui-brand-line: color-mix(in srgb, var(--ui-brand) 45%, var(--ui-surface));
    --ui-brand-ring: color-mix(in srgb, var(--ui-brand) 40%, transparent);
    --ui-surface: #172033;
    --ui-surface-raised: #1d283d;
    --ui-canvas: #0f1626;
    --ui-soft: #1b2538;
    --ui-hover: #222e45;
    --ui-line: #2c3a54;
    --ui-line-strong: #3d4d6b;
    --ui-ink: #e3e9f4;
    --ui-ink-strong: #f4f7fc;
    --ui-muted: #a3b1c7;
    --ui-subtle: #7d8ca5;
    --ui-focus: #8ea9ff;
    --ui-overlay: rgb(0 0 0 / 60%);
    --ui-input: #131b2c;
    --ui-success: #6fd19a;
    --ui-success-bg: #16352a;
    --ui-success-strong: #6fd19a;
    --ui-danger: #ff8f9c;
    --ui-danger-bg: #3d1d24;
    --ui-danger-line: #6b2f39;
    --ui-warning: #f2c46b;
    --ui-warning-bg: #3a2e14;
    --ui-info: #8db4f5;
    --ui-info-bg: #1a2a45;
    --ui-neutral: #b0bccd;
    --ui-neutral-bg: #243046;
    --ui-shadow-color: 0 0 0;
    --ui-shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --ui-shadow-md: 0 8px 24px rgb(0 0 0 / 35%);
    --ui-shadow-lg: 0 24px 60px rgb(0 0 0 / 50%);
  }
}

html {
  background: var(--ui-canvas);
}
body {
  font-family: var(--ui-font);
}
