/* ==========================================================================
   KLEINE MÜHLE - MASTER CSS V9.0 (Fluid Native App SPA)
   Fokus: Zentrale Variablen, Safe-Areas, Fluid Typography, Outfit Font, Glassmorphism
   ========================================================================== */

:root {
    /* --- 1. FARBPALETTE ("Bayerische Eleganz") --- */
    --theme-ink: #1A3A53;
    --theme-ink-rgb: 26, 58, 83;
    --theme-text: #1A3A53;
    --theme-ink-text: #ffffff;
    --theme-bg: #FCFBF9; /* Helles Beige/Off-White als Basis */
    --theme-sidebar-bg: rgba(252, 251, 249, 0.75);
    --theme-card: #FFFFFF;
    --theme-card-muted: rgba(26, 58, 83, 0.03); /* Soft Tint statt harter Grauwerte */
    --theme-line: rgba(26, 58, 83, 0.08); /* Unsichtbare Trenner */
    --theme-muted: #8F9EAF;
    --theme-accent: #C4A380;
    --theme-accent-rgb: 196, 163, 128;
    --theme-accent-text: #ffffff;
    --theme-pattern: rgba(26, 58, 83, 0.03);
    --theme-pattern-accent: rgba(196, 163, 128, 0.05);
    --theme-success: #16A34A;
    --theme-danger: #E11D48;
    --theme-warning: #D97706;

    /* --- 2. RADIEN (Organisch, Squircle-Fokus) --- */
    --radius-sm: 12px;
    --radius-md: clamp(16px, 2vw, 20px);
    --radius-lg: clamp(24px, 4vw, 32px);
    --radius-xl: clamp(32px, 5vw, 48px);
    --radius-full: 9999px;
    --radius-squircle: 35%;

    /* --- 3. SCHATTEN (Glassmorphism & Depth) --- */
    --shadow-soft: 0 10px 30px -10px rgba(26, 58, 83, 0.05);
    --shadow-float: 0 20px 40px -10px rgba(26, 58, 83, 0.12);
    --shadow-focus: 0 0 0 4px rgba(196, 163, 128, 0.2);

    /* --- 4. FLUID TYPOGRAPHY (Clamp) --- */
    --text-xs: clamp(0.7rem, 1vw, 0.75rem);
    --text-sm: clamp(0.8rem, 1.2vw, 0.875rem);
    --text-base: clamp(1rem, 1.5vw, 1.05rem);
    --text-lg: clamp(1.15rem, 2vw, 1.25rem);
    --text-xl: clamp(1.4rem, 2.5vw, 1.6rem);
    --text-2xl: clamp(1.8rem, 3.5vw, 2.2rem);
    --text-3xl: clamp(2.4rem, 5vw, 3rem);

    /* --- 5. LAYOUT & SPACING METRIKEN --- */
    --sidebar-width: clamp(260px, 20vw, 320px);
    --mobile-nav-height: calc(72px + env(safe-area-inset-bottom));
    --ease-fluid: cubic-bezier(0.25, 1, 0.5, 1);
    --ease-squishy: cubic-bezier(0.4, -0.3, 0.2, 1.2);
    --spacing-xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --spacing-sm: clamp(0.5rem, 1vw, 0.75rem);
    --spacing-md: clamp(1rem, 2vw, 1.5rem);
    --spacing-lg: clamp(1.5rem, 4vw, 2.5rem);
    --spacing-xl: clamp(2.5rem, 6vw, 4rem);

    /* --- 6. MUSTER VORLAGEN --- */
    --bg-organic: radial-gradient(circle at 80% 20%, var(--theme-pattern) 0%, transparent 40%), radial-gradient(circle at 20% 80%, var(--theme-pattern-accent) 0%, transparent 40%);
    --bg-geometric: linear-gradient(45deg, var(--theme-pattern) 25%, transparent 25%, transparent 75%, var(--theme-pattern) 75%), linear-gradient(45deg, var(--theme-pattern) 25%, transparent 25%, transparent 75%, var(--theme-pattern) 75%);
    --bg-playful: radial-gradient(var(--theme-pattern-accent) 15%, transparent 16%), radial-gradient(var(--theme-pattern-accent) 15%, transparent 16%);
    --bg-waves: repeating-radial-gradient(circle at 0 0, transparent 0, var(--theme-pattern) 4px, transparent 5px, var(--theme-pattern-accent) 10px);
    --bg-grid: linear-gradient(var(--theme-pattern) 1px, transparent 1px), linear-gradient(90deg, var(--theme-pattern) 1px, transparent 1px);
    --bg-dots: radial-gradient(var(--theme-pattern) 3px, transparent 4px), radial-gradient(var(--theme-pattern) 3px, transparent 4px);
    --bg-stripes: repeating-linear-gradient(45deg, transparent, transparent 10px, var(--theme-pattern) 10px, var(--theme-pattern) 12px);
}

