/* ---------------------------------------------------------
   K87 Custom Header
--------------------------------------------------------- */

body.k87-sticky-header {
    padding-top: 96px;
}

body.admin-bar.k87-sticky-header {
    padding-top: 128px;
}

body.woocommerce-checkout:not(.woocommerce-order-received).k87-sticky-header {
    padding-top: 0 !important;
}

.k87-site-header {
    position: fixed !important;
    top: 0;
    right: 0;
    left: 0;
    z-index: 99999;
    background: #ffffff;
    border-bottom: 1px solid #e6edf5;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body.admin-bar .k87-site-header {
    top: 32px;
}

.k87-header-shell {
    width: min(100% - 2rem, 1320px);
    margin-inline: auto;
    min-height: 76px;
    padding: 10px 4px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    direction: rtl;
}

.k87-header-start {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.k87-header-brand {
    min-width: 70px;
}

.k87-brand-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.k87-brand-link .custom-logo {
    width: auto;
    height: 56px;
    max-width: 120px;
    object-fit: contain;
}

.k87-brand-text {
    color: #0f172a;
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
}

.k87-header-nav {
    min-width: 0;
}

.k87-main-menu,
.k87-main-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.k87-main-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 3px;
}

.k87-main-menu > li {
    position: relative;
}

.k87-main-menu > li > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 999px;
    text-decoration: none;
    color: #0f172a;
    font-size: 15px;
    font-weight: 800;
    transition: all .2s ease;
    white-space: nowrap;
}

.k87-main-menu > li.current-menu-item > a,
.k87-main-menu > li.current-menu-ancestor > a {
    background: #eff6ff;
    color: #1d4ed8;
}

.k87-main-menu > li > a:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.k87-main-menu .menu-cat-thumb {
    display: none !important;
}

.k87-mobile-menu .menu-cat-thumb {
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    border-radius: 50%;
    object-fit: cover;
}

.k87-main-menu .sub-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 210px;
    background: #ffffff;
    border: 1px solid #e5ecf6;
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    padding: 8px;
    display: none;
    z-index: 20;
}

.k87-main-menu li:hover > .sub-menu {
    display: block;
}

.k87-main-menu .sub-menu li a {
    display: block;
    padding: 8px 10px;
    color: #1e293b;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 8px;
}

.k87-main-menu .sub-menu li a:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.k87-header-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.k87-currency-slot {
    display: inline-flex;
    align-items: center;
}

.k87-currency-slot .k87-btn {
    height: 42px;
    min-height: 42px;
    width: 42px;
    min-width: 42px;
    border-radius: 12px !important;
    border: 1px solid #d6dfeb !important;
    background: #ffffff !important;
    color: #1e3a8a !important;
    padding: 0 !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    transition: all .2s ease !important;
    cursor: pointer;
}

.k87-site-header .k87-currency-slot .k87-btn,
.k87-site-header .k87-header-icon-btn,
.k87-site-header .k87-menu-toggle,
.k87-site-header .k87-mobile-account,
.k87-site-header .k87-mobile-currency-trigger {
    border-radius: 12px !important;
}

.k87-currency-slot .k87-btn img {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    max-width: 14px !important;
    object-fit: contain !important;
}

.k87-currency-slot .k87-arr svg {
    width: 11px !important;
    height: 11px !important;
    display: block !important;
}

.k87-header-icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid #d6dfeb;
    background: #ffffff;
    color: #1e3a8a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all .2s ease;
    position: relative;
    padding: 0;
    cursor: pointer;
}

.k87-header-icon-btn:hover,
.k87-menu-toggle:hover,
.k87-search-close:hover {
    border-color: #1d4ed8;
    background: #eff6ff;
    color: #1d4ed8;
}

.k87-currency-slot .k87-btn:hover {
    border-color: #1d4ed8 !important;
    background: #eff6ff !important;
    color: #1d4ed8 !important;
}

.k87-header-icon-btn:focus,
.k87-header-icon-btn:focus-visible,
.k87-menu-toggle:focus,
.k87-menu-toggle:focus-visible,
.k87-mobile-account:focus,
.k87-mobile-account:focus-visible,
.k87-mobile-currency-trigger:focus,
.k87-mobile-currency-trigger:focus-visible,
.k87-currency-slot .k87-btn:focus,
.k87-currency-slot .k87-btn:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22) !important;
}

.k87-header-icon-btn:active,
.k87-menu-toggle:active,
.k87-search-close:active,
.k87-mobile-account:active,
.k87-mobile-currency-trigger:active,
.k87-currency-slot .k87-btn:active {
    transform: scale(.97);
}

