﻿/* ===== Header ===== */
.meli-header {
    width: 100%;
    background: #fff;
    border-bottom: 1px solid #ddd;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

    .meli-header .container {
        max-width: 1450px;
        margin: 0 auto;
        padding: 0 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

/* ===== Top Bar ===== */

.top-header-bar {
    background: #522474;
    padding: 8px 25px;
    color: #fff;
    font-family: 'IRANSans',sans-serif;
}

    .top-header-bar .container {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

/* right menu */

.right-menu {
    display: flex;
    gap: 22px;
}

    .right-menu a {
        color: #fff;
        text-decoration: none;
        font-size: 14px;
        display: inline-block; /* الزام برای transform */
        transition: transform .22s ease;
    }

        .right-menu a:hover {
            transform: scale(1.1); /* کمی بزرگ‌تر */

            color: #fff;
        }

/* icons */

.left-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .left-icons a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        background: rgba(255,255,255,.15);
        border-radius: 50%;
        color: #fff;
        font-size: 13px;
        transition: .2s;
    }

        .left-icons a:hover {
            background: rgba(255,255,255,.25);
        }

.flag {
    width: 32px;
    border-radius: 5px;
}

/* ===== Main Navigation ===== */

.nav-bar {
    display: flex;
    align-items: center;
    padding: 12px 20px;
}

.logo {
    height: 70px;
}

/* menu */

.menu {
    list-style: none;
    display: flex;
    gap: 28px;
    margin: 0 auto;
    padding: 0;
}

    .menu li {
        position: relative;
    }

        .menu li a {
            display: flex;
            align-items: center;
            gap: 6px;
            text-decoration: none;
            color: #444;
            font-size: 15px;
            font-weight: 500;
            transition: .2s;
        }

            .menu li a:hover {
                color: #522474;
            }

        .menu li .active {
            color: #522474;
            border-bottom: 3px solid #d4004a;
            padding-bottom: 4px;
        }

/* ===== Arrow ===== */

.arrow {
    width: 6px;
    height: 6px;
    border-right: 2px solid #444;
    border-bottom: 2px solid #444;
    transform: rotate(-45deg);
    transition: .25s;
}

/* ===== Submenu ===== */

.submenu {
    position: absolute;
    top: 130%;
    right: 0;
    background: #fff;
    list-style: none;
    padding: 8px 0;
    min-width: 200px;
    border-radius: 6px;
    box-shadow: 0 8px 25px rgba(0,0,0,.08);
    opacity: 0;
    visibility: hidden;
    transition: .25s;
    z-index: 1100;
}

    .submenu li a {
        display: block;
        padding: 9px 18px;
        font-size: 14px;
    }

        .submenu li a:hover {
            background: #f5f5f5;
        }

/* show submenu */

.has-sub:hover .submenu {
    top: 100%;
    opacity: 1;
    visibility: visible;
}

/* rotate arrow */

.has-sub:hover .arrow {
    transform: rotate(45deg);
}
.has-sub:hover > .submenu {
    top: 100%;
    opacity: 1;
    visibility: visible;
}

/* فلش هنگام هاور بچرخد */
.has-sub:hover > a .arrow {
    transform: rotate(45deg);
}
/* تنظیم زیرمنوی سطح دوم (از سمت چپ باز شود) */
.submenu .has-sub .submenu {
    top: 0;
    right: 100%;
    opacity: 0;
    visibility: hidden;
    transition: .25s;
}
/* نمایش زیرمنوی داخلی در هاور */
.submenu .has-sub:hover > .submenu {
    right: 100%;
    top: 0;
    opacity: 1;
    visibility: visible;
}
/* فلش مخصوص منوهای تو در تو */
.submenu .arrow {
    border-color: #888;
    transform: rotate(135deg); /* جهت چپ */
    margin-right: auto;
    margin-left: 10px;
}



/* ===== فلش عمومی ===== */
.arrow {
    width: 6px;
    height: 6px;
    border-right: 2px solid #444;
    border-bottom: 2px solid #444;
    transform: rotate(-45deg);
    transition: .25s;
    display: inline-block;
}

/* ===== فلش در منوی سطح اول ===== */
.has-sub:hover > a .arrow {
    transform: rotate(45deg);
}

/* ===== فلش در منوهای داخلی (جهت چپ) ===== */
.submenu .has-sub > a .arrow {
    transform: rotate(135deg);
}

/* در زمان هاور کمی رنگ فلش عوض شود */
.submenu .has-sub:hover > a .arrow {
    border-color: #522474;
}

/* ===== چیدمان زیرمنوی سطح دوم و سوم ===== */
.submenu {
    position: absolute;
    top: 130%;
    right: 0;
    background: #fff;
    list-style: none;
    padding: 8px 0;
    min-width: 200px;
    border-radius: 6px;
    box-shadow: 0 8px 25px rgba(0,0,0,.08);
    opacity: 0;
    visibility: hidden;
    transition: .25s;
    z-index: 0;
    margin:5px;
}

/* نمایش زیرمنوی سطح یک */
.has-sub:hover > .submenu {
    top: 100%;
    opacity: 1;
    visibility: visible;
}

/* زیرمنوی تو در تو از سمت چپ بیاد */
.submenu .submenu {
    top: 0;
    right: 100%;
}

/* نمایش زیرمنوی داخلی هنگام هاور */
.submenu .has-sub:hover > .submenu {
    opacity: 1;
    visibility: visible;
}

/* ظاهری برای آیتم‌ها */
.submenu li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 18px;
    font-size: 14px;
    color: #444;
    text-decoration: none;
}

    .submenu li a:hover {
        background: #f5f5f5;
        color: #522474;
    }
.menu li a,
.submenu li a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* همبرگر */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: 1200;
}

    .nav-toggle .bars {
        display: block;
        width: 25px;
        height: 3px;
        background-color: #444;
        margin: 5px 0;
        transition: 0.3s;
    }

    /* ضربدر همبرگر */
    .nav-toggle.open .bars:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .nav-toggle.open .bars:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.open .bars:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }


