/**
 * DataJam Pulse Portal - Layout Styles
 * Extracted from index.html v5.4.1 (Dec 13, 2025)
 *
 * Purpose: Structural layout, containers, sidebar, main content shell
 * Dependencies: Must load AFTER base.css (requires CSS variables)
 *
 * Sections:
 * 1. Container (app shell)
 * 2. Sidebar (structure, positioning, responsive)
 * 3. Main content (flex container)
 * 4. Header (sticky, responsive)
 * 5. Content padding
 * 6. Mobile sidebar overlay
 * 7. Responsive layout overrides
 */

/* ============================================
   CONTAINER (App Shell)
   ============================================ */

.container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ============================================
   SIDEBAR STRUCTURE
   ============================================ */

.sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--bg-tertiary);
    transition: width 0.3s, transform 0.3s, background 0.3s ease;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar.closed {
    width: 0;
}

.sidebar-header {
    padding: 28px 24px;
    border-bottom: 1px solid #2d3748;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* Don't shrink */
}

.sidebar-header img {
    max-width: 150px;
    height: auto;
}

.sidebar-content {
    padding: 24px;
    padding-bottom: 24px;
    flex: 1;
    min-height: 0; /* Fix: Allow scrolling in flex container */
    overflow-y: auto;
    overflow-x: hidden;
    /* Custom scrollbar for webkit browsers */
    scrollbar-width: thin;
    scrollbar-color: #4a5568 transparent;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background-color: #4a5568;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background-color: #718096;
}

.sidebar-bottom {
    flex-shrink: 0; /* Don't shrink */
    margin-top: auto; /* Push to bottom even if content is short */
    padding: 24px;
    background: #1a1c24;
    border-top: 1px solid #2d3748;
}

/* ============================================
   MAIN CONTENT SHELL
   ============================================ */

.main-content {
    flex: 1;
    overflow: auto;
    background: var(--bg-primary);
    transition: background 0.3s ease;
}

/* ============================================
   HEADER (Sticky)
   ============================================ */

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    transition: background 0.3s ease, border 0.3s ease;
    padding: 32px 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ============================================
   CONTENT PADDING
   ============================================ */

.content {
    padding: 42px;
}

/* ============================================
   MOBILE SIDEBAR OVERLAY
   ============================================ */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 12, 17, 0.85); /* Slightly darker for better focus */
    z-index: 98; /* Below sidebar (100) but above header (10) */
    backdrop-filter: blur(2px); /* Subtle blur effect for modern browsers */
    -webkit-backdrop-filter: blur(2px); /* Safari support */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    pointer-events: none; /* Prevent clicks when hidden */
}

/* ============================================
   RESPONSIVE LAYOUT (Mobile)
   ============================================ */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%); /* Closed by default on mobile */
        width: 300px;
    }

    .sidebar.closed {
        transform: translateX(-100%);
    }

    /* Open state - sidebar visible */
    .sidebar:not(.closed) {
        transform: translateX(0);
    }

    /* Lock body scroll when sidebar is open on mobile */
    body.sidebar-open {
        overflow: hidden;
        position: fixed;
        width: 100%; /* Prevent layout shift when scrollbar disappears */
        top: 0;
        left: 0;
        right: 0;
    }

    .header {
        padding: 20px 24px;
    }

    .content {
        padding: 24px;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto; /* Enable clicks when visible */
    }

    /* Smooth sidebar animation on mobile */
    .sidebar {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Overlay fade-in animation */
    .sidebar-overlay {
        transition: opacity 0.3s ease-in-out;
        opacity: 0;
    }

    .sidebar-overlay.active {
        opacity: 1;
    }
}