.k87-header-icon-btn:active,
.k87-menu-toggle:active,
.k87-search-close:active {
    border-color: #1d4ed8;
    background: #eff6ff;
    color: #1d4ed8;
}

.k87-currency-slot .k87-btn:active {
    border-color: #1d4ed8 !important;
    background: #eff6ff !important;
    color: #1d4ed8 !important;
}

.k87-cart-count {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #1d4ed8;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    line-height: 20px;
    text-align: center;
}

.k87-menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid #d6dfeb;
    background: #ffffff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    margin-left: 8px;
    color: #1e3a8a;
    transition: all .2s ease;
}

.k87-menu-toggle span {
    width: 18px;
    height: 2px;
    background: currentColor;
    display: block;
    border-radius: 2px;
}

.k87-mobile-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: min(86vw, 340px);
    height: 100vh;
    background: #ffffff;
    box-shadow: -16px 0 28px rgba(15, 23, 42, 0.18);
    transition: right .22s ease;
    z-index: 100001;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    max-height: 100dvh;
}

.k87-mobile-panel.is-open {
    right: 0;
}

.k87-mobile-panel-inner {
    padding: 84px 16px 30px;
    direction: rtl;
    min-height: 100%;
}

.k87-mobile-menu,
.k87-mobile-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.k87-mobile-menu > li {
    border-bottom: 1px solid #edf2f8;
}

.k87-mobile-menu > li > a {
    display: block;
    text-decoration: none;
    color: #0f172a;
    padding: 13px 4px;
    font-weight: 800;
    font-size: 15px;
}

.k87-mobile-menu .sub-menu {
    padding-right: 12px;
    padding-bottom: 8px;
}

.k87-mobile-menu .sub-menu li a {
    display: block;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 0;
    text-decoration: none;
}

.k87-mobile-sep {
    width: 100%;
    height: 1px;
    background: #e6edf5;
    margin: 14px 0;
}

.k87-mobile-account {
    min-height: 44px;
    border: 1px solid #d6dfeb;
    border-radius: 12px;
    color: #1e293b;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.k87-mobile-currency-trigger {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d6dfeb;
    background: #ffffff;
    color: #1e293b;
    font-size: 13px;
    font-weight: 800;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}

.k87-mobile-currency-trigger-text {
    font-size: 13px;
    font-weight: 900;
}

.k87-mobile-currency-trigger-value {
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
}

.k87-mobile-currency-trigger svg {
    color: #64748b;
    flex-shrink: 0;
}

.k87-mobile-currency-modal {
    position: fixed;
    inset: 0;
    z-index: 100020;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s ease;
}

.k87-mobile-currency-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.k87-mobile-currency-modal-card {
    width: min(92vw, 420px);
    max-height: min(74vh, 520px);
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e5ecf6;
    border-radius: 18px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
    padding: 18px 14px 14px;
    direction: rtl;
    position: relative;
}

.k87-mobile-currency-close {
    position: absolute;
    left: 10px;
    top: 8px;
    width: 34px;
    height: 34px;
    border: 1px solid #e2e8f0;
    border-radius: 10px !important;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.k87-mobile-currency-close span {
    display: inline-block;
    font-size: 24px;
    line-height: 1;
    transform: translateY(-1px);
}

.k87-mobile-currency-close:focus,
.k87-mobile-currency-close:focus-visible,
.k87-search-close:focus,
.k87-search-close:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22) !important;
}

.k87-mobile-currency-modal-card h3 {
    margin: 0 0 12px;
    color: #0f172a;
    font-size: 20px;
    font-weight: 900;
}

.k87-mobile-currency-options {
    display: grid;
    gap: 8px;
}

.k87-mobile-currency-options a {
    min-height: 40px;
    border: 1px solid #d6dfeb;
    border-radius: 10px;
    padding: 0 10px;
    color: #1e293b;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 800;
}

.k87-mobile-currency-options a.is-active {
    border-color: #1d4ed8;
    background: #eff6ff;
    color: #1d4ed8;
}

.k87-mobile-currency-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    line-height: 1;
    color: #1e293b;
    font-size: 13px;
    font-weight: 800;
    padding: 0 10px;
    border: 1px solid #d6dfeb;
    border-radius: 10px;
}

.k87-mobile-overlay,
.k87-search-overlay,
.k87-currency-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.4);
    opacity: 0;
    transition: opacity .22s ease;
    z-index: 100000;
}

