/* ============================================================
   Custom Header Injector – Popup & Inline Styles
   ============================================================ */

/* ---- Menu trigger items – fix alignment & underline ---- */

/* Remove ALL underlines, borders, shadows, pseudo-element lines */
li[class*="chi-trigger-"] a,
li[class*="chi-trigger-"] a:link,
li[class*="chi-trigger-"] a:visited,
li[class*="chi-trigger-"] a:hover,
li[class*="chi-trigger-"] a:focus,
li[class*="chi-trigger-"] a:active,
.menu-item[class*="chi-trigger-"] a,
.menu-item[class*="chi-trigger-"] a:hover,
.nav li[class*="chi-trigger-"] a,
.navbar-nav li[class*="chi-trigger-"] a,
.navbar-nav li[class*="chi-trigger-"] a:hover {
    text-decoration: none !important;
    border: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    background-image: none !important;
    outline: none !important;
}

/* Kill any pseudo-element underlines (many themes use ::before/::after for hover lines) */
li[class*="chi-trigger-"] a::before,
li[class*="chi-trigger-"] a::after,
.menu-item[class*="chi-trigger-"] a::before,
.menu-item[class*="chi-trigger-"] a::after {
    display: none !important;
    content: none !important;
    border: none !important;
    background: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* Fix vertical alignment – remove extra padding that causes the item to shift down */
li[class*="chi-trigger-"],
.menu-item[class*="chi-trigger-"] {
    display: flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
}

li[class*="chi-trigger-"] > a,
.menu-item[class*="chi-trigger-"] > a {
    display: inline-flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
}

/* ---- CHI items inside submenus – remove dropdown styling ---- */

/* Make the parent submenu container transparent and inline */
.sub-menu:has(> li[class*="chi-trigger-"]),
ul.sub-menu:has(> li[class*="chi-trigger-"]) {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    transform: none !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    pointer-events: auto !important;
    transition: none !important;
    clip: auto !important;
    height: auto !important;
    overflow: visible !important;
}

/* Reset the parent <li> hover dropdown behavior */
li.menu-item-has-children:has(> .sub-menu > li[class*="chi-trigger-"]) {
    position: relative;
}

li.menu-item-has-children:has(> .sub-menu > li[class*="chi-trigger-"]):hover > .sub-menu,
li.menu-item-has-children:has(> .sub-menu > li[class*="chi-trigger-"]):focus-within > .sub-menu {
    display: flex !important;
    position: static !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Remove sub-menu item styling (borders, padding) */
.sub-menu > li[class*="chi-trigger-"] {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: auto !important;
    min-width: 0 !important;
}

.sub-menu > li[class*="chi-trigger-"] > a {
    padding: 0 !important;
    margin: 0 !important;
    background: none !important;
    border: none !important;
}

/* Natural size popup – no max-width/max-height constraints */
.chi-popup.chi-natural-size {
    width: auto;
}

/* ---- Overlay ---- */
.chi-overlay {
    position: fixed;
    inset: 0;
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s ease;
}

.chi-overlay.chi-active {
    opacity: 1;
    visibility: visible;
}

/* ---- Popup container (for popup mode) ---- */
.chi-popup.chi-popup-mode {
    position: fixed;
    z-index: 999999;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.92);
    width: 92%;
    border-radius: 12px;
    box-shadow: 0 20px 64px rgba(0, 0, 0, .25);
    opacity: 0;
    visibility: hidden;
    transition: transform .35s cubic-bezier(.4, 0, .2, 1),
                opacity   .35s cubic-bezier(.4, 0, .2, 1),
                visibility .35s ease;
    overflow: hidden;
}

.chi-popup.chi-popup-mode.chi-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ---- Close button ---- */
.chi-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    background: rgba(0, 0, 0, .06);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

html[dir="rtl"] .chi-popup-close {
    right: auto;
    left: 10px;
}

.chi-popup-close:hover {
    background: rgba(0, 0, 0, .12);
    color: #000;
    transform: rotate(90deg);
}

.chi-popup-close:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ---- Popup inner body ---- */
.chi-popup-body {
    padding: 28px 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Limit scroll height if parent has max-height */
.chi-popup.chi-popup-mode .chi-popup-body {
    max-height: inherit;
}

/* Pretty scrollbar inside popup */
.chi-popup-body::-webkit-scrollbar { width: 6px; }
.chi-popup-body::-webkit-scrollbar-track { background: transparent; }
.chi-popup-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .15);
    border-radius: 3px;
}

/* ---- Inline mode ---- */
.chi-popup.chi-inline-mode {
    display: none;
    margin: 0 auto;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    position: relative;
    z-index: 100;
}

.chi-popup.chi-inline-mode.chi-active {
    display: block;
}

/* ============================================================
   Responsive – Mobile (≤ 600px)
   ============================================================ */
@media (max-width: 600px) {
    .chi-popup.chi-popup-mode {
        width: 96%;
        border-radius: 14px 14px 0 0;
        top: auto;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
    }

    .chi-popup.chi-popup-mode.chi-active {
        transform: translateX(-50%) translateY(0);
    }

    .chi-popup-body {
        max-height: 70vh;
        padding: 24px 16px 32px;
    }
}

/* ============================================================
   Accessibility – Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .chi-overlay,
    .chi-popup.chi-popup-mode,
    .chi-popup-close {
        transition: none !important;
    }
}

/* ============================================================
   Lock body scroll while popup is open
   ============================================================ */
body.chi-popup-open {
    overflow: hidden;
}
