﻿nav {
    text-align: right;
}

.nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav a {
    display: block;
    /*background: #795548;*/
    /*background: #253463;*/
    background: #008080;
    color: #fff;
    text-decoration: none;
    padding: .8em 0.8em;
    text-transform: uppercase;
    font-size: 100%;
    /*letter-spacing: 2px;*/
    position: relative;
    /*margin-left:10px;*/
}

.submenu ul {
    position: absolute;
    top: 100%;
    left: 0;
    display: none;
    z-index: 999;
    width: auto;
}

.submenu-level2 ul {
    position: absolute;
    top: 0;
    left: 10%;
    display: none;
    z-index: 999;
    width: auto;
}

.nav > li:hover > .submenu-level2 {
    display: block;
}



.submenu-level3 ul {
    position: absolute;
    top: 0;
    left: 100%;
    display: none !important;
    z-index: 999;
    width: auto;
}
 .submenu-level3 {
    display: none !important;
}

.submenu-level2 > ul > li:hover > .submenu-level3 {
    display: block !important;
}

.submenu-level2 > ul > li:not(:hover) .submenu-level3 {
    display: none !important;
}



.nav > li ul  ul {
    top: 0; /* اصلاح موقعیت زیرمنوهای دوم و سوم */
    left: 100%; /* باز کردن زیرمنوهای سوم از سمت راست */
    display: none; /* پنهان کردن زیرمنوها ابتدایی */
    position: absolute; /* تغییر position از relative به absolute */
}

.nav > li:hover > ul ul {
    display: block; /* نمایش زیرمنوها هنگام هاور روی عنصرهای مادر */
}


.nav {
    vertical-align: top;
    display: inline-block;
    box-shadow: 1px -1px -1px 1px #000, -1px 1px -1px 1px #fff, 0 0 6px 3px #fff;
    border-radius: 6px;
}

    .nav > li {
        float: right;
        border-bottom: 4px #aaa solid;
        position: relative;
    }

        .nav > li > ul {
            position: absolute;
            top: 100%;
            left: 0;
            display: none;
            z-index: 999;
            width: auto;
        }

        .nav > li ul {
            position: absolute; /* تغییر position از relative به absolute برای زیرمنوها */
            top: 100%; /* انتقال زیرمنوها به پایین ایتم‌های مادر */
            left: 0; /* تمایل به سمت چپ بودن زیرمنوها */
            display: none; /* پنهان کردن زیرمنوها ابتدایی */
            z-index: 999; /* تنظیم z-index بالا تا بالای دیگر المان‌ها قرار گیرند */
            width: auto; /* عرض خودکار برای زیرمنوها */
        }


        .nav > li > a {
            float: right !important;
        }

        .nav > li:hover, .nav > li:hover > a {
            border-bottom-color: orange;
        }

    .nav li:hover > a {
        color: orange;
    }

    .nav > li:first-child {
        border-radius: 4px 0 0 4px;
    }

        .nav > li:first-child > a {
            border-radius: 4px 0 0 0;
        }

    .nav > li:last-child {
        border-radius: 0 0 4px 0;
        margin-right: 0;
    }

        .nav > li:last-child > a {
            border-radius: 0 4px 0 0;
        }

    .nav li li a {
        margin-top: 1px;
    }

    .nav > li > a:first-child:nth-last-child(2):before {
        content: " ";
        position: absolute;
        height: 0;
        width: 0;
        border: 5px solid transparent;
        top: 50%;
        right: 5px;
    }

    .nav ul {
        position: absolute;
        white-space: nowrap;
        border-bottom: 5px solid orange;
        z-index: 1;
        left: -99999em;
    }

    .nav > li:hover > ul {
        left: auto;
        right: 0; /* باز شدن زیرمنوها از سمت راست */
        padding-top: 5px;
        min-width: 100%;
        display: block;
    }

    .nav > li ul ul {
        top: 0;
        left: 100%;
        display: none; /* تغییر در حالت نمایش */
        position: absolute;
    }

    .nav > li li ul {
        right: auto; /* اصلاح تنظیمات نمایش سطح دوم */
        left: 100%; /* باز شدن زیرمنوهای سطح سوم از سمت راست */
        display: none; /* پنهان کردن زیرمنوها ابتدایی */
        position: absolute;
        /*border-left: 1px solid #fff;*/
    }

    .nav > li li:hover > ul {
        left: auto;
        right: 100%; /* باز کردن زیرمنو از سمت راست */
        top: -1px;
    }

    .nav > li > a:first-child:nth-last-child(2):before {
        border-top-color: #aaa;
    }

    .nav > li:hover > a:first-child:nth-last-child(2):before {
        border: 5px solid transparent;
        border-bottom-color: orange;
        margin-top: -5px;
    }

    .nav li li > a:first-child:nth-last-child(2):before {
        border-left-color: #aaa;
        margin-top: -5px;
    }

    .nav li li:hover > a:first-child:nth-last-child(2):before {
        border: 5px solid transparent;
        border-right-color: orange;
        right: 10px;
    }