.k87-mobile-overlay.is-open,
.k87-search-overlay.is-open,
.k87-currency-overlay.is-open {
    opacity: 1;
}

.k87-search-modal {
    position: fixed;
    inset: 0;
    z-index: 100010;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 112px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .18s ease;
}

body.admin-bar .k87-search-modal {
    padding-top: 144px;
}

.k87-search-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.k87-search-modal-card {
    width: min(92vw, 560px);
    background: #ffffff;
    border: 1px solid #e5ecf6;
    border-radius: 20px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
    padding: 22px;
    direction: rtl;
    position: relative;
}

.k87-search-close {
    position: absolute;
    left: 10px;
    top: 8px;
    width: 42px;
    height: 42px;
    border: 1px solid #d6dfeb;
    border-radius: 12px !important;
    background: #ffffff;
    color: #1e3a8a;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all .2s ease;
}

.k87-search-close span {
    display: inline-block;
    font-size: 24px;
    line-height: 1;
    transform: translateY(-1px);
}

.k87-search-modal-card h3 {
    margin: 0 0 14px;
    color: #0f172a;
    font-size: 24px;
    font-weight: 900;
}

.k87-search-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 0;
    direction: rtl;
}

.k87-search-form {
    margin: 0;
}

.k87-search-input-wrapper {
    display: flex;
    align-items: center;
    background: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 5px 10px 5px 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: 0.3s ease;
}

.k87-search-input-wrapper:focus-within {
    background: #ffffff;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.1);
}

.k87-search-field {
    border: none !important;
    outline: none !important;
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    background: transparent;
    box-shadow: none !important;
    min-height: 0;
}

.k87-search-field:focus,
.k87-search-field:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.k87-search-submit {
    background: #2563eb;
    color: #ffffff;
    border: none;
    width: 45px;
    height: 45px;
    min-width: 45px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
    padding: 0;
}

.k87-search-submit .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
}

.k87-search-submit:hover {
    background: #1d4ed8;
    transform: scale(1.08);
    color: #ffffff !important;
}

body.k87-mobile-menu-open,
body.k87-search-open,
body.k87-currency-open {
    overflow: hidden;
}

/* Desktop: use side menu for sections + centered logo like mobile */
@media (min-width: 992px) {
    .k87-header-shell {
        width: calc(100% - 1rem);
        min-height: 76px;
        padding: 10px 6px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }

    .k87-header-start {
        min-width: 44px;
        z-index: 2;
    }

    .k87-header-brand {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 1;
        min-width: auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .k87-header-nav {
        display: none;
    }

    .k87-menu-toggle {
        display: inline-flex;
    }

    .k87-brand-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .k87-brand-link .custom-logo {
        display: block;
        height: 52px;
        max-width: 102px;
    }

    .k87-header-tools {
        z-index: 2;
    }
}

@media (max-width: 991px) {
    body.k87-sticky-header {
        padding-top: 78px;
    }

    body.admin-bar.k87-sticky-header {
        padding-top: 124px;
    }

    .k87-header-shell {
        width: calc(100% - 1rem);
        min-height: 62px;
        padding: 8px 2px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;
    }

    .k87-header-start {
        min-width: 44px;
        z-index: 2;
    }

    .k87-header-brand {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1;
    }

    .k87-brand-link .custom-logo {
        height: 42px;
        max-width: 88px;
    }

    .k87-header-nav {
        display: none;
    }

    .k87-currency-slot {
        display: none;
    }

    .k87-header-tools {
        gap: 6px;
        z-index: 2;
    }

    .k87-header-icon-btn,
    .k87-menu-toggle {
        width: 38px;
        height: 38px;
    }

    .k87-menu-toggle {
        display: inline-flex;
    }

    .k87-search-modal-card {
        width: calc(100% - 1rem);
        border-radius: 16px;
        padding: 18px 14px;
    }

    .k87-mobile-currency-modal-card {
        width: calc(100% - 1rem);
    }

    .k87-search-modal {
        padding-top: 88px;
    }

    .k87-search-modal-card h3 {
        font-size: 20px;
    }

    .k87-search-field {
        font-size: 14px;
        padding: 10px 14px;
    }

    .k87-search-submit {
        width: 42px;
        height: 42px;
        min-width: 42px;
    }
}

@media (max-width: 782px) {
    body.admin-bar .k87-site-header {
        top: 46px;
    }

    body.admin-bar .k87-search-modal {
        padding-top: 98px;
    }
}
