/**
 * Fixed Header Styles
 * Date: August 17, 2025
 * 
 * Makes the header fixed and unaffected by zoom scaling
 * Preserves all header functionality including search, theme toggle, and profile link
 */

/* ============================================
   FIXED HEADER POSITIONING
   ============================================ */

/* Override sticky positioning with fixed */
.header.header-fixed {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 9999; /* Higher than zoom controls (1000) and other elements */
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Ensure header content stays centered and constrained */
.header-fixed .header-content {
    max-width: 100%;
    padding: 0 2rem;
    margin: 0 auto;
}

/* ============================================
   CONTAINER ADJUSTMENTS
   ============================================ */

/* Add padding to container when header is fixed */
/* 1.5x spacing for better visual separation between header and content */
.container.with-fixed-header {
    padding-top: 105px; /* Header height (70px) + 35px breathing room */
    transform-origin: center 105px; /* Adjust transform origin to account for header + padding */
}

/* Ensure container still gets scaled properly */
.container {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SEARCH CONTAINER STYLES
   ============================================ */

/* Ensure search container stays functional */
.header-fixed .search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.header-fixed .search-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.header-fixed .search-icon {
    margin-right: 0.5rem;
    opacity: 0.5;
}

.header-fixed .search-input {
    border: none;
    background: none;
    outline: none;
    width: 200px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.header-fixed .search-input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   PROFILE & THEME TOGGLE
   ============================================ */

.header-fixed .profile-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    transition: all 0.2s;
    text-decoration: none;
}

.header-fixed .profile-link:hover {
    background: var(--bg-tertiary);
}

.header-fixed .theme-toggle {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-fixed .theme-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

[data-theme="dark"] .header-fixed {
    background-color: var(--bg-secondary);
    border-bottom-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .header-fixed .search-container {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .header-fixed .search-container:focus-within {
    border-color: var(--accent);
}

[data-theme="dark"] .header-fixed .theme-toggle {
    border-color: var(--border-color);
}

[data-theme="dark"] .header-fixed .theme-toggle:hover,
[data-theme="dark"] .header-fixed .profile-link:hover {
    background: var(--bg-tertiary);
}

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

@media (max-width: 768px) {
    .header-fixed .header-content {
        padding: 0 1rem;
    }
    
    .header-fixed h1 {
        font-size: 1.2rem;
    }
    
    .header-fixed .search-input {
        width: 120px;
    }
    
    .container.with-fixed-header {
        padding-top: 90px; /* Header height (60px) + 30px breathing room for mobile */
        transform-origin: center 90px;
    }
    
    html {
        scroll-padding-top: 90px; /* Mobile scroll padding adjustment */
    }
}

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

/* Smooth scroll adjustment for fixed header */
html {
    scroll-padding-top: 105px; /* Account for fixed header + padding when scrolling to anchors */
}

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

/*
    Z-Index Stack (low to high):
    - Content: 1
    - Draggable elements: 10
    - Sticky elements: 100
    - Floating panels: 999
    - Zoom controls: 1000
    - Modals: 2000
    - Fixed header: 9999
    - Toast notifications: 10000
*/

/* ============================================
   INTERACTION PRESERVATION
   ============================================ */

/* Ensure header doesn't interfere with drag & drop */
.header-fixed {
    pointer-events: auto;
}

.header-fixed * {
    pointer-events: auto;
}

/* Prevent header from capturing drag events meant for content below */
.header-fixed.dragging-active {
    pointer-events: none;
}

.header-fixed.dragging-active .header-controls > * {
    pointer-events: auto;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .header-fixed {
        position: relative !important;
        page-break-inside: avoid;
    }
    
    .container.with-fixed-header {
        padding-top: 0 !important;
    }
}