/* حالت موبایل */
@media (max-width: 991px) {
    .nav-toggle {
        display: block;
        position: absolute;
        top: 20px;
        right: 20px;
        z-index: 1200;
        background: none;
        border: none;
        cursor: pointer;
    }

    .menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 60px;
        right: 0;
        width: 250px;
        max-height: 80vh;
        overflow-y: auto;
        background: #fff;
        box-shadow: 0 8px 25px rgba(0,0,0,0.1);
        border-radius: 6px;
        z-index: 1100;
    }
}

/* ===============================
   FIX HEADER / DESKTOP / MOBILE MENU
================================ */

.main-nav .container {
    position: relative;
    max-width: 1450px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu,
.menu ul {
    list-style: none;
}




/* ---------- Mobile / Tablet ---------- */

@media (max-width: 991px) {
    .meli-header {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 5000;
    }

    .top-header-bar {
        display: none;
    }

    .main-nav .container {
        min-height: 76px;
        padding: 0 16px;
        direction: rtl;
    }

    .logo {
        height: 58px;
        margin-right: auto;
    }

    .nav-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        padding: 0px;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 12px;
        cursor: pointer;
        position: relative;
        z-index: 6000;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
        outline: none;
    margin:0px 2px 40px 10px;
     
    }
        .nav-toggle:focus,
        .nav-toggle:active {
            outline: none;
            box-shadow: none;
            background: #fff; /* جلوگیری از تغییر رنگ */
        }

        .nav-toggle .bars {
            display: block;
            width: 24px;
            height: 2px;
            margin: 3px 0;
            background: #522474;
            border-radius: 5px;
            transition: 0.3s ease;
        }

        .nav-toggle.open .bars:nth-child(1) {
            transform: rotate(45deg) translate(5px, 6px);
        }

        .nav-toggle.open .bars:nth-child(2) {
            opacity: 0;
            transform: translateX(10px);
        }

        .nav-toggle.open .bars:nth-child(3) {
            transform: rotate(-45deg) translate(5px, -6px);
        }

    .menu {
        display: block !important;
        position: absolute;
        top: 76px;
        right: 16px;
        left: 16px;
        width: auto;
        max-height: calc(100vh - 96px);
        overflow-y: auto;
        overflow-x: hidden;
        padding: 10px;
        margin: 0;
        background: #fff;
        border-radius: 16px;
        box-shadow: 0 18px 45px rgba(0, 0, 0, 0.16);
        z-index: 5500;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-12px);
        transition: 0.28s ease;
    }

        .menu.mobile-open {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transform: translateY(0);
        }

        .menu li {
            position: relative;
            width: 100%;
        }

            .menu li a {
                width: 100%;
                min-height: 46px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                gap: 12px;
                padding: 11px 14px;
                color: #333;
                font-size: 14px;
                font-weight: 500;
                text-decoration: none;
                border-radius: 12px;
                line-height: 1.8;
                white-space: normal;
                overflow: visible;
                text-overflow: unset;
                transition: 0.22s ease;
            }

                .menu li a:hover,
                .menu li.open > a {
                    background: #f7f3fa;
                    color: #522474;
                }

    /* در موبایل زیرمنوها absolute نباشند که روی هم نیفتند */
    .submenu,
    .submenu .submenu,
    .submenu .submenu .submenu {
        position: static !important;
        display: block;
        width: 100%;
        min-width: 0;
        max-width: none;
        height: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        margin: 0;
        padding: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        transition: max-height 0.32s ease, padding 0.32s ease;
        z-index: auto;
    }

    .has-sub.open > .submenu {
        height: auto;
        max-height: 1200px;
        padding: 4px 0 6px 0;
    }

    .submenu li a {
        font-size: 13.5px;
        background: #fafafa;
        margin: 3px 0;
        border-radius: 10px;
        padding-right: 24px;
    }

    .submenu .submenu li a {
        background: #f4f4f4;
        padding-right: 38px;
        font-size: 13px;
    }

    .submenu .submenu .submenu li a {
        background: #eeeeee;
        padding-right: 52px;
        font-size: 12.8px;
    }

    .arrow {
        width: 7px;
        height: 7px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        display: inline-block;
        flex: 0 0 auto;
        transform: rotate(45deg);
        transition: 0.25s ease;
    }

    .has-sub.open > a .arrow {
        transform: rotate(225deg);
    }
}