/* ==========================================
   Floating editorial navbar
   ========================================== */

.shop-navbar {
    --nav-ink: #203337;
    --nav-muted: #7a898b;
    --nav-accent: #087f78;
    --nav-line: #e5edec;

    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    padding: 12px 20px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    direction: rtl;
    font-family: "Vazirmatn", sans-serif;
}

.shop-navbar,
.shop-navbar * {
    box-sizing: border-box;
}

.shop-navbar a {
    text-decoration: none;
}

.shop-navbar button,
.shop-navbar input {
    font: inherit;
}

.shop-navbar button {
    cursor: pointer;
}

/* Main floating frame */

.shop-navbar .shop-navbar-inner {
    display: grid;
    grid-template-columns: 215px minmax(150px, 1fr) auto auto;
    grid-template-areas:
        "logo search user cart"
        "menu menu menu menu";
    align-items: center;
    gap: 0 18px;
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 18px 24px 0;
    border: 1px solid rgb(220 232 230 / 90%);
    border-radius: 22px;
    background: rgb(255 255 255 / 96%);
    box-shadow:
        0 12px 38px rgb(24 56 52 / 7%),
        0 2px 5px rgb(24 56 52 / 3%);
}

@supports (backdrop-filter: blur(18px)) {
    .shop-navbar .shop-navbar-inner {
        background: rgb(255 255 255 / 90%);
        backdrop-filter: blur(18px);
    }
}

.shop-navbar .shop-actions {
    display: contents;
}

/* Brand */

.shop-navbar .shop-logo {
    grid-area: logo;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: var(--nav-ink);
}

.shop-navbar .shop-logo-icon {
    display: grid;
    place-items: center;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 14px 14px 4px 14px;
    background: #203b3c;
    color: #b8f0d7;
    box-shadow: none;
    font-size: 23px;
    transform: none;
}

.shop-navbar .shop-logo-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.shop-navbar .shop-logo-title {
    color: var(--nav-ink);
    font-size: 20px;
    font-weight: 800;
    white-space: nowrap;
}

.shop-navbar .shop-logo-subtitle {
    color: var(--nav-muted);
    font-size: 10px;
}

/* Search */

.shop-navbar .shop-search {
    grid-area: search;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 650px;
    height: 47px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid #e7eeec;
    border-radius: 11px;
    background: #f4f7f6;
    box-shadow: none;
    transition:
        background 180ms ease,
        border-color 180ms ease;
}

.shop-navbar .shop-search:focus-within {
    border-color: #7fb9ab;
    background: #fff;
}

.shop-navbar .shop-search input {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0 4px;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--nav-ink);
    font-size: 12px;
}

.shop-navbar .shop-search input::placeholder {
    color: #8a9693;
}

.shop-navbar .shop-search button {
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--nav-accent);
    font-size: 18px;
}

/* Account and cart */

.shop-navbar .shop-user,
.shop-navbar .shop-login {
    grid-area: user;
}

.shop-navbar .shop-user {
    position: relative;
}

.shop-navbar .shop-user-button,
.shop-navbar .shop-login,
.shop-navbar .shop-cart-link,
.shop-navbar .shop-mobile-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 43px;
    height: 43px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--nav-ink);
    box-shadow: none;
    font-size: 23px;
}

.shop-navbar .shop-login {
    width: auto;
    min-width: 84px;
    padding-inline: 12px;
    border: 1px solid var(--nav-line);
    font-size: 12px;
    font-weight: 700;
}

.shop-navbar .shop-login i {
    font-size: 21px;
}

.shop-navbar .shop-cart-link {
    grid-area: cart;
    position: relative;
    width: 47px;
    background: #eaf4ef;
    color: #276954;
}

.shop-navbar .shop-cart-count {
    position: absolute;
    top: -4px;
    right: -4px;
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border: 2px solid #fff;
    border-radius: 6px;
    background: #203b3c;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.shop-navbar .shop-mobile-button {
    display: none;
}

/* Navigation row */

.shop-navbar .shop-menu {
    grid-area: menu;
    position: static;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
    max-height: none;
    margin: 17px 0 0;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--nav-line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    transform: none;
}

.shop-navbar .shop-menu-link,
.shop-navbar .shop-category-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-height: 53px;
    padding: 11px 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #637371;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: color 160ms ease;
}

.shop-navbar .shop-menu-link::after,
.shop-navbar .shop-category-button::after {
    position: absolute;
    right: 14px;
    bottom: 0;
    left: 14px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--nav-accent);
    content: "";
    transform: scaleX(0);
    transition: transform 180ms ease;
}

.shop-navbar .shop-menu-link > i,
.shop-navbar .shop-category-button > i:first-child {
    color: #82918e;
    font-size: 16px;
}

.shop-navbar .shop-category:first-of-type > .shop-category-button {
    color: #254d43;
    font-weight: 800;
}

.shop-navbar .shop-menu-chevron {
    margin-right: 3px;
    font-size: 9px;
    transition: transform 180ms ease;
}

.shop-navbar .shop-category-button[aria-expanded="true"]
.shop-menu-chevron {
    transform: rotate(180deg);
}