@font-face { font-family: 'Playfair Display'; src: url('../../assets/fonts/PlayfairDisplay-Regular.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'Outfit'; src: url('../../assets/fonts/Outfit-Regular.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* NATIVE APP FEELING */
body {
    background-color: var(--theme-bg);
    color: var(--theme-text);
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
    overscroll-behavior-y: none;
    display: flex;
}

[x-cloak] { display: none !important; }

/* HINTERGRUND ZUWEISUNGEN (Theming) */
body.theme-minimal { background-image: none; }
body.theme-organic, body.theme-organic .km-app-sidebar { background-image: var(--bg-organic); }
body.theme-geometric, body.theme-geometric .km-app-sidebar { background-image: var(--bg-geometric); background-size: 40px 40px; background-position: 0 0, 20px 20px; }
body.theme-playful, body.theme-playful .km-app-sidebar { background-image: var(--bg-playful); background-size: 30px 30px; background-position: 0 0, 15px 15px; }
body.theme-waves, body.theme-waves .km-app-sidebar { background-image: var(--bg-waves); background-size: 80px 80px; }
body.theme-grid, body.theme-grid .km-app-sidebar { background-image: var(--bg-grid); background-size: 24px 24px; }
body.theme-dots, body.theme-dots .km-app-sidebar { background-image: var(--bg-dots); background-size: 30px 30px; background-position: 0 0, 15px 15px; }
body.theme-stripes, body.theme-stripes .km-app-sidebar { background-image: var(--bg-stripes); }
body.mobile .km-app-sidebar { background-image: none !important; }

/* UTILITY CLASSES */
.text-ink { color: var(--theme-text); }
.text-accent { color: var(--theme-accent); }
.text-danger { color: var(--theme-danger); }
.text-success { color: var(--theme-success); }
.text-muted { color: var(--theme-muted); }
.bg-ink { background-color: var(--theme-ink); color: var(--theme-ink-text); }
.font-mono { font-family: monospace; }
.tracking-widest { letter-spacing: 0.1em; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.font-bold { font-weight: 800; }
.leading-tight { line-height: 1.25; }
.shrink-0 { flex-shrink: 0; }
.border-none { border: none !important; }

/* FLUID SPACING */
.mt-16 { margin-top: var(--spacing-md) !important; }
.mb-16 { margin-bottom: var(--spacing-md) !important; }
.mt-32 { margin-top: var(--spacing-lg) !important; }
.mb-32 { margin-bottom: var(--spacing-lg) !important; }
.p-16 { padding: var(--spacing-md) !important; }
.p-32 { padding: var(--spacing-lg) !important; }

/* --- APP SHELL ARCHITEKTUR --- */
.km-app-layout {
    display: flex;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
}

.km-app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--theme-sidebar-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg) var(--spacing-md);
    flex-shrink: 0;
    z-index: 50;
    border-right: 1px solid var(--theme-line);
    padding-top: calc(var(--spacing-lg) + env(safe-area-inset-top));
    padding-bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
}

.km-brand { display: flex; align-items: center; gap: 12px; margin-bottom: var(--spacing-md); }
.km-brand i { font-size: var(--text-2xl); color: var(--theme-accent); }
.km-brand h1 { font-family: 'Playfair Display', serif; font-size: var(--text-xl); font-weight: 900; letter-spacing: -1px; margin: 0; color: var(--theme-text); }

.km-app-nav { display: flex; flex-direction: column; gap: 8px; margin-top: var(--spacing-lg); flex: 1; }

.km-nav-link {
    display: flex; align-items: center; gap: 16px; padding: 12px 16px;
    border-radius: var(--radius-md); color: var(--theme-muted);
    font-weight: 700; font-size: var(--text-base); cursor: pointer;
    transition: all 0.3s var(--ease-squishy); min-height: 52px;
}
.km-nav-link:hover { color: var(--theme-text); background-color: var(--theme-card); box-shadow: var(--shadow-soft); transform: translateX(4px); }

.km-nav-icon {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: var(--radius-squircle);
    background-color: var(--theme-card-muted); color: var(--theme-muted);
    font-size: 1.2rem; transition: all 0.3s var(--ease-squishy); flex-shrink: 0;
}

.km-nav-link.active { background-color: var(--theme-card); color: var(--theme-text); box-shadow: var(--shadow-float); transform: scale(1.02); border: 1px solid var(--theme-line); }

/* Dynamische Tab-Farben */
.km-nav-link.active[data-tab="dashboard"] .km-nav-icon { background-color: rgba(26, 58, 83, 0.1); color: var(--theme-text); }
.km-nav-link.active[data-tab="family"] .km-nav-icon { background-color: rgba(196, 163, 128, 0.15); color: var(--theme-accent); }
.km-nav-link.active[data-tab="calendar"] .km-nav-icon { background-color: rgba(139, 92, 246, 0.15); color: #8B5CF6; }
.km-nav-link.active[data-tab="tasks"] .km-nav-icon { background-color: rgba(251, 113, 133, 0.15); color: #FB7185; }
.km-nav-link.active[data-tab="food"] .km-nav-icon { background-color: rgba(245, 158, 11, 0.15); color: #D97706; }
.km-nav-link.active[data-tab="health"] .km-nav-icon { background-color: rgba(37, 99, 235, 0.15); color: #2563EB; }
.km-nav-link.active[data-tab="settings"] .km-nav-icon { background-color: rgba(100, 116, 139, 0.15); color: #475569; }

.km-app-main {
    flex: 1; background-color: transparent; overflow-y: auto; overflow-x: hidden;
    padding: var(--spacing-xl); padding-bottom: 6rem;
    -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
    padding-top: calc(var(--spacing-xl) + env(safe-area-inset-top));
}

/* MOBILE OVERRIDE */
body.mobile .km-app-layout { flex-direction: column; }
body.mobile .km-app-sidebar {
    position: fixed; bottom: 0; left: 0; right: 0;
    width: 100%; height: var(--mobile-nav-height);
    flex-direction: row; padding: 0 0.5rem env(safe-area-inset-bottom) 0.5rem;
    background: rgba(252, 251, 249, 0.85); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--theme-line); z-index: 100; border-right: none;
}
body.mobile .km-app-nav { flex-direction: row; margin-top: 0; justify-content: space-around; width: 100%; align-items: center; }
body.mobile .km-nav-link { flex-direction: column; gap: 4px; padding: 6px; background: none !important; box-shadow: none !important; transform: none !important; min-height: auto; border: none !important;}
body.mobile .km-nav-link span { font-size: var(--text-xs); font-weight: 800; color: var(--theme-muted); transition: color 0.3s; }
body.mobile .km-nav-link.active span { color: var(--theme-text); }
body.mobile .km-nav-icon { width: 36px; height: 36px; border-radius: var(--radius-squircle); font-size: 1.1rem; }
body.mobile .km-app-main { padding-bottom: calc(var(--mobile-nav-height) + 2rem); padding: var(--spacing-md); }
body.mobile .km-sidebar-header, body.mobile .km-sidebar-footer { display: none; }