/* ==========================================================================
   XIVOTEC MASTER HEADER - CLEAN SLATE
   Bypassing Divi's #main-header conflicts
   ========================================================================== */

/* 1. Header Container - Fixed & Dark Blue
   Higher Z-Index than Divi's defaults (9999) */
#xivotec-master-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 99999;
    background-color: var(--xivotec-primary, #002340) !important; /* Always Dark Blue with fallback */
    transition: background-color 0.4s ease-in-out, padding 0.4s ease, top 0.3s ease;
    padding: 15px 0; /* Adjusted for smaller height */
    border-bottom: 1px solid rgba(255,255,255,0.05); /* Subtle separator */
}

/* Admin Bar Compatibility */
body.admin-bar #xivotec-master-header {
    top: 0px;
}
@media screen and (max-width: 782px) {
    body.admin-bar #xivotec-master-header {
        top: 0px;
    }
}

/* Scrolled State */
#xivotec-master-header.is-scrolled {
    padding: 8px 0; /* Tighter on scroll */
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* 2. Inner Layout */
.xivotec-header-inner {
    max-width: 1400px; /* Adjust as needed */
    margin: 0 auto;
    padding: 0 40px 0 140px; /* Reserve space for the absolute logo on the left */
    display: flex;
    justify-content: center; /* Center nav horizontally (logo is absolute, left space reserved) */
    align-items: center;
    position: relative; /* Context for absolute items */
    height: auto; /* Allow header to grow when items stack vertically */
    min-height: 50px; /* Keep the reduced base height as minimum */
    flex-wrap: wrap; /* Let nav items wrap to multiple lines */
    gap: 8px; /* Small gap when items wrap */
}

/* 3. Absolute Logo (Top Left) */
.xivotec-logo {
    position: absolute;
    left: 80px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100000;
    display: block;
    line-height: 0;
}

.xivotec-logo img {
    height: 40px; /* Slightly smaller initial size */
    width: auto;
    transition: height 0.4s ease;
}

#xivotec-master-header.is-scrolled .xivotec-logo img {
    height: 32px; /* Smaller usage on scroll */
}

/* 4. Navigation Wrapper (Menu + CTA) */
.xivotec-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap; /* Support stacked/vertical items */
    width: 100%;
    justify-content: center; /* Center contents inside header-inner */
}

/* Desktop Menu Styles */
.xivotec-nav-desktop {
    flex: 1; /* take available space so CTA can sit at the right */
    display: flex;
    justify-content: center;
}

.xivotec-nav-desktop ul.xivotec-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 10px; /* Reduced gap to accommodate padding */
    flex-wrap: wrap; /* Allow menu items to wrap vertically if needed */
    align-items: center;
}

/* ----------------------- */
/* Kontakt CTA (glowing)  */
/* ----------------------- */
.xivotec-cta {
    /* Match .btn / .btn-primary from leistungen.css */
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 16px 32px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 1rem;
    cursor: pointer;
    background: var(--xivotec-accent);
    color: white;
    box-shadow: 0 0 20px rgba(12, 188, 219, 0.35);
    margin-left: 18px; /* spacing from menu */
}

