/* assets/css/app_layout.css - v5.0 (Final Force Fix) */

:root {
    --app-bg: #0f172a;
    --app-card: #1e293b;
    --app-accent: #0ea5e9;
    --app-text: #f8fafc;
    --app-muted: #94a3b8;
    --app-border: rgba(255, 255, 255, 0.08);
    
    /* Basis-Höhen der Leisten (ohne Safe Area) */
    --header-base-height: 50px;
    --nav-base-height: 55px;
    
    /* Standard Safe Areas (Starten bei 0) */
    --safe-area-top: 0px;
    --safe-area-bottom: 0px;
}

/* Falls der Browser es nativ kann (iOS meistens) */
@supports (padding-top: env(safe-area-inset-top)) {
    :root {
        --safe-area-top: env(safe-area-inset-top, 0px);
        --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* --- GRUNDLAYOUT --- */
body {
    margin: 0;
    padding: 0;
    background-color: var(--app-bg);
    color: var(--app-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* BODY PADDING:
       Oben: Header-Höhe + Safe-Area + 15px Abstand zum Inhalt 
       Unten: Nav-Höhe + Safe-Area + 20px Abstand */
    padding-top: calc(var(--header-base-height) + var(--safe-area-top) + 15px) !important;
    padding-bottom: calc(var(--nav-base-height) + var(--safe-area-bottom) + 20px) !important;
    
    overflow-x: hidden;
    width: 100%;
}

/* --- HEADER (OBEN) --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.98); /* Etwas undurchsichtiger */
    border-bottom: 1px solid var(--app-border);
    
    /* Gesamthöhe wächst mit der Safe Area */
    height: calc(var(--header-base-height) + var(--safe-area-top));
    
    /* Padding oben schiebt den Text UNTER die Statusleiste */
    padding-top: var(--safe-area-top);
    padding-left: 16px;
    padding-right: 16px;
    
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.app-brand, .app-header-actions {
    /* Inhalt ist immer 50px hoch, egal wie dick die Statusleiste ist */
    height: var(--header-base-height);
    display: flex;
    align-items: center;
    color: white;
    font-weight: 800;
    text-decoration: none;
    text-transform: uppercase;
}

.app-header-actions { gap: 12px; }

/* --- BOTTOM NAV (UNTEN) --- */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: #0f172a;
    border-top: 1px solid var(--app-border);
    
    /* Gesamthöhe wächst mit der Safe Area */
    height: calc(var(--nav-base-height) + var(--safe-area-bottom));
    
    /* Padding unten schiebt die Icons ÜBER die Systemleiste */
    padding-bottom: var(--safe-area-bottom);
    
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-sizing: border-box;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--app-muted);
    font-size: 10px;
    gap: 4px;
    width: 20%;
    /* WICHTIG: Klickbereich ist nur die Basis-Höhe, nicht die Safe-Area */
    height: var(--nav-base-height);
    position: relative;
}
.nav-item.active { color: var(--app-accent); }
.nav-item i { font-size: 20px; margin-bottom: 2px; }

.nav-badge {
    position: absolute; top: 4px; right: 20%;
    background: #ef4444; color: white; font-size: 10px; font-weight: bold;
    min-width: 16px; height: 16px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #0f172a; padding: 0 3px;
}

/* --- MENÜ OVERLAY --- */
.menu-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: #0f172a; color: white;
    display: flex; flex-direction: column;
    transform: translateY(100%); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto; 
    
    /* Auch das Menü muss Abstände halten */
    padding-top: var(--safe-area-top);
    padding-bottom: calc(20px + var(--safe-area-bottom));
}
.menu-overlay.open { transform: translateY(0); }

.menu-header {
    /* Header im Menü braucht keine extra Safe-Area im Padding, weil der Container schon Padding hat */
    padding: 16px 20px; 
    min-height: 60px;
    display: flex; justify-content: space-between; align-items: center;
    background: var(--app-card); border-bottom: 1px solid var(--app-border);
    position: sticky; top: 0; z-index: 10;
}

/* Restliche Styles unverändert */
.menu-close-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; }
.menu-section { padding: 20px; border-bottom: 1px solid var(--app-border); }
.menu-section-title { font-size: 11px; text-transform: uppercase; color: var(--app-muted); font-weight: 800; margin-bottom: 15px; letter-spacing: 1px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-tile {
    background: rgba(255,255,255,0.03); padding: 16px; border-radius: 16px;
    text-decoration: none; color: white; display: flex; flex-direction: column;
    align-items: center; text-align: center; gap: 10px; border: 1px solid var(--app-border);
    transition: 0.2s;
}
.menu-list { list-style: none; padding: 0; margin: 0; }
.menu-list-item { display: flex; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,0.05); text-decoration: none; color: var(--app-text); font-size: 15px; align-items: center; gap: 15px; }
.menu-list-item:last-child { border-bottom: none; }
.menu-list-item i { width: 24px; text-align: center; color: var(--app-muted); }
.user-stats-bar { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 5px; scrollbar-width: none; }
.stat-chip { background: rgba(255,255,255,0.05); padding: 8px 14px; border-radius: 99px; font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 8px; font-weight: 600; border: 1px solid var(--app-border); }
.wrap, .page-container, main { margin-top: 0 !important; padding-top: 0 !important; max-width: 1400px; margin-left: auto; margin-right: auto; }
.dmp-toggle, .comm-chat-toggle { display: none !important; visibility: hidden !important; pointer-events: none !important; }
.dm-leftbar, .comm-chat-drawer, .dm-chatdock { z-index: 99999 !important; }

/* --- DESKTOP (> 1024px) --- */
@media (min-width: 1024px) {
    :root { 
        --header-base-height: 70px; 
        --safe-area-top: 0px !important; 
        --safe-area-bottom: 0px !important;
    }
    .app-header { display: none; }
    body { padding-top: var(--header-base-height) !important; padding-bottom: 0 !important; }
    .app-nav {
        top: 0; bottom: auto; height: var(--header-base-height);
        padding-bottom: 0; justify-content: center; gap: 40px;
    }
    .nav-item { flex-direction: row; width: auto; font-size: 14px; font-weight: 600; padding: 0 20px; border-radius: 12px; height: 45px; }
    .menu-overlay { width: 400px; left: auto; right: 0; border-left: 1px solid var(--app-border); box-shadow: -10px 0 30px rgba(0,0,0,0.5); padding-top: 0; }
}

@media (max-width: 980px) {
    .dm-leftbar, .comm-chat-drawer { 
        bottom: calc(var(--nav-base-height) + var(--safe-area-bottom)) !important;
        top: calc(var(--header-base-height) + var(--safe-area-top)) !important;
        width: 100% !important; max-width: 100% !important; border-radius: 0 !important;
    }
}