/* =====================================================
   FIXBUDDY DASHBOARD V2 - LAYOUT
   Professionelles Dark Theme Layout
   ===================================================== */

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    font-size: 16px; /* Erhöht für bessere Lesbarkeit (18-70 Jahre) */
}

body {
    height: 100%;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ===== DASHBOARD CONTAINER ===== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: width var(--transition-slow);
}

/* Logo */
.sidebar-logo {
    height: var(--header-height);
    padding: 0 var(--space-5);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-logo .logo-fix {
    color: var(--text-primary);
}

.sidebar-logo .logo-buddy {
    color: var(--accent);
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: var(--space-4) var(--space-3);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color-light);
    border-radius: 2px;
}

/* Nav Sections */
.nav-group {
    margin-bottom: var(--space-6);
}

.nav-group-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

/* Nav Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3);
    margin-bottom: 2px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    min-height: 44px; /* Accessibility: min touch target */
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-glow);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-item-icon .icon {
    filter: brightness(0) invert(0.6);
    transition: filter var(--transition);
}

.nav-item:hover .nav-item-icon .icon,
.nav-item.active .nav-item-icon .icon {
    filter: brightness(0) saturate(100%) invert(77%) sepia(30%) saturate(500%) hue-rotate(6deg) brightness(95%);
}

.nav-item-text {
    font-size: var(--font-size-sm);
    font-weight: 500;
    white-space: nowrap;
}

.nav-item-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--bg-primary);
    background: var(--accent);
    border-radius: 9px;
}

/* Sidebar User */
.sidebar-user {
    padding: var(--space-4);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--bg-primary);
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: var(--font-size-xs);
    color: var(--accent);
}

.sidebar-logout {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-logout .icon {
    filter: brightness(0) invert(0.4);
}

.sidebar-logout:hover {
    background: var(--danger-bg);
}

.sidebar-logout:hover .icon {
    filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1500%) hue-rotate(331deg);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* Top Bar */
.topbar {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Content */
.content {
    flex: 1;
    padding: var(--space-6);
}

/* Module Container */
.module {
    display: none;
    animation: fadeIn 0.2s ease;
}

.module.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }
    
    .sidebar-logo span,
    .nav-group-title,
    .nav-item-text,
    .nav-item-badge,
    .sidebar-user-info {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: var(--space-3);
    }
    
    .nav-item.active::before {
        display: none;
    }
    
    .sidebar-user {
        justify-content: center;
    }
    
    .sidebar-logout {
        display: none;
    }
    
    .main-content {
        margin-left: var(--sidebar-collapsed);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-logo span,
    .nav-group-title,
    .nav-item-text,
    .nav-item-badge,
    .sidebar-user-info {
        display: block;
    }
    
    .nav-item {
        justify-content: flex-start;
        padding: var(--space-3) var(--space-3);
    }
    
    .sidebar-user {
        justify-content: flex-start;
    }
    
    .sidebar-logout {
        display: flex;
    }
    
    .main-content {
        margin-left: 0;
        overflow-x: hidden;
        max-width: 100vw;
    }

    .content {
        padding: var(--space-4);
        padding-bottom: 90px; /* Platz für Bottom Nav */
        overflow-x: hidden;
        max-width: 100%;
    }

    #module-content {
        overflow-x: hidden;
        max-width: 100%;
    }
}

/* ===== MOBILE BOTTOM NAVIGATION ===== */
/* Hidden on desktop */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70px;
        background: #151515;
        border-top: 1px solid rgba(255,255,255,0.1);
        z-index: 9999;
        padding: 8px 0;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: #666;
        text-decoration: none;
        font-size: 12px; /* Mobile-Fix: 10px war zu klein */
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;
    }

    .bottom-nav-item span:not(.nav-icon-wrap):not(.bottom-nav-badge) {
        display: block;
    }

    .bottom-nav-item:active {
        transform: scale(0.95);
    }

    .bottom-nav-item.active {
        color: #b8935f;
    }

    .bottom-nav-item svg {
        width: 24px !important;
        height: 24px !important;
        flex-shrink: 0;
    }

    .bottom-nav-item.create-btn {
        color: #fff;
    }

    .bottom-nav-item.create-btn .nav-icon-wrap {
        width: 50px;
        height: 50px;
        background: linear-gradient(135deg, #b8935f 0%, #A5885A 100%);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: -25px;
        box-shadow: 0 4px 15px rgba(184,147,95,0.5);
        border: 3px solid #151515;
    }

    .bottom-nav-item.create-btn .nav-icon-wrap svg {
        width: 22px !important;
        height: 22px !important;
    }

    .bottom-nav-item.create-btn span:last-child {
        margin-top: -2px;
        font-size: 11px; /* Mobile-Fix: 9px war zu klein */
    }

    .bottom-nav-badge {
        position: absolute;
        top: 2px;
        right: 50%;
        transform: translateX(14px);
        min-width: 18px;
        height: 18px;
        background: #E53935;
        border-radius: 9px;
        font-size: 10px;
        font-weight: 600;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 5px;
    }
}

/* ===== EXTRA SMALL DEVICES (iPhone SE, kleine Android) ===== */
@media (max-width: 375px) {
    .bottom-nav {
        height: 65px;
        padding: 6px 0;
    }

    .bottom-nav-item {
        font-size: 11px;
        gap: 2px;
    }

    .bottom-nav-item svg {
        width: 22px !important;
        height: 22px !important;
    }

    .bottom-nav-item.create-btn .nav-icon-wrap {
        width: 46px;
        height: 46px;
        margin-top: -22px;
    }

    .content {
        padding: 12px !important;
        padding-bottom: 80px !important;
    }

    /* Kleinere Abstände auf sehr kleinen Screens */
    .module-header {
        padding: 16px 12px;
    }

    .card, .order-card {
        padding: 12px;
    }
}
