/**
 * Vikrun Core - Header/Search Module v1.3.1
 * Fully isolated search styling.
 *
 * Fix:
 * - Elementor nav/menu was visually above the search dropdown.
 * - Old theme CSS still targeted .searched_item / .header_last_searched.
 *
 * Rule:
 * - New markup uses only vk-* classes.
 * - No header * selector.
 * - No global input[type=search] selector.
 */

body.vikrun-core-header-search-enabled .elementor-location-header,
body.vikrun-core-header-search-enabled .site-header {
    overflow: visible;
}

/* Raise the whole header stacking context only while Vikrun search is open. */
body.vikrun-core-header-search-enabled.vikrun-search-active .elementor-location-header,
body.vikrun-core-header-search-enabled.vikrun-search-active .site-header,
body.vikrun-core-header-search-enabled .elementor-location-header:has(#rb_header_search.vk-is-active),
body.vikrun-core-header-search-enabled .site-header:has(#rb_header_search.vk-is-active) {
    position: relative !important;
    z-index: 99990 !important;
    overflow: visible !important;
}

/*
 * Raise every Elementor ancestor that contains the search form.
 * This is needed because Elementor containers/widgets can create their own stacking contexts.
 */
body.vikrun-core-header-search-enabled .elementor-element:has(#rb_header_search.vk-is-active),
body.vikrun-core-header-search-enabled .elementor-widget-shortcode:has(#rb_header_search.vk-is-active),
body.vikrun-core-header-search-enabled .vikrun-header-search-widget.vk-search-open {
    position: relative !important;
    z-index: 99995 !important;
    overflow: visible !important;
}

/* While search is open, keep desktop nav lower than the dropdown. */
body.vikrun-core-header-search-enabled.vikrun-search-active .elementor-location-header .elementor-widget-nav-menu,
body.vikrun-core-header-search-enabled.vikrun-search-active .elementor-location-header .elementor-nav-menu--main,
body.vikrun-core-header-search-enabled.vikrun-search-active .elementor-location-header nav,
body.vikrun-core-header-search-enabled.vikrun-search-active .site-header .elementor-widget-nav-menu,
body.vikrun-core-header-search-enabled.vikrun-search-active .site-header .elementor-nav-menu--main,
body.vikrun-core-header-search-enabled.vikrun-search-active .site-header nav {
    position: relative;
    z-index: 20 !important;
}

/* Old custom menu layers should not cover the search results while search is open. */
body.vikrun-core-header-search-enabled.vikrun-search-active .vk-pro-menu,
body.vikrun-core-header-search-enabled.vikrun-search-active .vk-pro-floating-layer {
    z-index: 20 !important;
}

#rb_header_search.vk-header-search {
    position: relative !important;
    width: 100%;
    max-width: 100%;
    direction: rtl;
    z-index: 99996 !important;
    overflow: visible !important;
}

#rb_header_search.vk-header-search.vk-is-active {
    z-index: 99999 !important;
}

#rb_header_search .vk-header-search__field {
    position: relative;
    width: 100%;
    max-width: 100%;
}

#rb_header_search .vk-header-search__input {
    width: 100%;
    min-height: 46px;
    border: 1px solid #eeeeee;
    border-radius: 14px;
    padding: 0 48px 0 16px;
    background: #ffffff;
    color: #111111;
    font-size: 14px;
    font-weight: 600;
    line-height: 46px;
    box-shadow: none;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

#rb_header_search .vk-header-search__input::placeholder {
    color: #777777;
    font-size: 13px;
    font-weight: 500;
}

#rb_header_search:hover .vk-header-search__input,
#rb_header_search .vk-header-search__input:focus {
    border-color: #0ba5d5;
    background: #f7fbff;
    box-shadow: 0 0 0 4px rgba(11, 165, 213, .08);
}

/* `color` صریح لازم است: `reset.css`ِ پایه به دکمه/لینک رنگِ مجنتای `#c36` می‌دهد
   و هر آیکنِ `currentColor` در این دکمه صورتی می‌شد (همان نشتیِ شناخته‌شده). */
#rb_header_search .vk-header-search__button {
    color: var(--vk-ink, #111111);
    position: absolute;
    right: 15px;
    left: auto;
    top: 50%;
    z-index: 3;
    width: 22px;
    height: 22px;
    padding: 0 !important;
    margin: 0;
    border: 0;
    background: transparent;
    transform: translateY(-50%);
    cursor: pointer;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#rb_header_search .vk-header-search__button svg {
    display: block;
    width: 20px;
    height: 20px;
}