.xivotec-cta:hover,
.xivotec-cta:focus {
    background: var(--xivotec-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 25px rgba(12, 188, 219, 0.5);
    outline: none;
}

@media (max-width: 980px) {
    .xivotec-cta { display: none; }
}

/* If WordPress outputs the CSS class on the <li> (common), style its child anchor */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta {
    /* Use .btn / .btn-primary styles for menu-inserted CTA */
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 16px 32px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 1rem;
    cursor: pointer;
    background: var(--xivotec-accent);
    color: white;
    box-shadow: 0 0 20px rgba(12, 188, 219, 0.35);
    margin-left: 18px;
}

.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a:hover,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta:hover,
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a:focus,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta:focus {
    background: var(--xivotec-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 25px rgba(12, 188, 219, 0.5);
    outline: none;
}

@media (max-width: 980px) {
    .xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
    .xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta {
        display: none !important; /* hide CTA in desktop area on small screens */
    }
}

.xivotec-nav-desktop ul.xivotec-menu li a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    font-family: inherit;
    
    /* Hover Animation Structure */
    display: inline-block;
    padding: 10px 16px; /* Create the "square" area */
    border-radius: 4px; /* Slightly rounded corners */
    position: relative; /* Context for the line */
    transition: background-color 0.3s ease;
}

/* Allow long labels to wrap instead of overflowing */
.xivotec-nav-desktop ul.xivotec-menu li a {
    white-space: normal;
}

/* Hover: White Transparent Background (exclude CTA items) */
.xivotec-nav-desktop ul.xivotec-menu li:not(.xivotec-cta) a:hover {
    background-color: rgba(255, 255, 255, 0.1); 
    color: #ffffff; /* Keep text white */
}

/* Hover: Bottom Line Animation (exclude CTA items) */
.xivotec-nav-desktop ul.xivotec-menu li:not(.xivotec-cta) a::after {
    content: '';
    position: absolute;
    bottom: 0px; /* Align to bottom of the padding box */
    left: 50%;
    transform: translateX(-50%);
    width: 0; /* Start hidden */
    height: 3px;
    background-color:var(--xivotec-accent); /* Red line matching reference */
    transition: width 0.3s ease;
}

.xivotec-nav-desktop ul.xivotec-menu li:not(.xivotec-cta) a:hover::after {
    width: 80%; /* Expand line */
}

/* 6. Mobile Trigger (Hamburger) */
.mobile_menu_trigger {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    z-index: 100001;
    padding: 5px;
}

.mobile_menu_trigger .line {
    display: block;
    width: 25px;
    height: 2px;
    background-color: #ffffff;
    transition: all 0.3s ease;
}

/* 7. Mobile Menu Overlay */
.xivotec-nav-mobile {
    position: fixed;
    top: 0;
    right: -100%; /* Hidden off-screen */
    width: 100%;
    height: 100vh;
    background-color: #002340;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: right 0.4s ease;
    z-index: 99998;
}

.xivotec-nav-mobile.is-active {
    right: 0;
}

.xivotec-mobile-menu {
    list-style: none;
    padding: 0;
    text-align: center;
}

.xivotec-mobile-menu li {
    margin: 20px 0;
}

.xivotec-mobile-menu li a {
    color: #ffffff;
    font-size: 24px;
    text-decoration: none;
}

/* 8. Responsiveness */
@media (max-width: 980px) {
    .xivotec-nav-desktop {
        display: none;
    }
    
    .mobile_menu_trigger {
        display: flex;
    }
}

/* ========================================================================== */
/* CTA refinement: smaller, pill radius, and isolate from nav hover effects   */
/* ========================================================================== */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta {
    margin-left: 12px; /* slight separation from menu items */
}

.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta {
    /* compact size to match other site buttons */
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--xivotec-accent);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(12, 188, 219, 0.28);
    transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

/* Remove nav link hover background and underline for CTA anchors */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a::after,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta::after {
    display: none;
    content: none;
}

.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a:hover,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta:hover,
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a:focus,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta:focus {
    background: var(--xivotec-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(12, 188, 219, 0.4);
    color: #ffffff;
}

/* Ensure CTA does not inherit the general .xivotec-nav-desktop li a padding */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta {
    padding-left: 20px !important;
    padding-right: 20px !important;
}

@media (max-width: 980px) {
    /* keep CTA hidden in desktop area on small screens */
    .xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
    .xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta {
        display: none !important;
    }
}

/* Final CTA tightening & robust overrides to avoid double-render / large size */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta {
    margin-left: 10px; /* subtle separation */
}

/* Force compact dimensions and remove potential duplicate decorations */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta {
    padding: 8px 18px !important;
    border-radius: 8px !important;
    font-size: 0.95rem !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
    background: var(--xivotec-accent) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 18px rgba(12,188,219,0.28) !important;
}

/* Suppress any li-level hover/transition so only the anchor animates */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta {
    transition: none !important;
}

.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta:hover {
    background: transparent !important;
}

.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta::after { display: none !important; content: none !important; }

/* Ensure the anchor keeps its CTA animation while parent li stays inert */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a {
    transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease !important;
}

/* Remove nav item underline / after pseudo specifically for CTA anchors */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a::after,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta::after,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta::after {
    display: none !important;
    content: none !important;
}

/* Prevent base nav:hover background from applying to CTA */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a:hover,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta:hover,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta:hover {
    background: var(--xivotec-accent-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 8px 26px rgba(12,188,219,0.36) !important;
    color: #ffffff !important;
}

/* If the menu outputs both a wrapper and an inner anchor with classes (duplicate nodes), hide the duplicate anchor inside the .menu-item-wrapper when present.
   This is defensive: if you still see two visible CTAs, paste the header HTML and I'll remove the correct duplicate server-side. */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta a.xivotec-cta + a.xivotec-cta { display: none !important; }

@media (max-width: 980px) {
    .xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
    .xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta,
    .xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta { display: none !important; }
}

/* 9. Critical Fixes for Divi */
/* Push content down so it's not hidden behind the fixed header */
body #page-container {
    
    margin-top: 0 !important;
}

/* On mobile/smaller screens where header might be smaller or different */
@media (max-width: 980px) {
    body #page-container {
        padding-top: 0px !important;
    }
}

/* Prevent Divi's default margin issues */
html {
    margin-top: 0 !important; 
}

/* Subtle white divider at bottom of header for separation */
#xivotec-master-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px; /* slightly lower to hide header's blue edge */
    height: 2px;
    background-color: var(--xivotec-accent);
    pointer-events: none;
}