.shop-navbar .shop-menu-link[aria-current="page"],
.shop-navbar .shop-category-button[aria-expanded="true"] {
    color: var(--nav-accent);
}

.shop-navbar .shop-menu-link[aria-current="page"]::after,
.shop-navbar .shop-category-button[aria-expanded="true"]::after {
    transform: scaleX(1);
}

/* Dropdowns */

.shop-navbar .shop-category {
    position: relative;
}

.shop-navbar .shop-category-menu,
.shop-navbar .shop-user-menu {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    left: auto;
    z-index: 20;
    display: none;
    width: 285px;
    max-height: min(65vh, 520px);
    margin: 0;
    padding: 8px;
    border: 1px solid var(--nav-line);
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 18px 45px rgb(25 59 52 / 12%);
    overflow-y: auto;
    overscroll-behavior: contain;
    opacity: 1;
    visibility: visible;
    transform: none;
    scrollbar-width: thin;
    scrollbar-color: #c7d9d3 transparent;
}

.shop-navbar .shop-category:hover > .shop-category-menu,
.shop-navbar .shop-user:hover > .shop-user-menu {
    display: none;
}

.shop-navbar .shop-category > .shop-category-menu.show,
.shop-navbar .shop-user.open > .shop-user-menu {
    display: block;
}

.shop-navbar .shop-user-menu {
    right: auto;
    left: 0;
    width: 310px;
    max-width: calc(100vw - 24px);
}

.shop-navbar .shop-category-item,
.shop-navbar .shop-user-menu-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-height: 43px;
    padding: 10px;
    border-radius: 8px;
    color: #536862;
    font-size: 12px;
    line-height: 1.8;
}

.shop-navbar .shop-category-item {
    justify-content: space-between;
}

.shop-navbar .shop-category-item > span {
    display: flex;
    align-items: center;
    gap: 9px;
}

.shop-navbar .shop-category-item > i,
.shop-navbar .shop-user-menu-arrow {
    margin-right: auto;
    color: #a0afaa;
    font-size: 10px;
}

.shop-navbar .shop-user-menu-item > i:first-child {
    flex-shrink: 0;
    color: #80958c;
    font-size: 17px;
}

.shop-navbar .shop-category-empty {
    padding: 18px 10px;
    color: var(--nav-muted);
    font-size: 12px;
}

.shop-navbar .shop-category-divider,
.shop-navbar .shop-user-menu-divider {
    height: 1px;
    margin: 8px;
    background: var(--nav-line);
}

.shop-navbar .shop-user-menu-header {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 8px;
    padding: 12px 8px 16px;
    border-bottom: 1px solid var(--nav-line);
}

.shop-navbar .shop-user-menu-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 43px;
    width: 43px;
    height: 43px;
    border-radius: 12px;
    background: #eaf4ef;
    color: #33765f;
    font-size: 24px;
}

.shop-navbar .shop-user-menu-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.shop-navbar .shop-user-menu-title strong {
    overflow-wrap: anywhere;
    color: var(--nav-ink);
    font-size: 13px;
}

.shop-navbar .shop-user-menu-title span {
    color: var(--nav-muted);
    font-size: 10px;
}

.shop-navbar .logout-item,
.shop-navbar .logout-item > i:first-child {
    color: #c94d5a;
}

.shop-navbar :is(a, button):focus-visible {
    outline: 3px solid #5da992;
    outline-offset: 3px;
}

@media (hover: hover) {
    .shop-navbar .shop-menu-link:hover,
    .shop-navbar .shop-category-button:hover {
        color: var(--nav-accent);
    }

    .shop-navbar .shop-menu-link:hover::after,
    .shop-navbar .shop-category-button:hover::after {
        transform: scaleX(1);
    }

    .shop-navbar .shop-category-item:hover,
    .shop-navbar .shop-user-menu-item:hover {
        background: #f0f6f3;
        color: #246e56;
    }

    .shop-navbar .shop-user-button:hover,
    .shop-navbar .shop-login:hover {
        background: #f0f6f3;
    }

    .shop-navbar .logout-item:hover {
        background: #fff1f2;
        color: #be384b;
    }
}

/* Mobile */

