/*
 * Branding-Tokens
 * System-Defaults seit 2026-05-14 = Nolar-Plattform-CI.
 * Pro Tenant überschreibbar via BrandingService::buildCssOverride() —
 * die DB-Entity setzt einzelne --brand-*-Werte und übersteuert diese Defaults.
 * Bestehende Variable-Namen (--brand-primary, --neutral-*) bleiben, damit
 * keine App-CSS-Reference bricht. Werte sind auf Nolar-Palette umgestellt.
 */
:root {
    /* === Nolar-Brand-Palette (vollständig, für Status-Pills + Akzente) === */
    --nolar-yellow:         #FFD23F;
    --nolar-orange:         #FF7849;
    --nolar-magenta:        #C24A8A;
    --nolar-purple:         #6E47C2;
    --nolar-blue:           #3A55D9;
    --nolar-cyan:           #4FBDD9;

    /* === Brand-Primary (Tenant-überschreibbar) === */
    /* Default = Nolar-Purple. Bjoerns Solarkonzepte-Branding (Orange) kommt aus DB-Entity. */
    --brand-primary:        #6E47C2;
    --brand-primary-dark:   #5938A6;  /* Hover */
    --brand-primary-soft:   #F1ECFA;  /* sanfte Hintergründe (Sidebar-aktiv, Pills) */
    --brand-on-soft:        #4A2E96;  /* Text auf soft */
    --brand-neutral:        #5E687F;  /* Plattform-Grau */

    /* === Neutralskala (Nolar) === */
    --neutral-50:           #FFFFFF;  /* Page-BG */
    --neutral-100:          #F4F5F8;  /* Card-BG / bg-soft */
    --neutral-200:          #F1F2F7;  /* Borders / aktive Nav-Items */
    --neutral-300:          #C7CBD3;  /* Disabled */
    --neutral-400:          #8A8F98;  /* text-faint */
    --neutral-700:          #5E687F;  /* text-muted */
    --neutral-900:          #0B1020;  /* ink / Headlines */

    /* Oberflächen */
    --surface:              #FFFFFF;

    /* Nolar Tagline / Hintergrund-Akzente */
    --ink:                  #0B1020;
    --ink-soft:             #2A3340;
    --text:                 #3A3F4A;

    /* === Semantik === */
    --color-success:        #22C55E;
    --color-success-bg:     #DCFCE7;
    --color-success-border: #BBF7D0;
    --color-success-text:   #15803D;

    --color-danger:         #DC2626;
    --color-danger-bg:      #FEF2F2;
    --color-danger-border:  #FECACA;
    --color-danger-text:    #DC2626;

    /* === Schrift === */
    /* Inter als Hauptfont (Nolar-Spec). Google Font wird via base.html.twig geladen. */
    --font-stack: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    color-scheme: light;
}

/*
 * Light-Mode Legacy-Hex-Remap.
 * Templates haben aus Solarkonzepte-Zeiten noch hardcoded Hex-Werte
 * (#989697, #2A2828, #F9A72B, …) in Inline-Styles. Statt 50+ Templates
 * massen-zu-refactoren, biegen Attribute-Selektoren diese Hex-Werte auf
 * Nolar-Tokens um. Reine Defensive — sobald ein Template umgeschrieben ist
 * (var(--neutral-700) statt #989697) verschwindet der Effekt automatisch.
 * Greift IMMER (kein Theme-Selektor), Dark-Mode-Layer weiter unten gewinnt
 * dann per höherer Spezifität, weil [data-theme="dark"] davor kommt.
 */
[style*="color: #989697"],
[style*="color:#989697"]   { color: var(--neutral-400) !important; }
[style*="color: #888"]     { color: var(--neutral-400) !important; }
[style*="color: #999"]     { color: var(--neutral-400) !important; }

[style*="color: #656263"],
[style*="color:#656263"]   { color: var(--neutral-700) !important; }
[style*="color: #555"]     { color: var(--neutral-700) !important; }
[style*="color: #666"]     { color: var(--neutral-700) !important; }
[style*="color: #737373"]  { color: var(--neutral-700) !important; }

[style*="color: #2A2828"],
[style*="color:#2A2828"],
[style*="color: #1a1a1a"],
[style*="color:#1a1a1a"]   { color: var(--ink) !important; }

[style*="color: #F9A72B"],
[style*="color:#F9A72B"],
[style*="color: #B07712"],
[style*="color:#B07712"]   { color: var(--brand-primary) !important; }

[style*="background: #F9A72B"],
[style*="background:#F9A72B"],
[style*="background-color: #F9A72B"],
[style*="background-color:#F9A72B"]   { background: var(--brand-primary) !important; }

[style*="background: #FDE0B5"],
[style*="background:#FDE0B5"],
[style*="background: #FFF7ED"],
[style*="background:#FFF7ED"]         { background: var(--brand-primary-soft) !important; }

[style*="background: #F9A72B"][style*="color: white"],
[style*="background:#F9A72B"][style*="color: white"]   { color: white !important; }

[style*="border-color: #F9A72B"],
[style*="border-color:#F9A72B"]       { border-color: var(--brand-primary) !important; }

