/**
 * Mozaik - Core Design Tokens
 * Kontrol design system: values compiled from the system's tokens.json, named after Mozaik (--m-*).
 * Light is the default theme. Dark applies with data-theme="dark" on <html> (Mozaik's ThemeService)
 * or the .dark class on <html>.
 */

/* ============================================
   LIGHT THEME (default)
   ============================================ */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* Colour */
  --m-primary: #1f6b45;
  --m-primary-hover: #195a3a;
  --m-primary-active: #144a30;
  --m-primary-light: #ddf1e4;
  --m-primary-dark: #0f3b25;
  --m-primary-strong: #1f6b45;
  --m-on-primary: #ffffff;
  --m-on-fill: #ffffff;
  --m-on-fill-muted: rgba(255, 255, 255, 0.8);
  --m-secondary: #3e9d67;
  --m-table-row-selected-bg: var(--m-primary-light);
  --m-table-row-selected-hover-bg: #cbe9d6;
  --m-success: #1e7f4b;
  --m-success-hover: #186b3f;
  --m-success-light: #dcf2e4;
  --m-success-text: #145a35;
  --m-danger: #cc3b33;
  --m-danger-hover: #b0302a;
  --m-danger-light: #fbe5e2;
  --m-danger-text: #9e2a23;
  --m-warning: #c27a12;
  --m-warning-hover: #a86808;
  --m-warning-light: #fcefd9;
  --m-warning-text: #8a5206;
  --m-info: #2d6cc8;
  --m-info-hover: #2459a8;
  --m-info-light: #e2ecfa;
  --m-info-text: #1f4e92;
  --m-text-primary: #121a16;
  --m-text-secondary: #4b544f;
  --m-text-muted: #636d67;
  --m-text-disabled: #a9b0ab;
  --m-bg-primary: #ffffff;
  --m-bg-secondary: #f4f5f3;
  --m-bg-tertiary: #e8ebe7;
  --m-bg-hover: #ebefea;
  --m-border: #e3e7e3;
  --m-border-hover: #cfd5d0;
  --m-border-strong: #838d87;
  --m-border-focus: var(--m-primary);
  --m-chart-1: #0f3b25;
  --m-chart-2: var(--m-primary);
  --m-chart-3: var(--m-secondary);
  --m-hatch: #bcc5bf;
  --m-overlay: rgba(13, 20, 16, 0.48);

  /* Shadow: surfaces are flat, shadows mark things that float */
  --m-shadow-xs: 0 1px 2px rgba(18, 26, 22, 0.05);
  --m-shadow-sm: 0 1px 3px rgba(18, 26, 22, 0.06), 0 1px 2px rgba(18, 26, 22, 0.04);
  --m-shadow-md: 0 6px 16px rgba(18, 26, 22, 0.07);
  --m-shadow-lg: 0 16px 40px rgba(18, 26, 22, 0.12);
  --m-shadow-xl: 0 28px 72px rgba(18, 26, 22, 0.2);
  --m-shadow-focus: 0 0 0 2px #ffffff, 0 0 0 4px #1f6b45;
  --m-shadow-focus-danger: 0 0 0 2px #ffffff, 0 0 0 4px #cc3b33;
  --m-shadow-focus-success: 0 0 0 2px #ffffff, 0 0 0 4px #1e7f4b;

  /* Type */
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Courier New", Courier, monospace;

  /* Font size */
  --m-font-size-2xs: 0.6875rem;
  --m-font-size-xs: 0.75rem;
  --m-font-size-sm: 0.875rem;
  --m-font-size-md: 1rem;
  --m-font-size-lg: 1.125rem;
  --m-font-size-xl: 1.25rem;
  --m-font-size-2xl: 1.5rem;
  --m-font-size-3xl: 2rem;
  --m-font-size-4xl: 3rem;

  /* Font weight */
  --m-font-weight-normal: 400;
  --m-font-weight-medium: 500;
  --m-font-weight-semibold: 600;
  --m-font-weight-bold: 700;

  /* Line height */
  --m-line-height-tight: 1.25;
  --m-line-height-normal: 1.5;
  --m-line-height-relaxed: 1.75;

  /* Spacing (4px scale) */
  --m-spacing-0: 0;
  --m-spacing-1: 0.25rem;
  --m-spacing-2: 0.5rem;
  --m-spacing-3: 0.75rem;
  --m-spacing-4: 1rem;
  --m-spacing-5: 1.25rem;
  --m-spacing-6: 1.5rem;
  --m-spacing-8: 2rem;
  --m-spacing-10: 2.5rem;
  --m-spacing-12: 3rem;
  --m-spacing-16: 4rem;

  /* Radius */
  --m-radius-none: 0;
  --m-radius-sm: 6px;
  --m-radius-md: 12px;
  --m-radius-lg: 16px;
  --m-radius-xl: 20px;
  --m-radius-2xl: 28px;
  --m-radius-full: 9999px;

  /* Size */
  --m-control-sm: 32px;
  --m-control-md: 40px;
  --m-control-lg: 48px;
  --m-icon-xs: 12px;
  --m-icon-sm: 16px;
  --m-icon-md: 20px;
  --m-icon-lg: 24px;
  --m-icon-xl: 32px;
  --m-icon-2xl: 48px;
  --m-avatar-sm: 32px;
  --m-avatar-md: 40px;
  --m-avatar-lg: 56px;
  --m-avatar-xl: 80px;
  --m-sidebar-width: 280px;
  --m-sidebar-collapsed: 72px;
  --m-topbar-height: 64px;

  /* Opacity */
  --m-opacity-disabled: 0.5;

  /* Z-index */
  --m-z-base: 0;
  --m-z-dropdown: 1000;
  --m-z-sticky: 1020;
  --m-z-fixed: 1030;
  --m-z-modal-backdrop: 1040;
  --m-z-modal: 1050;
  --m-z-popover: 1060;
  --m-z-tooltip: 1070;
  --m-z-toast: 1080;

  /* Breakpoints (reference only: media queries repeat the number) */
  --m-breakpoint-sm: 640px;
  --m-breakpoint-md: 768px;
  --m-breakpoint-lg: 1024px;
  --m-breakpoint-xl: 1280px;
  --m-breakpoint-2xl: 1536px;

  /* Motion: not a token family, so it lives here */
  --m-transition-fast: 0.12s ease;
  --m-transition-base: 0.2s ease;
  --m-transition-slow: 0.3s ease;
  --m-transition-slower: 0.5s ease;
}