/* ----------------------- */
/* Dropdown / Hover Menus  */
/* ----------------------- */

/* Ensure parent list items can position absolute submenus */
.xivotec-nav-desktop ul.xivotec-menu > li {
    position: relative;
}

/* Base submenu (nested ul) hidden by default */
.xivotec-nav-desktop ul.xivotec-menu li ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--xivotec-primary, #002340);
    padding: 18px;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 100002;
    min-width: 220px;
    color: #ffffff;
    list-style: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

/* Show submenu on hover (desktop) */
.xivotec-nav-desktop ul.xivotec-menu li:hover > ul {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Submenu items */
.xivotec-nav-desktop ul.xivotec-menu li ul li {
    margin: 0 0 6px 0;
}

.xivotec-nav-desktop ul.xivotec-menu li ul li a {
    display: block;
    padding: 6px 8px;
    color: #ffffff;
    font-size: 16px;
    white-space: normal;
}

/* Support multi-column / mega-style submenu using CSS Grid when many items exist */
.xivotec-nav-desktop ul.xivotec-menu li ul {
    display: none; /* keep hidden until hover */
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.xivotec-nav-desktop ul.xivotec-menu li ul .sub-column {
    display: flex;
    flex-direction: column;
}

/* Make sure hover dropdowns don't trigger on small screens (mobile uses overlay) */
@media (max-width: 980px) {
    .xivotec-nav-desktop ul.xivotec-menu li ul,
    .xivotec-nav-desktop ul.xivotec-menu li:hover > ul {
        display: none !important;
        opacity: 0 !important;
        transform: none !important;
    }
}

/* ==========================================================================
   Consolidated CTA class: `.xivotec-cta-btn`
   This single block contains all CTA styling. It is applied to anchors with
   the class `xivotec-cta-btn` and also to menu anchors produced as
   `li.xivotec-cta > a` so you only need one source of truth.
   ========================================================================== */
.xivotec-cta-btn,
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta {
    /* Copied exactly from .btn / .btn-primary in leistungen.css */
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 16px 32px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.3s !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    background: var(--xivotec-accent) !important;
    color: white !important;
    box-shadow: 0 0 20px rgba(12, 188, 219, 0.35) !important;
    margin-left: 18px !important;
}

.xivotec-cta-btn:hover,
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a:hover,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta:hover,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta:hover {
    background: var(--xivotec-accent-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 25px rgba(12, 188, 219, 0.5) !important;
}

/* Keep the li inert so only the anchor animates */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta {
    transition: none !important;
    background: transparent !important;
}

/* STRICT RESET: remove any visual styling from the <li> itself so only the
   anchor/button shows the CTA. This prevents the 'double button' effect. */
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    min-width: 0 !important;
    display: list-item !important;
}

.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta::before,
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta::after {
    display: none !important;
    content: none !important;
}

/* Remove underline/after pseudo for CTA targets */
.xivotec-cta-btn::after,
.xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a::after,
.xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta::after,
.xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta::after {
    display: none !important;
    content: none !important;
}

/* Mobile: keep CTA hidden in desktop area */
@media (max-width: 980px) {
    .xivotec-cta-btn,
    .xivotec-nav-desktop ul.xivotec-menu li.xivotec-cta > a,
    .xivotec-nav-desktop ul.xivotec-menu li > a.xivotec-cta,
    .xivotec-nav-desktop ul.xivotec-menu li > a.btn.xivotec-cta {
        display: none !important;
    }
}

/* Mobile: disable header animations */
@media (max-width: 980px) {
    #xivotec-master-header {
        transition: none !important;
    }

    #xivotec-master-header.is-scrolled {
        padding: 15px 0 !important;
        box-shadow: none !important;
    }

    .xivotec-logo img {
        transition: none !important;
    }

    #xivotec-master-header.is-scrolled .xivotec-logo img {
        height: 40px !important;
    }

    #xivotec-master-header::after {
        transition: none !important;
    }
}
