@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";

/* ── BMW Corporate Fonts ──────────────────────────────────────────────────── */

/* BMW Group TN Pro */
@font-face {
  font-family: 'BMW Group TN Pro';
  src: url('/fonts/BMWGroupTNPro-Thin.woff2') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Pro';
  src: url('/fonts/BMWGroupTNPro-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Pro';
  src: url('/fonts/BMWGroupTNPro-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Pro';
  src: url('/fonts/BMWGroupTNPro-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Pro';
  src: url('/fonts/BMWGroupTNPro-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Pro';
  src: url('/fonts/BMWGroupTNPro-Black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* BMW Group TN Condensed Pro */
@font-face {
  font-family: 'BMW Group TN Condensed Pro';
  src: url('/fonts/BMWGroupTNCondensedPro-Thin.woff2') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Condensed Pro';
  src: url('/fonts/BMWGroupTNCondensedPro-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Condensed Pro';
  src: url('/fonts/BMWGroupTNCondensedPro-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Condensed Pro';
  src: url('/fonts/BMWGroupTNCondensedPro-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'BMW Group TN Condensed Pro';
  src: url('/fonts/BMWGroupTNCondensedPro-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@custom-variant dark (&:is(.dark *));

@theme inline {
    --font-heading:   'BMW Group TN Pro', system-ui, -apple-system, sans-serif;
    --font-sans:      'BMW Group TN Pro', system-ui, -apple-system, sans-serif;
    --font-condensed: 'BMW Group TN Condensed Pro', system-ui, -apple-system, sans-serif;
    --font-mono: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
    --color-sidebar-ring: var(--sidebar-ring);
    --color-sidebar-border: var(--sidebar-border);
    --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
    --color-sidebar-accent: var(--sidebar-accent);
    --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
    --color-sidebar-primary: var(--sidebar-primary);
    --color-sidebar-foreground: var(--sidebar-foreground);
    --color-sidebar: var(--sidebar);
    --color-chart-5: var(--chart-5);
    --color-chart-4: var(--chart-4);
    --color-chart-3: var(--chart-3);
    --color-chart-2: var(--chart-2);
    --color-chart-1: var(--chart-1);
    --color-ring: var(--ring);
    --color-input: var(--input);
    --color-border: var(--border);
    --color-destructive: var(--destructive);
    --color-accent-foreground: var(--accent-foreground);
    --color-accent: var(--accent);
    --color-muted-foreground: var(--muted-foreground);
    --color-muted: var(--muted);
    --color-secondary-foreground: var(--secondary-foreground);
    --color-secondary: var(--secondary);
    --color-primary-foreground: var(--primary-foreground);
    --color-primary: var(--primary);
    --color-popover-foreground: var(--popover-foreground);
    --color-popover: var(--popover);
    --color-card-foreground: var(--card-foreground);
    --color-card: var(--card);
    --color-foreground: var(--foreground);
    --color-background: var(--background);
    --color-success: var(--success);
    --color-success-text: var(--success-text);
    --color-warning: var(--warning);
    --color-info: var(--info);
    --color-primary-dark: var(--primary-dark);
    --color-primary-soft: var(--ci-primary-soft);
    --color-status-red-strong: var(--status-red-strong);
    --color-status-red-soft: var(--status-red-soft);
    --color-status-yellow: var(--status-yellow);
    --color-status-grey: var(--status-grey);
    --color-status-green: var(--status-green);
    /* DCT Industrial-Flat: alle Radien auf 2px ausser xl-Stufen subtil hoeher */
    --radius-sm: 2px;
    --radius-md: 2px;
    --radius-lg: 2px;
    --radius-xl: 2px;
    --radius-2xl: 4px;
    --radius-3xl: 6px;
    --radius-4xl: 8px;
}

:root {
    /* ── BMW CI Palette — aligned mit DCT Live-Export 22.05.2026 ──────────────── */
    /* Source: dct.bmwgroup.net/home (Brain 05-Referenzen/bmw-ci-dct-2026-05-22) */
    /* Constitution v1.1 Amendment 22.05.2026: Primary von Blue Coral auf DCT Petrol */
    --ci-primary:       #037493;  /* DCT Petrol — App-Primary               */
    --ci-primary-dark:  #035970;  /* DCT Petrol Hover                       */
    --ci-primary-light: #A8DFFF;  /* DCT Petrol Tint                        */
    --ci-primary-soft:  #E0F2FF;  /* DCT Petrol Soft (Selected-Item-BG)     */
    --ci-danger:        #D93025;  /* Destructive — Kadi-v2-Extension       */
    --ci-warning:       #D48830;  /* Orange Ochre                           */
    --ci-success:       #4CAF6A;  /* Simply Green                           */
    --ci-info:          #037493;  /* Info nutzt Primary-Petrol              */
    --ci-logo-bmw:      #0066B1;  /* RESERVIERT: nur in BMW-Roundel-SVG     */

    /* ── DCT Status-Color-System (Risikomatrix, KPI-Cards) ────────────────── */
    --status-red-strong: #F8BBD0;
    --status-red-soft:   #FCE4EC;
    --status-yellow:     #FFE082;
    --status-grey:       #D7D8DA;
    --status-green:      #C8E6C9;

    /* ── QAF-Vergleich Stand-Farben (V11 STAND_COLORS q0/q1, Spec 3.10 —
       key-stabile Darstellungskonstanten des Referenz-Tools) ─────────────── */
    --qaf-stand-alt: #A2B9C1;
    --qaf-stand-neu: #1f4e5f;

    /* QAF-Vergleich Bucket-Farben (V11 BUCKET_COLORS, key-stabil) */
    --qaf-bucket-material: #3d6f80;
    --qaf-bucket-labor: #8fb4c0;
    --qaf-bucket-manufacturing: #1f4e5f;
    /* FWZ (Vorrichtungen und Folgewerkzeuge) — eigener Block seit KAR-999/F-03.
       Gedecktes Aubergine: gleiche Sättigung wie die übrigen Bucket-Töne, aber
       im Farbkreis weit genug von Petrol (Material/Fertigung), Braun (Scrap)
       und Grün (Profit) entfernt, damit die Blöcke im Stapel unterscheidbar
       bleiben. */
    --qaf-bucket-fwz: #6b5b7b;
    --qaf-bucket-scrap: #a4653a;
    --qaf-bucket-sga: #7a8c9c;
    --qaf-bucket-profit: #3C6A3C;
    --qaf-bucket-other: #c2ccd1;
    /* Loop 11 (Token-Audit-Befund): --status-yellow-soft wurde in der
       Benchmark-Detail-Box referenziert, war aber nie definiert — der
       transparent-Fallback griff immer. Sanfte Stufe analog --status-red-soft. */
    --status-yellow-soft: #FFF8E1;
    /* Loop 11: Waterfall-Richtungs-Töne — vorher nur als lose Fallback-Hex in
       qaf-v2-waterfall.tsx (die Vars existierten nicht, der Fallback griff
       immer). Werte = der bisherige Ist-Zustand, jetzt als dokumentierte
       Konstante; eine FARB-Änderung wäre ein eigener Design-Entscheid. */
    --qaf-bucket-increase: #6b8fa8;
    --qaf-bucket-decrease: #A8DFFF;

    /* ── Wertstrom (VSM) Editor-Farben (Wertstrom P0, KAR-878) — Node-Palette
       + Canvas-Chrome des VSM-Editors (components/wertstrom/vsm-config.ts,
       vsm-editor.tsx). Wie die QAF-Vergleich-Konstanten oben bewusst
       außerhalb der DCT-Palette: die 7 Node-Typ-Farben unterscheiden VSM-
       Elementarten auf dem Canvas (keine Status-/Risiko-Aussage), Werte
       unverändert zu vorher (nur von Hex nach CSS-Var migriert, siehe
       CLAUDE.md "BMW Color System"). NUR im VSM-Editor verwendet, ausschließlich
       über die CSS-Vars (nie als lose Hex in *.tsx). */
    --vsm-node-process: #037493;
    --vsm-node-machine: #6B21A8;
    --vsm-node-inventory: #D97706;
    --vsm-node-transport: #16A34A;
    --vsm-node-customer: #0891B2;
    --vsm-node-supplier: #4B5563;
    --vsm-node-timevalue: #CC0000;
    --vsm-edge: #6B7A8D;
    --vsm-edge-warning: #CC0000;
    --vsm-grid-bg: #F7F9FB;
    --vsm-grid-dot: #CBD5E1;
    --vsm-connect-preview: #037493;

    /* ── SupplierPulse — Light Theme ──────────────────────── */
    --background: #FFFFFF;                         /* DCT App-Canvas Weiss */
    --foreground: #353A41;                         /* DCT Text Primary */
    --card: #FFFFFF;
    --card-foreground: #353A41;
    --popover: #FFFFFF;
    --popover-foreground: #353A41;
    /* Primary: DCT Petrol #037493 (Live-Export, NICHT #0066B1 Logo-Roundel) */
    --primary: #037493;
    --primary-foreground: #FFFFFF;
    --secondary: #E0F2FF;                          /* DCT Petrol-Soft Selected-State */
    --secondary-foreground: #035970;
    --muted: #EFEFEF;                               /* DCT Disabled-BG */
    --muted-foreground: #69707A;                   /* DCT Text Muted */
    --accent: #E0F2FF;
    --accent-foreground: #035970;
    /* Destructive: Kadi-v2-Extension (DCT hatte kein klares Error-Color im Sample) */
    --destructive: #D93025;
    --border: #C1C5CB;                             /* DCT Border Subtle */
    --input: #C1C5CB;                              /* DCT Input Border */
    --ring: #037493;
    /* Chart colors — auf DCT Status-Palette gemapped */
    --chart-1: #4CAF6A;                            /* green */
    --chart-2: #037493;                            /* petrol (Primary) */
    --chart-3: #FFE082;                            /* amber */
    --chart-4: #F8BBD0;                            /* red-strong */
    --chart-5: #69707A;                            /* grey */
    --radius: 2px;                                 /* DCT Industrial-Flat */
    /* Success: Simply Green #4CAF6A */
    --success: #4CAF6A;
    /* Success-Text: dunkler für AA-Kontrast auf hellem Grund (vgl. kpi-card) */
    --success-text: #1E7C3A;
    /* Warning: Orange Ochre #D48830 */
    --warning: #D48830;
    /* Info: nutzt Primary-Petrol */
    --info: #037493;
    /* Primary Dark: Petrol-Hover */
    --primary-dark: #035970;
    /* Sidebar: DCT-Style helle Sidebar (war OKLCH-dark — komplett-Wechsel) */
    --sidebar: #FFFFFF;
    --sidebar-foreground: #353A41;
    --sidebar-primary: #037493;
    --sidebar-primary-foreground: #FFFFFF;
    --sidebar-accent: #E0F2FF;                     /* Selected-Item-BG */
    --sidebar-accent-foreground: #037493;
    --sidebar-border: #DCDEE1;                     /* Border-Faint */
    --sidebar-ring: #037493;
}

.dark {
    /* Dark-Mode (KAR-521 Dark-Mode-Audit 22.05.2026):
       Primary auf Petrol-Light, Status-Color-System saturatedere Variants fuer
       Lesbarkeit auf dunklem BG. DCT liefert nur Light, Dark ist Kadi-v2-Erweiterung. */

    /* CI-Palette Dark-Variants */
    --ci-primary:       #4DAFC9;
    --ci-primary-dark:  #2E8AA0;
    --ci-primary-light: #2F5466;
    --ci-primary-soft:  oklch(0.24 0.05 220);
    --ci-danger:        #E8616D;
    --ci-warning:       #E8A84E;
    --ci-success:       #7DD4A0;
    --ci-info:          #4DAFC9;
    --ci-logo-bmw:      #0066B1;

    /* DCT Status-Color-System Dark-Variants */
    --status-red-strong: #E27895;
    --status-red-soft:   #3A1B23;
    --status-yellow:     #FFD54F;
    --status-grey:       #525559;
    --status-green:      #7DD4A0;

    /* QAF-Vergleich Stand-Farben Dark-Variants (NEU aufgehellt für Kontrast
       auf dunklem Card-BG, analog zur Status-Palette) */
    --qaf-stand-alt: #A2B9C1;
    --qaf-stand-neu: #7DB4CA;

    /* QAF-Vergleich Bucket-Farben Dark-Variants (dunkle Töne aufgehellt) */
    --qaf-bucket-material: #6FA3B5;
    --qaf-bucket-labor: #B9DCE8; /* heller als SGA-Dark (#9FB1C0), sonst konvergieren sie */
    --qaf-bucket-manufacturing: #7DB4CA;
    --qaf-bucket-fwz: #A895BC; /* dieselbe Aufhellung wie die übrigen Dark-Varianten */
    --qaf-bucket-scrap: #C98F5F;
    --qaf-bucket-sga: #9FB1C0;
    --qaf-bucket-profit: #7DD4A0;
    --qaf-bucket-other: #8B959B;
    /* Waterfall-Richtungs-Töne Dark (Loop 11 — aufgehellt analog oben) */
    --qaf-bucket-increase: #8FAFC4;
    --qaf-bucket-decrease: #C4E9FF;
    /* Sanfte Gelb-Stufe Dark (gedämpft statt aufgehellt — Flächen-Ton) */
    --status-yellow-soft: #4A3F1F;

    /* Wertstrom (VSM) Editor-Farben Dark-Variants — dieselbe Aufhellung wie
       die QAF-Bucket-Farben oben (dunkle Töne aufgehellt für Kontrast auf
       dunklem Card-BG); Grid-BG/-Dot gedreht (helles Grid -> dunkles Grid). */
    --vsm-node-process: #4DAFC9;
    --vsm-node-machine: #B57EDC;
    --vsm-node-inventory: #E8A23D;
    --vsm-node-transport: #4ADE80;
    --vsm-node-customer: #22D3EE;
    --vsm-node-supplier: #9AA4B2;
    --vsm-node-timevalue: #E8616D;
    --vsm-edge: #93A0AF;
    --vsm-edge-warning: #E8616D;
    --vsm-grid-bg: #10151C;
    --vsm-grid-dot: #33404D;
    --vsm-connect-preview: #4DAFC9;

    --background: oklch(0.145 0.02 260);
    --foreground: #e8e8e8;
    --card: oklch(0.185 0.02 260);
    --card-foreground: #e8e8e8;
    --popover: oklch(0.185 0.02 260);
    --popover-foreground: #e8e8e8;
    /* Primary: Petrol-Light fuer Dark-BG */
    --primary: #4DAFC9;
    --primary-foreground: oklch(0.145 0.02 260);
    --secondary: oklch(0.24 0.03 260);
    --secondary-foreground: oklch(0.97 0 0);
    --muted: oklch(0.24 0.03 260);
    --muted-foreground: #a0a0a0;
    --accent: oklch(0.24 0.03 260);
    --accent-foreground: #e8e8e8;
    --destructive: #E8616D;
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 15%);
    --ring: #4DAFC9;
    --chart-1: #4CAF6A;
    --chart-2: #4DAFC9;
    --chart-3: #FFE082;
    --chart-4: #F8BBD0;
    --chart-5: oklch(0.50 0 0);
    --success: #7DD4A0;
    /* Success-Text: hell genug für Kontrast auf dunklem Grund */
    --success-text: #7DD4A0;
    --warning: #E8A84E;
    --info: #4DAFC9;
    --primary-dark: #2E8AA0;
    --sidebar: oklch(0.145 0.02 260);
    --sidebar-foreground: oklch(0.97 0 0);
    --sidebar-primary: #4DAFC9;
    --sidebar-primary-foreground: oklch(0.145 0.02 260);
    --sidebar-accent: oklch(0.24 0.03 260);
    --sidebar-accent-foreground: oklch(0.97 0 0);
    --sidebar-border: oklch(1 0 0 / 10%);
    --sidebar-ring: #4DAFC9;
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
    font-family: 'BMW Group TN Pro', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 22px;
    font-weight: 400;
  }
  input::placeholder,
  textarea::placeholder {
    color: var(--muted-foreground);
    opacity: 0.6;
  }
}

/* ── Condensed utility ────────────────────────────────────────────────────── */
.font-condensed {
  font-family: 'BMW Group TN Condensed Pro', system-ui, -apple-system, sans-serif;
}

/* Loop 11 (BMW-001): `font-display` wurde app-weit in ~32 Dateien als
   Überschriften-Klasse benutzt, war aber nie definiert — Tailwind verwarf
   sie, alle „Display"-Titel erbten den Body-Font. Dieses Utility macht die
   überall bereits geschriebene Absicht wahr (Headings: TN Condensed Pro,
   CLAUDE.md „Fonts"). */
.font-display {
  font-family: 'BMW Group TN Condensed Pro', system-ui, -apple-system, sans-serif;
}

/* ── Print styles (OEE reports) ───────────────────────── */
@media print {
  /* Hide navigation, sidebar, action buttons */
  nav,
  aside,
  header[data-print-hide],
  [data-print-hide],
  button,
  .scrollbar-none {
    display: none !important;
  }

  body {
    background: white !important;
    color: #1C1C1C !important;
    font-size: 11pt;
  }

  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Keep cards visible, remove shadows */
  .shadow-sm,
  .shadow-xl {
    box-shadow: none !important;
  }

  /* Ensure charts render at full width */
  .recharts-responsive-container {
    width: 100% !important;
  }

  /* Page breaks */
  .page-break-before {
    page-break-before: always;
  }

  /* DCT Petrol headers print correctly */
  .bg-primary,
  .bg-\[\#037493\] {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Drawing surface: keep touch gestures as draw/drag (no scroll) on iOS. touch-action
   must be set on the SVG AND its descendants — Safari does not inherit it. (KAR-662) */
.note-draw-surface,
.note-draw-surface * {
  touch-action: none;
}

/* Wertstrom (VSM) canvas: same KAR-662 lesson as .note-draw-surface above —
   touch-action does not reliably inherit to DOM descendants on Safari, so the
   canvas div's own inline touchAction:'none' (vsm-editor.tsx) is not enough on
   its own for Node-Divs/Connections-SVG/Timeline-Band nested inside it. P8.2b
   Review-Fix K3 (KAR-987, pointer-touch-action-inheritance): wildcard rule +
   a non-passive touchmove/preventDefault fallback (vsm-editor.tsx) mirror the
   note-canvas.tsx fix exactly. */
.vsm-canvas-surface,
.vsm-canvas-surface * {
  touch-action: none;
}

/* iOS safe-area padding (KAR-704 mobile-touch audit). These utility classes were
   referenced by the mobile bottom nav + drawer sheet but never defined, so on
   iPhones with a home indicator the bottom nav overlapped the system gesture
   area and its lowest ~34px swallowed/misfired taps. On non-notch devices
   env(safe-area-inset-bottom) resolves to 0, so desktop is unaffected. */
@layer utilities {
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .pb-safe-or-4 {
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  }
}
