/* Header layout */
.uk-navbar-container {
    padding: 0 20px;
}

/* KI-Tools Modal über dem Admin-Header halten */
#ki-tools-global-modal {
    z-index: 20000 !important;
}
#ki-tools-global-modal.uk-open {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
#ki-tools-global-modal .uk-modal-dialog {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    margin: 0 auto !important;
}

.header-navbar {
    min-height: 84px;
}

.header-desktop-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    column-gap: 28px;
    width: 100%;
}


.header-main-left {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    overflow: visible;
    flex: 1 1 0;        /* stretch to fill available grid cell */
    width: 100%;
}

.header-main-left .uk-navbar-nav {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 0;
    margin: 0;
    width: auto;
    flex: 1 1 auto;     /* allow nav to grow so margin-left:auto has space */
    gap: 0;
}

.header-main-left.header-main-left-nav-left .uk-navbar-nav {
    margin-left: 0;
    justify-content: flex-start;
    flex: 0 1 auto;
}

.header-main-left.header-main-left-nav-right .uk-navbar-nav {
    margin-left: auto;
    justify-content: flex-end;
    flex: 0 1 auto;
}

.header-main-left.header-main-left-nav-center .uk-navbar-nav {
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
    flex: 0 1 auto;
}

.header-main-left .uk-navbar-nav > li > a {
    padding-left: 8px;
    padding-right: 8px;
    text-transform: none;
}

.header-main-left .uk-navbar-nav > li {
    flex: 0 0 auto;
}


.header-main-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    margin-left: auto;
    flex: 0 0 auto;
}

.header-right-tools {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    width: max-content;
    max-width: max-content;
}

.header-icon-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.header-right-tools .uk-navbar-item {
    padding-left: 0;
    padding-right: 0;
    flex: 0 0 auto;
}

.header-search-item {
    margin: 0;
}

.header-search-form {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 220px;
    height: 24px;
    border: 1px solid #e5e5e5;
    background: #fff;
}

.header-search-icon {
    position: absolute;
    left: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.header-search-input {
    width: 100%;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 0 16px 0 50px;
    font: inherit;
    box-sizing: border-box;
}

.header-search-input:focus {
    outline: 0;
}

.header-right-tools .uk-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 6px;
}

.header-right-tools .uk-icon-link svg,
.header-right-tools .uk-navbar-toggle svg {
    width: 20px;
    height: 20px;
}

.navbar-logo {
    height: 40px;
    min-height: 40px;
    width: auto;
    max-height: none;
    flex: 0 0 auto;
    transition: filter 0.3s ease;
}

#theme-toggle {
    cursor: pointer;
}

.header-mobile-shell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    width: 100%;
}

@media (max-width: 1650px) {
    .header-desktop-shell {
        column-gap: 22px;
    }

    .header-main-left .uk-navbar-nav > li > a {
        padding-left: 7px;
        padding-right: 7px;
    }

    .header-search-form {
        width: 190px;
    }
}

@media (max-width: 1450px) {
    .header-desktop-shell {
        column-gap: 16px;
    }

    .header-main-left .uk-navbar-nav > li > a {
        padding-left: 6px;
        padding-right: 6px;
    }

    .header-search-form {
        width: 168px;
    }
}

@media (max-width: 1200px) {
    .header-right-tools {
        gap: 10px;
    }

    .header-icon-group {
        gap: 8px;
    }

    .header-search-form {
        width: 150px;
    }
}

/* ========================================================================
   MOBILE HEADER STYLES
   ======================================================================== */

/* Mobile Shell - Visible only on mobile */
.header-mobile-shell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    width: 100%;
    gap: 12px;
    padding: 0 15px;
    box-sizing: border-box;
    background: inherit;
}

/* Mobile Logo */
.header-mobile-shell .uk-navbar-item.uk-logo {
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

.header-mobile-shell .navbar-logo {
    height: 36px;
    min-height: 36px;
    width: auto;
}

/* Mobile Toggle Button */
.header-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: inherit;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-radius: 6px;
}

.header-mobile-toggle:hover {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme='dark'] .header-mobile-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
}

.header-mobile-toggle svg {
    width: 24px;
    height: 24px;
}

/* Mobile Search Wrap */
.mobile-header-search-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
    order: 1;
}