#rb_header_search.vk-is-loading .vk-header-search__field::after {
    content: "";
    position: absolute;
    left: 16px;
    top: 50%;
    width: 18px;
    height: 18px;
    border: 2px solid #dddddd;
    border-left-color: #111111;
    border-radius: 50%;
    transform: translateY(-50%);
    animation: vikrun-header-search-loading .8s infinite linear;
    z-index: 5;
}

@keyframes vikrun-header-search-loading {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

#header_search_result.vk-header-search__results {
    position: absolute !important;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 100000 !important;
    display: none;
    overflow: visible !important;
}

#rb_header_search.vk-is-active #header_search_result.vk-header-search__results,
#header_search_result.vk-header-search__results.active {
    display: block;
}

.vk-header-search-box {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e3e7ec;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(17, 17, 17, .12);
    overflow: hidden;
    isolation: isolate;
}

.vk-header-search-box__close {
    position: relative;
    width: 30px;
    height: 26px;
    margin-right: auto;
    margin-left: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #666666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vk-header-search-box__close span {
    font-size: 22px;
    line-height: 1;
}

.vk-header-search-box__list {
    max-height: 285px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-left: 4px !important;
    scrollbar-width: thin;
}

.vk-header-search-box__list::-webkit-scrollbar {
    width: 7px;
}

.vk-header-search-box__list::-webkit-scrollbar-track {
    background: #eeeeee;
}

.vk-header-search-box__list::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 999px;
}

.vk-header-search-item {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
    gap: 10px;
    padding: 10px 28px 10px 26px;
    border-bottom: 1px solid #eeeeee;
    color: #555555;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.7;
    overflow: hidden;
}

.vk-header-search-item:last-child {
    border-bottom: 0;
}

.vk-header-search-item:hover {
    color: #111111;
    background: #fafafa;
}

.vk-header-search-item::before {
    content: "";
    position: absolute;
    right: 4px;
    top: 50%;
    width: 18px;
    height: 18px;
    background-repeat: no-repeat;
    background-position: center;
    transform: translateY(-50%);
    opacity: .78;
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.5664 13.5664C13.8105 13.3224 14.2062 13.3224 14.4502 13.5664L18.0668 17.183C18.3108 17.4271 18.3108 17.8227 18.0668 18.0668C17.8227 18.3108 17.4271 18.3108 17.183 18.0668L13.5664 14.4502C13.3224 14.2062 13.3224 13.8105 13.5664 13.5664Z' fill='%23828282'/%3E%3Cpath d='M15.3333 9.29167C15.3333 5.95495 12.6284 3.25 9.29167 3.25C5.95495 3.25 3.25 5.95495 3.25 9.29167C3.25 12.6284 5.95495 15.3333 9.29167 15.3333C12.6284 15.3333 15.3333 12.6284 15.3333 9.29167ZM16.5833 9.29167C16.5833 13.3187 13.3187 16.5833 9.29167 16.5833C5.26459 16.5833 2 13.3187 2 9.29167C2 5.26459 5.26459 2 9.29167 2C13.3187 2 16.5833 5.26459 16.5833 9.29167Z' fill='%23828282'/%3E%3C/svg%3E");
}

