/* Custom Responsive Header Styles */
.crh-header-wrapper {
    width: 100%;
    z-index: 9999 !important;
    transition: background-color 0.3s ease;
    display: block;
    visibility: visible;
    opacity: 1;
    position: relative;
}

/* Sticky Header - Works with Elementor absolute positioning */
.crh-sticky {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    right: 0;
    width: 100vw !important;
    margin: 0 !important;
    z-index: 9999 !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    transform: translateY(0);
    display: block;
    visibility: visible;
    opacity: 1;
}

/* Hide header when scrolling down */
.crh-sticky.crh-hidden {
    transform: translateY(-100%);
}

.crh-sticky.crh-scrolled {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Fix for WordPress Admin Bar - Admin bar has z-index 99999, so stay below it */
body.admin-bar .crh-header-wrapper,
body.admin-bar .crh-sticky {
    z-index: 9999 !important;
}

body.admin-bar .crh-sticky {
    top: 32px !important;
}

@media screen and (max-width: 782px) {
    body.admin-bar .crh-sticky {
        top: 46px !important;
    }
}

.crh-container {
    width: 100%;
    max-width: 2560px; /* Increased to 2560px for 4k screens */
    margin: 0 auto;
    padding: 20px 50px; /* 20px top/bottom padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* Default Layout with CTA: Push menu to right */
.crh-container.crh-has-cta .crh-nav {
    margin-left: auto;
    margin-right: 30px;
}

/* Centered Layout: Reset margins */
.crh-layout-center.crh-has-cta .crh-nav {
    margin-left: 0;
    margin-right: 0;
}

/* Left Layout */
.crh-layout-left {
    justify-content: flex-start;
}

.crh-layout-left .crh-nav {
    margin-left: 40px; /* Space from logo */
}

.crh-layout-left .crh-cta {
    margin-left: auto; /* Push CTA to far right */
}

/* Left Layout Override for CTA logic */
.crh-layout-left.crh-has-cta .crh-nav {
    margin-left: 40px;
    margin-right: 0;
}

/* Left All Layout - Everything aligned left */
.crh-layout-left-all {
    justify-content: flex-start;
}

.crh-layout-left-all .crh-nav {
    margin-left: 40px; /* Space from logo */
}

.crh-layout-left-all .crh-cta {
    margin-left: 30px; /* Space from menu */
}

.crh-layout-left-all.crh-has-cta .crh-nav {
    margin-left: 40px;
    margin-right: 0;
}

/* Centered Layout */
.crh-layout-center {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.crh-layout-center .crh-logo {
    justify-self: start;
}

.crh-layout-center .crh-nav {
    justify-self: center;
}

.crh-layout-center .crh-cta {
    justify-self: end;
}

.crh-layout-center .crh-mobile-toggle {
    justify-self: end; /* Ensure toggle is on the right in mobile if grid is used */
}

/* CTA Button */
.crh-cta {
    display: block;
}

.crh-mobile-cta {
    display: none; /* Hidden on desktop */
}

/* Logo */
.crh-logo {
    position: relative;
    z-index: 2;
}

.crh-logo a {
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
    color: #333;
    text-transform: uppercase;
    display: flex;
    align-items: center;
}

.crh-custom-logo {
    height: 100px; /* Increased logo height */
    width: auto;
    min-width: 150px; /* Ensure it doesn't collapse */
    display: block;
    object-fit: contain;
}

/* Desktop Menu */
.crh-nav {
    display: flex;
    align-items: center;
}

.crh-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 30px;
}

.crh-menu li {
    position: relative;
}

.crh-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 16px;
    transition: color 0.3s ease;
}

.crh-menu a:hover {
    color: #0073aa; /* WordPress Blue or your brand color */
}

/* Dropdown (Submenus) - Desktop Only */
@media (min-width: 769px) {
    .crh-menu .sub-menu {
        position: absolute;
        top: 100%;
        left: 0;
        background: #fff;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        min-width: 200px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
        transition: all 0.3s ease;
        list-style: none;
        padding: 10px 0;
        border-radius: 4px;
        z-index: 10000;
        margin: 0;
    }

    .crh-menu li:hover > .sub-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.crh-menu .sub-menu li {
    padding: 0;
    display: block;
    width: 100%;
}

.crh-menu .sub-menu a {
    display: block;
    padding: 10px 20px;
    font-size: 14px;
    white-space: nowrap;
}

.crh-menu .sub-menu a:hover {
    background-color: #f5f5f5;
}

/* Ensure parent menu items with submenus are visible */
.crh-menu > li.menu-item-has-children {
    position: relative;
}

/* Add dropdown indicator (arrow) to parent items */
.crh-menu > li.menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 8px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    transition: transform 0.3s ease;
}

/* Rotate arrow when hovering - Desktop only */
@media (min-width: 769px) {
    .crh-menu > li.menu-item-has-children:hover > a::after {
        transform: rotate(180deg);
    }
}

/* Mobile Toggle */
.crh-mobile-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 6px;
}