/* Mobile Search Form */
.mobile-header-search-form {
    width: 100%;
    height: 36px !important;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box !important;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.mobile-header-search-form:focus-within {
    border-color: var(--primary-color, #1e87f0) !important;
    box-shadow: 0 0 0 3px rgba(30, 135, 240, 0.15) !important;
}

[data-theme='dark'] .mobile-header-search-form {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

[data-theme='dark'] .mobile-header-search-form:focus-within {
    border-color: var(--primary-color, #1e87f0) !important;
    box-shadow: 0 0 0 3px rgba(30, 135, 240, 0.25) !important;
}

.mobile-header-search-form .header-search-icon {
    left: 12px !important;
    color: #999;
}

[data-theme='dark'] .mobile-header-search-form .header-search-icon {
    color: #888;
}

.mobile-header-search-form .header-search-input {
    width: 100% !important;
    height: 100% !important;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 0 12px 0 36px !important;
    font-size: 14px !important;
    box-sizing: border-box !important;
    color: inherit;
}

.mobile-header-search-form .header-search-input::placeholder {
    color: #999;
}

[data-theme='dark'] .mobile-header-search-form .header-search-input::placeholder {
    color: #888;
}

/* Mobile dropdown for search results */
#mobile-search-results-dropdown {
    width: calc(100vw - 30px);
    max-width: 400px;
    margin-top: 8px;
}

#mobile-search-results-list {
    max-height: 280px;
    overflow-y: auto;
}

/* ========================================================================
   RESPONSIVE BREAKPOINTS FOR MOBILE HEADER
   ======================================================================== */

/* Mobile breakpoint - matches PHP $bpMdMax which is max(768, 1024-1) = 1023px */
@media (max-width: 1023px) {
    .header-desktop-shell {
        display: none !important;
    }
    
    .header-mobile-shell {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 12px;
        padding: 0 15px;
        box-sizing: border-box;
    }
    
    .header-mobile-toggle {
        display: inline-flex !important;
        flex-shrink: 0;
    }
    
    .mobile-header-search-wrap {
        flex: 1;
        min-width: 0;
        position: relative;
        order: 1;
    }
    
    .mobile-header-search-form {
        width: 100% !important;
        height: 36px !important;
        padding: 0 8px !important;
        font-size: 13px !important;
        box-sizing: border-box !important;
    }
    
    .mobile-header-search-form .header-search-input {
        width: 100% !important;
        font-size: 13px !important;
        box-sizing: border-box !important;
        padding: 0 12px 0 36px !important;
    }
    
    /* Hide desktop logo, show mobile logo */
    .header-desktop-shell .uk-navbar-item.uk-logo {
        display: none !important;
    }
    
    .header-mobile-shell .uk-navbar-item.uk-logo {
        display: flex !important;
    }
    
    /* Mobile header specific styles */
    #mobile-header .header-mobile-shell {
        display: flex !important;
    }
    
    #mobile-header .header-desktop-shell {
        display: none !important;
    }
}

/* Small mobile devices (phones) */
@media (max-width: 480px) {
    .header-mobile-shell {
        padding: 0 10px;
        min-height: 56px;
    }
    
    .header-mobile-shell .navbar-logo {
        height: 32px;
        min-height: 32px;
    }
    
    .header-mobile-toggle {
        min-width: 36px;
        min-height: 36px;
        padding: 6px;
    }
    
    .header-mobile-toggle svg {
        width: 20px;
        height: 20px;
    }
    
    .mobile-header-search-form {
        height: 32px !important;
    }
}

/* Large mobile/Tablet landscape */
@media (min-width: 768px) and (max-width: 959px) {
    .header-mobile-shell {
        min-height: 64px;
    }
    
    .header-mobile-shell .navbar-logo {
        height: 38px;
        min-height: 38px;
    }
    
    .mobile-header-search-form {
        height: 38px !important;
    }
}

/* Touch devices optimizations */
@media (hover: none) and (pointer: coarse) {
    .header-mobile-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }
    
    .header-mobile-toggle svg {
        width: 24px;
        height: 24px;
    }
    
    .mobile-header-search-form {
        height: 40px !important;
        font-size: 14px !important;
    }
    
    .mobile-header-search-form .header-search-input {
        font-size: 14px !important;
    }
}

[data-theme='dark'] .navbar-logo {
    filter: brightness(0) invert(1);
}

/* ─── Tooltip / Dropdown z-index fix ──────────────────────────────────────────
   UIkit renders overlays at <body> level (tooltip default z-index: 1030).
   Admin sidebar: 1650, corner tab: 1660, statusbar sticky: 1500,
   quick-edit modal: 11020, modals: 20000.
   ──────────────────────────────────────────────────────────────────────────── */
.uk-drop,
.uk-dropdown,
.uk-navbar-dropdown {
    z-index: 1680 !important;
}

header .uk-navbar-dropdown.header-mega-full {
    width: 100vw !important;
    max-width: 100vw !important;
    left: 50% !important;
    right: auto !important;
    margin-left: 0 !important;
    transform: translateX(-50%) !important;
    box-sizing: border-box;
}

.uk-tooltip {
    z-index: 12050 !important;
    pointer-events: none;
}

/* Prevent the sticky wrapper and navbar from forming a stacking/clipping
   context that would cut off tooltips or dropdowns rendered inside it. */
.header-sticky-wrapper {
    overflow: visible !important;
}

.header-navbar.uk-navbar-container {
    overflow: visible !important;
}
