/* NEU: Basis – Schriften (lokal), Design-Tokens, Dark Mode, Reset, Typografie, Animationen */

/* ------------------------------------------------------------ Schriften */
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../assets/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../assets/fonts/dm-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../assets/fonts/dm-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../assets/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('../assets/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('../assets/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2'); }

/* ------------------------------------------------------------ Tokens Light */
:root {
    --primary-light: #e8edf4;
    --primary: #425775;
    --primary-dark: #293e55;
    --secondary-light: #e4e9ef;
    --secondary: #6b839e;
    --secondary-dark: #4a5e75;

    --success-light: #ebf4e8;
    --success: #569948;
    --success-dark: #25762a;
    --warning-light: #f9f4db;
    --warning: #f1c150;
    --warning-dark: #876611;
    --danger-light: #ffe9e9;
    --danger: #d24242;
    --danger-dark: #8a3c3c;
    --info-light: #e8edf4;
    --info: #5a7daa;
    --info-dark: #3e5b80;

    --gray-50: #f7f8fa;
    --gray-100: #eef0f4;
    --gray-200: #dde1e8;
    --gray-300: #c4c9d4;
    --gray-400: #8e95a3;
    --gray-500: #636b79;
    --gray-600: #4a515d;
    --gray-700: #373c46;
    --gray-800: #2b2f38;
    --gray-900: #3d4350;

    --bg-page: #e8ecf1;
    --bg-card: #f5f7fb;
    --bg-sidebar: #3d4350;
    --bg-header: #f5f7fb;
    --bg-hover: var(--gray-50);
    --bg-selected: var(--primary-light);

    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-muted: var(--gray-400);
    --text-inverse: #ffffff;
    --text-sidebar: #c9cfda;

    --border: var(--gray-200);
    --border-light: var(--gray-100);
    --border-top: #ced8e2;

    --shadow-sm: 0 1px 2px rgba(52, 80, 110, 0.08);
    --shadow-md: 0 4px 12px rgba(52, 80, 110, 0.12);
    --shadow-lg: 0 12px 24px rgba(52, 80, 110, 0.15);
    --shadow-xl: 0 20px 40px rgba(52, 80, 110, 0.18);
    --focus-ring: 0 0 0 3px rgba(66, 87, 117, 0.25);

    --radius: 4px;
    --radius-sm: 2px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, monospace;

    --sidebar-width: 272px;
    --sidebar-collapsed-width: 72px;
    --header-height: 64px;
    --bottom-nav-height: 64px;
    --content-max-customer: 560px;

    --touch-target: 48px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    color-scheme: light;
}

/* ------------------------------------------------------------ Tokens Dark */
:root.dark-mode {
    --primary-light: #4a5f7d;
    --primary: #7a7b7d;
    --primary-dark: #8e9298;

    /* ÄNDERUNG gegenüber Design-System v2.0: Statusflächen im Dark Mode abgedunkelt,
       damit Badges/Alerts nicht als helle Flecken erscheinen (Kontrast Text/Fläche >= 4.5:1) */
    --secondary-light: #2c333c;
    --secondary-dark: #aebfd2;
    --success-light: #22301f;
    --success-dark: #8ccf7e;
    --warning-light: #37301d;
    --warning-dark: #f1c150;
    --danger-light: #3b2323;
    --danger-dark: #f09090;
    --info-light: #232e3c;
    --info-dark: #9db8dc;

    --gray-50: #282a31;
    --gray-100: #31343b;
    --gray-200: #3c3f46;
    --gray-300: #474952;
    --gray-400: #6a6f7e;
    --gray-500: #8a8f9e;
    --gray-600: #9a9fae;
    --gray-700: #aab0bf;
    --gray-800: #babfc0;
    --gray-900: #d0d5df;

    --bg-page: #222425;
    --bg-card: #202020;
    --bg-sidebar: #202020;
    --bg-header: #1e1e1e;

    --text-primary: #e0e5f0;
    --text-secondary: #8a8f9e;
    --text-muted: #a0a4af;
    --text-sidebar: #a9afbb;

    --border: #333741;
    --border-light: #3f4046;
    --border-top: #4a4f5e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(157, 184, 220, 0.35);

    color-scheme: dark;
}

/* ------------------------------------------------------------ Reset */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
/* NEU UX: Schriftgröße (Einstellungen/Profil) – skaliert alle rem-Größen der App */
html[data-font-scale="small"] { font-size: 90%; }
html[data-font-scale="large"] { font-size: 112.5%; }
html[data-font-scale="xlarge"] { font-size: 125%; }

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ------------------------------------------------------------ Utilities */
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.2px; }
.link { color: var(--primary); font-weight: 500; }
.link:hover { text-decoration: underline; }
.help-text { font-size: 0.8rem; color: var(--text-muted); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: fixed; top: 0.5rem; left: 0.5rem; z-index: 3000;
    padding: 0.6rem 1rem; border-radius: var(--radius);
    background: var(--primary); color: var(--text-inverse);
    transform: translateY(-200%); transition: var(--transition-fast);
}
.skip-link:focus-visible { transform: translateY(0); }

.app-loading, .noscript {
    min-height: 100dvh; display: flex; flex-direction: column; gap: 0.75rem;
    align-items: center; justify-content: center; color: var(--text-secondary);
}
.app-loading i { font-size: 2rem; color: var(--primary); animation: pulse 1.5s infinite; }

/* ------------------------------------------------------------ Animationen */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@keyframes toastProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes progressShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes statusSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