.crh-bar {
    width: 25px;
    height: 3px;
    background-color: #333;
    transition: all 0.3s ease;
}

/* Stop animations during resize */
.crh-resize-stopper * {
    transition: none !important;
    animation: none !important;
}

/* Mobile Styles */
@media (max-width: 1024px) {
    /* Reset Grid/Flex Layouts for Mobile */
    .crh-layout-center,
    .crh-layout-left {
        display: flex;
        justify-content: space-between;
    }
    
    /* Hide CTA on mobile for now to avoid clutter */
    .crh-cta {
        display: none;
    }

    .crh-mobile-cta {
        display: block;
        margin-top: 30px;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .crh-mobile-toggle {
        display: flex;
        position: relative;
        z-index: 10001; /* Keep toggle above the full screen menu */
    }
    
    /* When menu is active, fix the toggle position */
    .crh-mobile-toggle.active {
        position: fixed;
    }

    .crh-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw; /* Ensure full viewport width */
        height: 100vh;
        background-color: #ffffff;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        z-index: 10000;
        margin: 0 !important; /* Reset any desktop margins */
        
        /* Base Hidden State */
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        
        /* Reset overrides */
        border-top: none;
        max-height: none;
        box-shadow: none;
        padding: 0;
    }

    .crh-nav.active {
        opacity: 1;
        visibility: visible;
    }

    /* Animation: Fade (Default) */
    .crh-anim-fade {
        transform: scale(0.95);
    }
    .crh-anim-fade.active {
        transform: scale(1);
    }

    /* Animation: Slide Down */
    .crh-anim-slide-down {
        transform: translateY(-100%);
    }
    .crh-anim-slide-down.active {
        transform: translateY(0);
    }

    /* Animation: Slide Right */
    .crh-anim-slide-right {
        transform: translateX(-100%);
    }
    .crh-anim-slide-right.active {
        transform: translateX(0);
    }

    /* Animation: Zoom */
    .crh-anim-zoom {
        transform: scale(0.5);
    }
    .crh-anim-zoom.active {
        transform: scale(1);
    }

    .crh-menu {
        flex-direction: column;
        width: 100%;
        gap: 25px;
        text-align: center;
    }

    .crh-menu li {
        width: auto;
        border-bottom: none;
    }

    .crh-menu a {
        display: block;
        padding: 5px;
        font-size: 24px !important; /* Larger font for full screen */
        font-weight: 600;
    }

    /* Mobile Submenu */
    .crh-menu .sub-menu {
        position: static;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        background-color: transparent;
        padding: 0;
        text-align: inherit;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        list-style: none;
        margin: 0;
    }
    
    .crh-menu .sub-menu.open {
        max-height: 500px;
        padding: 10px 0;
    }
    
    .crh-menu .sub-menu a {
        font-size: 18px !important;
        padding: 8px 5px !important;
    }
    
    /* Add arrow indicator for parent items on mobile */
    .crh-menu > li.menu-item-has-children > a::after {
        transform: rotate(0deg);
        transition: transform 0.3s ease;
    }
    
    .crh-menu > li.menu-item-has-children.submenu-open > a::after {
        transform: rotate(180deg);
    }

    /* Hamburger Animation */
    .crh-mobile-toggle.active .crh-bar:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    .crh-mobile-toggle.active .crh-bar:nth-child(2) {
        opacity: 0;
    }
    .crh-mobile-toggle.active .crh-bar:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
}
