/**
 * Layout Fix V5.0
 * 
 * Behebt Z-Index-Probleme und Überlappungen
 * 
 * @package DATAsoft_Escort_Core
 * @version 5.0.5
 */

/* ===========================
   Z-INDEX HIERARCHY
   =========================== */

/* Level 1: Base Content */
.ds-profile-grid,
.ds-filter-sidebar,
.ds-content-main {
    position: relative;
    z-index: 1;
}

/* Level 2: Header (Sticky) */
.ds-header-v5 {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky, 1020);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
}

/* Level 3: Dropdowns */
.ds-mega-menu,
.ds-user-dropdown,
.ds-guthaben-dropdown,
.ds-notifications-dropdown {
    position: absolute;
    z-index: var(--z-dropdown, 1000);
}

/* Level 4: Customer Menu (Sidebar) */
.ds-customer-menu {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 320px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
    z-index: var(--z-fixed, 1030);
    transform: translateX(100%);
    transition: transform var(--transition-base);
    overflow-y: auto;
    padding: var(--spacing-2xl) var(--spacing-lg);
}

.ds-customer-menu.active {
    transform: translateX(0);
}

/* Level 5: Modal Backdrop */
.ds-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay);
    z-index: var(--z-modal-backdrop, 1040);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.ds-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Level 6: Modals */
.ds-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: var(--z-modal, 1050);
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.ds-modal.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ===========================
   LAYOUT FIXES
   =========================== */

/* Prevent content jump when customer menu opens */
body.customer-menu-open {
    overflow: hidden;
}

/* Ensure profile grid doesn't overlap with sidebar */
.ds-homepage-v5 {
    display: flex;
    gap: var(--spacing-lg);
    max-width: 1920px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.ds-filter-sidebar {
    flex: 0 0 300px;
    position: sticky;
    top: 80px; /* Header height */
    height: calc(100vh - 100px);
    overflow-y: auto;
}

.ds-content-main {
    flex: 1;
    min-width: 0; /* Prevent flex overflow */
}

.ds-werbung-sidebar {
    flex: 0 0 300px;
    position: sticky;
    top: 80px;
    height: calc(100vh - 100px);
    overflow-y: auto;
}

/* ===========================
   RESPONSIVE ADJUSTMENTS
   =========================== */

@media (max-width: 1440px) {
    .ds-werbung-sidebar {
        display: none;
    }
    
    .ds-content-main {
        flex: 1;
    }
}

@media (max-width: 1024px) {
    .ds-filter-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: var(--z-fixed, 1030);
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        background: var(--color-surface);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }
    
    .ds-filter-sidebar.active {
        transform: translateX(0);
    }
    
    .ds-content-main {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .ds-homepage-v5 {
        flex-direction: column;
        padding: var(--spacing-sm);
    }
    
    .ds-customer-menu {
        width: 100%;
    }
}

/* ===========================
   SCROLL BEHAVIOR
   =========================== */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar for sidebar */
.ds-filter-sidebar::-webkit-scrollbar,
.ds-werbung-sidebar::-webkit-scrollbar,
.ds-customer-menu::-webkit-scrollbar {
    width: 8px;
}

.ds-filter-sidebar::-webkit-scrollbar-track,
.ds-werbung-sidebar::-webkit-scrollbar-track,
.ds-customer-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.ds-filter-sidebar::-webkit-scrollbar-thumb,
.ds-werbung-sidebar::-webkit-scrollbar-thumb,
.ds-customer-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.ds-filter-sidebar::-webkit-scrollbar-thumb:hover,
.ds-werbung-sidebar::-webkit-scrollbar-thumb:hover,
.ds-customer-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