/*
 * Dark-Mode — aktiviert durch <html data-theme="dark">. Nolar-Brand bleibt;
 * Neutralskala invertiert auf Nolar-dunkel-Werte; Semantic-Farben mit dunkleren Hintergründen.
 */
[data-theme="dark"] {
    --neutral-50:           #0B1020;
    --neutral-100:          #161B2E;
    --neutral-200:          #232A41;
    --neutral-300:          #3A4256;
    --neutral-400:          #8A8F98;
    --neutral-700:          #C7CBD3;
    --neutral-900:          #FFFFFF;

    --surface:              #161B2E;

    --brand-primary-soft:   #2A1F50;
    --brand-on-soft:        #B79EE8;

    --color-success-bg:     #14301F;
    --color-success-border: #1F4A30;
    --color-success-text:   #4ADE80;

    --color-danger-bg:      #3A1818;
    --color-danger-border:  #5A2424;
    --color-danger-text:    #F87171;

    color-scheme: dark;
}

/*
 * Dark-Mode Override für hardcoded Hex-Farben in Inline-Styles.
 * Templates verwenden teilweise direkt #2A2828, #656263 etc. statt CSS-Vars —
 * diese werden hier mit höherer Spezifität auf die Dark-Mode-Tokens umgebogen.
 * Attribute-Selektoren machen das ohne Template-Massen-Refactoring.
 */
[data-theme="dark"] [style*="color: #2A2828"],
[data-theme="dark"] [style*="color:#2A2828"]   { color: var(--neutral-900) !important; }
[data-theme="dark"] [style*="color: #0B1020"],
[data-theme="dark"] [style*="color:#0B1020"]   { color: var(--neutral-900) !important; }

[data-theme="dark"] [style*="color: #656263"],
[data-theme="dark"] [style*="color:#656263"]   { color: var(--neutral-700) !important; }
[data-theme="dark"] [style*="color: #5E687F"],
[data-theme="dark"] [style*="color:#5E687F"]   { color: var(--neutral-700) !important; }

[data-theme="dark"] [style*="color: #888"]     { color: var(--neutral-400) !important; }
[data-theme="dark"] [style*="color: #666"]     { color: var(--neutral-700) !important; }
[data-theme="dark"] [style*="color: #8A8F98"],
[data-theme="dark"] [style*="color:#8A8F98"]   { color: var(--neutral-400) !important; }

[data-theme="dark"] [style*="color: #B07712"],
[data-theme="dark"] [style*="color:#B07712"]   { color: var(--brand-on-soft) !important; }

[data-theme="dark"] [style*="background: #FFFBEB"],
[data-theme="dark"] [style*="background:#FFFBEB"],
[data-theme="dark"] [style*="background: #FEF3C7"],
[data-theme="dark"] [style*="background:#FEF3C7"]   { background: var(--neutral-100) !important; }

[data-theme="dark"] [style*="background: #DCFCE7"],
[data-theme="dark"] [style*="background:#DCFCE7"]   { background: var(--color-success-bg) !important; }

[data-theme="dark"] [style*="background: #FEE2E2"],
[data-theme="dark"] [style*="background:#FEE2E2"],
[data-theme="dark"] [style*="background: #FEF2F2"],
[data-theme="dark"] [style*="background:#FEF2F2"]   { background: var(--color-danger-bg) !important; }

[data-theme="dark"] [style*="background: #fafafa"],
[data-theme="dark"] [style*="background:#fafafa"],
[data-theme="dark"] [style*="background: #FAFAF9"],
[data-theme="dark"] [style*="background:#FAFAF9"],
[data-theme="dark"] [style*="background: #F4F5F8"],
[data-theme="dark"] [style*="background:#F4F5F8"]   { background: var(--neutral-100) !important; }

[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #FFF"],
[data-theme="dark"] [style*="background:#FFF"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #FFFFFF"],
[data-theme="dark"] [style*="background:#FFFFFF"]   { background: var(--surface) !important; color: var(--neutral-900); }

[data-theme="dark"] [style*="background: #FFF7ED"],
[data-theme="dark"] [style*="background:#FFF7ED"],
[data-theme="dark"] [style*="background: #F1ECFA"],
[data-theme="dark"] [style*="background:#F1ECFA"]   { background: var(--brand-primary-soft) !important; }

/*
 * Defense: Tenant-Brand kann auf jeden Wert gesetzt werden (auch #000000).
 * Im Darkmode brauchen Links eine Mindesthelligkeit unabhängig vom Tenant-Brand —
 * --brand-on-soft ist im Darkmode hartcodiert auf hellem Lila und wird nicht
 * durch BrandingService::buildCssOverride() überschrieben.
 * Buttons/Badges bleiben unangetastet (eigene Hintergründe + Kontrast).
 */
[data-theme="dark"] a:not(.btn):not(.btn-secondary):not(.badge) {
    color: var(--neutral-900) !important;
}
[data-theme="dark"] a:not(.btn):not(.btn-secondary):not(.badge):hover {
    color: var(--brand-on-soft) !important;
}

[data-theme="dark"] dialog {
    background: var(--surface);
    color: var(--neutral-900);
}

[data-theme="dark"] textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] select {
    background: var(--surface);
    color: var(--neutral-900);
    border-color: var(--neutral-200);
}