/* ============================================
   DARK THEME
   ============================================ */
[data-theme="dark"],
:root.dark {
  color-scheme: dark;

  /* Colour */
  --m-primary: #5bc98a;
  --m-primary-hover: #74d49d;
  --m-primary-active: #8eddb0;
  --m-primary-light: #1c3a2a;
  --m-primary-dark: #133524;
  --m-primary-strong: #1f6b45;
  --m-on-primary: #08190f;
  --m-on-fill: #ffffff;
  --m-on-fill-muted: rgba(255, 255, 255, 0.8);
  --m-secondary: #2f8a57;
  --m-table-row-selected-bg: var(--m-primary-light);
  --m-table-row-selected-hover-bg: #24493a;
  --m-success: #22804c;
  --m-success-hover: #1b6e40;
  --m-success-light: #15301f;
  --m-success-text: #7fd9a5;
  --m-danger: #c8423a;
  --m-danger-hover: #b3362f;
  --m-danger-light: #3a1a17;
  --m-danger-text: #f49a92;
  --m-warning: #c27a12;
  --m-warning-hover: #d88c1e;
  --m-warning-light: #3a2a10;
  --m-warning-text: #f2c27a;
  --m-info: #3570cc;
  --m-info-hover: #2c62b8;
  --m-info-light: #172a45;
  --m-info-text: #9dc0f5;
  --m-text-primary: #eef2ef;
  --m-text-secondary: #a9b4ad;
  --m-text-muted: #8d9891;
  --m-text-disabled: #56605a;
  --m-bg-primary: #171d1a;
  --m-bg-secondary: #0f1412;
  --m-bg-tertiary: #222a26;
  --m-bg-hover: #252f2a;
  --m-border: #29322d;
  --m-border-hover: #38433d;
  --m-border-strong: #6f7a74;
  --m-border-focus: var(--m-primary);
  --m-chart-1: #c6f1d8;
  --m-chart-2: var(--m-primary);
  --m-chart-3: var(--m-secondary);
  --m-hatch: #3b4741;
  --m-overlay: rgba(0, 0, 0, 0.62);

  /* Shadow */
  --m-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --m-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --m-shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --m-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --m-shadow-xl: 0 28px 72px rgba(0, 0, 0, 0.6);
  --m-shadow-focus: 0 0 0 2px #171d1a, 0 0 0 4px #5bc98a;
  --m-shadow-focus-danger: 0 0 0 2px #171d1a, 0 0 0 4px #e0675e;
  --m-shadow-focus-success: 0 0 0 2px #171d1a, 0 0 0 4px #4cc17e;
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  :root {
    --m-transition-fast: 0s;
    --m-transition-base: 0s;
    --m-transition-slow: 0s;
    --m-transition-slower: 0s;
  }
}

/* ============================================
   BASE STYLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--m-font-size-sm);
  line-height: var(--m-line-height-normal);
  color: var(--m-text-primary);
  background-color: var(--m-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--m-primary-light);
  color: var(--m-text-primary);
}

/* The hatch: diagonal stripes for remaining or pending capacity (charts, progress, empty states). */
.m-hatch {
  background-image: repeating-linear-gradient(135deg, var(--m-hatch) 0 2px, transparent 2px 8px);
}