@media (max-width: 950px) {
    .shop-navbar {
        padding: 8px 8px 0;
    }

    .shop-navbar .shop-navbar-inner {
        grid-template-columns: 37px minmax(0, 1fr) auto auto;
        grid-template-areas:
            "toggle logo user cart"
            "search search search search"
            "menu menu menu menu";
        gap: 10px 8px;
        padding: 12px;
        border-radius: 17px;
    }

    .shop-navbar .shop-mobile-button {
        grid-area: toggle;
        display: inline-flex;
        width: 37px;
        height: 37px;
        background: #f0f5f2;
        font-size: 23px;
    }

    .shop-navbar .shop-logo {
        gap: 8px;
    }

    .shop-navbar .shop-logo-icon {
        flex-basis: 34px;
        width: 34px;
        height: 34px;
        border-radius: 10px 10px 3px 10px;
        font-size: 18px;
    }

    .shop-navbar .shop-logo-title {
        font-size: 15px;
    }

    .shop-navbar .shop-logo-subtitle {
        font-size: 8px;
    }

    .shop-navbar .shop-user-button,
    .shop-navbar .shop-cart-link {
        width: 37px;
        height: 37px;
        font-size: 20px;
    }

    .shop-navbar .shop-login {
        min-width: 0;
        width: 37px;
        height: 37px;
        padding: 0;
    }

    .shop-navbar .shop-login span {
        display: none;
    }

    .shop-navbar .shop-search {
        max-width: none;
        height: 42px;
        border-radius: 9px;
    }

    .shop-navbar .shop-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
        max-height: calc(100dvh - 165px);
        margin: 0;
        padding-top: 8px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .shop-navbar .shop-menu.active {
        display: flex;
    }

    .shop-navbar .shop-menu-link,
    .shop-navbar .shop-category-button {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 8px;
        font-size: 12px;
    }

    .shop-navbar .shop-menu-link::after,
    .shop-navbar .shop-category-button::after {
        display: none;
    }

    .shop-navbar .shop-menu-link[aria-current="page"],
    .shop-navbar .shop-category-button[aria-expanded="true"] {
        background: #edf5f0;
    }

    .shop-navbar .shop-menu-chevron {
        margin-right: auto;
    }

    .shop-navbar .shop-category-menu {
        position: static;
        width: 100%;
        max-height: 260px;
        margin: 5px 0;
        padding: 5px;
        border-radius: 10px;
        background: #f7faf8;
        box-shadow: none;
    }

    .shop-navbar .shop-user-menu {
        top: calc(100% + 12px);
        left: -45px;
        max-height: calc(100dvh - 110px);
    }
}

@media (max-width: 380px) {
    .shop-navbar .shop-navbar-inner {
        gap: 9px 5px;
        padding: 10px;
    }

    .shop-navbar .shop-logo-icon {
        display: none;
    }

    .shop-navbar .shop-logo-title {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shop-navbar *,
    .shop-navbar *::before,
    .shop-navbar *::after {
        transition: none !important;
        animation: none !important;
    }
}
@media (max-width: 950px) {

    /* گزینه‌های اصلی زیر هم */
    .shop-navbar .shop-menu.active {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .shop-navbar .shop-menu > .shop-menu-link,
    .shop-navbar .shop-menu > .shop-category {
        display: block;
        flex: 0 0 auto;
        width: 100%;
    }

    .shop-navbar .shop-menu > .shop-menu-link,
    .shop-navbar .shop-category-button {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        width: 100%;
        min-height: 46px;
    }

    .shop-navbar .shop-menu-chevron {
        margin-right: auto;
    }

    /* زیرمنو درست زیر گزینه خودش باز شود */
    .shop-navbar .shop-category > .shop-category-menu {
        position: static;
        inset: auto;
        width: 100%;
        max-height: none;
        margin: 5px 0 8px;
        padding: 6px 12px 6px 6px;
        border: 0;
        border-right: 2px solid #c7dfd4;
        border-radius: 0 0 10px 10px;
        background: #f7faf8;
        box-shadow: none;
        overflow: visible;
        transform: none;
    }

    .shop-navbar .shop-category > .shop-category-menu.show {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .shop-navbar .shop-category-item {
        display: flex;
        flex: 0 0 auto;
        width: 100%;
        min-height: 43px;
        white-space: normal;
    }
}

@media (max-width: 950px) {

    /* جلوگیری از بیرون‌زدگی ستون منو */
    .shop-navbar .shop-navbar-inner {
        min-width: 0;
    }

    /* منوی بسته */
    .shop-navbar #shopMenu {
        display: none !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        white-space: normal !important;
    }

    /* منوی باز: هر گزینه یک ردیف */
    .shop-navbar #shopMenu.active {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 5px !important;
        max-height: calc(100dvh - 165px);
        overflow-y: auto !important;
    }

    .shop-navbar #shopMenu > * {
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
    }

    .shop-navbar #shopMenu > .shop-menu-link,
    .shop-navbar #shopMenu .shop-category-button {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        min-height: 46px;
        white-space: normal !important;
    }

    .shop-navbar #shopMenu .shop-category {
        display: block !important;
        position: relative !important;
    }

    .shop-navbar #shopMenu .shop-menu-chevron {
        margin-right: auto !important;
    }

    /* زیرمنوها هم زیر گزینه مربوطه باز شوند */
    .shop-navbar #shopMenu .shop-category-menu {
        display: none !important;
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        max-height: none !important;
        margin: 5px 0 8px !important;
        padding: 6px 12px 6px 6px !important;
        border: 0;
        border-right: 2px solid #c7dfd4;
        border-radius: 0 0 10px 10px;
        background: #f7faf8;
        box-shadow: none !important;
        overflow: visible !important;
        transform: none !important;
    }

    .shop-navbar #shopMenu .shop-category-menu.show {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px;
    }

    .shop-navbar #shopMenu .shop-category-item {
        display: flex !important;
        width: 100% !important;
        min-width: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .shop-navbar #shopMenu .shop-category-item > span {
        min-width: 0;
    }
}