.vk-header-search-item--category::before {
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7.70833 3.33333C7.70833 3.21827 7.61506 3.125 7.5 3.125H3.33333C3.21827 3.125 3.125 3.21827 3.125 3.33333V9.16667C3.125 9.28173 3.21827 9.375 3.33333 9.375H7.5C7.61506 9.375 7.70833 9.28173 7.70833 9.16667V3.33333ZM8.95833 9.16667C8.95833 9.97208 8.30542 10.625 7.5 10.625H3.33333C2.52792 10.625 1.875 9.97208 1.875 9.16667V3.33333C1.875 2.52792 2.52792 1.875 3.33333 1.875H7.5C8.30542 1.875 8.95833 2.52792 8.95833 3.33333V9.16667Z' fill='%23828282'/%3E%3Cpath d='M16.875 3.33333C16.875 3.21827 16.7817 3.125 16.6667 3.125H12.5C12.3849 3.125 12.2917 3.21827 12.2917 3.33333V5.83333C12.2917 5.94839 12.3849 6.04167 12.5 6.04167H16.6667C16.7817 6.04167 16.875 5.94839 16.875 5.83333V3.33333ZM18.125 5.83333C18.125 6.63875 17.4721 7.29167 16.6667 7.29167H12.5C11.6946 7.29167 11.0417 6.63875 11.0417 5.83333V3.33333C11.0417 2.52792 11.6946 1.875 12.5 1.875H16.6667C17.4721 1.875 18.125 2.52792 18.125 3.33333V5.83333Z' fill='%23828282'/%3E%3Cpath d='M16.875 10.8333C16.875 10.7183 16.7817 10.625 16.6667 10.625H12.5C12.3849 10.625 12.2917 10.7183 12.2917 10.8333V16.6667C12.2917 16.7817 12.3849 16.875 12.5 16.875H16.6667C16.7817 16.875 16.875 16.7817 16.875 16.6667V10.8333ZM18.125 16.6667C18.125 17.4721 17.4721 18.125 16.6667 18.125H12.5C11.6946 18.125 11.0417 17.4721 11.0417 16.6667V10.8333C11.0417 10.0279 11.6946 9.375 12.5 9.375H16.6667C17.4721 9.375 18.125 10.0279 18.125 10.8333V16.6667Z' fill='%23828282'/%3E%3Cpath d='M7.70833 14.1667C7.70833 14.0516 7.61506 13.9583 7.5 13.9583H3.33333C3.21827 13.9583 3.125 14.0516 3.125 14.1667V16.6667C3.125 16.7817 3.21827 16.875 3.33333 16.875H7.5C7.61506 16.875 7.70833 16.7817 7.70833 16.6667V14.1667ZM8.95833 16.6667C8.95833 17.4721 8.30542 18.125 7.5 18.125H3.33333C2.52792 18.125 1.875 17.4721 1.875 16.6667V14.1667C1.875 13.3613 2.52792 12.7083 3.33333 12.7083H7.5C8.30542 12.7083 8.95833 13.3613 8.95833 14.1667V16.6667Z' fill='%23828282'/%3E%3C/svg%3E");
}

.vk-header-search-item--product::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 50%;
    width: 18px;
    height: 18px;
    background-repeat: no-repeat;
    background-position: center;
    transform: translateY(-50%);
    opacity: .78;
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.20801 14.1667V5.83334C5.20801 5.48817 5.48783 5.20834 5.83301 5.20834H14.1663C14.5115 5.20834 14.7913 5.48817 14.7913 5.83334C14.7913 6.17852 14.5115 6.45834 14.1663 6.45834H6.45801V14.1667C6.45801 14.5119 6.17819 14.7917 5.83301 14.7917C5.48783 14.7917 5.20801 14.5119 5.20801 14.1667Z' fill='%23666666'/%3E%3Cpath d='M5.39111 5.39145C5.63519 5.14737 6.03082 5.14737 6.2749 5.39145L14.6082 13.7248C14.8523 13.9689 14.8523 14.3645 14.6082 14.6086C14.3642 14.8526 13.9685 14.8526 13.7244 14.6086L5.39111 6.27524C5.14704 6.03116 5.14704 5.63553 5.39111 5.39145Z' fill='%23666666'/%3E%3C/svg%3E");
}

.vk-header-search-item span {
    display: block;
    min-width: 0;
    max-width: 100%;
    padding: 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vk-header-search-box__empty {
    padding: 18px 12px;
    color: #666666;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

@media (max-width: 991px) {
    #rb_header_search .vk-header-search__input {
        min-height: 44px;
        line-height: 44px;
        padding-right: 44px;
    }

    #header_search_result.vk-header-search__results {
        top: calc(100% + 5px);
    }

    .vk-header-search-box {
        border-radius: 14px;
        padding: 10px;
    }

    .vk-header-search-box__list {
        max-height: 265px;
    }
}

@media (max-width: 620px) {
    #rb_header_search { width: 100%; }
    #rb_header_search .vk-header-search__input {
        font-size: 13px;
        min-height: 40px;
        line-height: 40px;
    }
    #header_search_result.vk-header-search__results {
        border-radius: 14px;
        max-height: 240px;
    }
    .vk-header-search-box { padding: 8px; }
    .vk-header-search-box__item { padding: 9px 10px; font-size: 12.5px; }
}
