﻿/* nav.css 完整优化版 */
/* ==================== 头部样式 ==================== */
.site-header {
    background: #4d6fff;
    color: white;
    padding: 1.2rem 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: none;
    width: 100%;
    margin: 0 auto;
    flex-wrap: nowrap;
}

.site-title {
    font-size: 1.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    order: 1;
    cursor: pointer;
}

/* ==================== 导航系统 ==================== */
.nav-toggle {
    display: none;
    position: relative;
    z-index: 1002;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    order: 2;
    padding: 0 15px;
}

.nav-links {
    display: flex;
    gap: 25px;
    margin-left: auto;
    transition: all 0.3s ease;
    order: 3;
    position: relative;
}

    .nav-links a {
        color: white;
        text-decoration: none;
        opacity: 0.9;
        transition: opacity 0.3s;
        padding: 8px 12px;
    }

        .nav-links a:hover {
            opacity: 1;
            text-decoration: underline;
        }

.nav-link.level-3 {
    padding-left: 50px !important;
}

/* ==================== 多级菜单系统 ==================== */
.main-nav {
    display: flex;
    gap: 25px;
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #f8f9fa;
    border: 1px solid #eee;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
    margin-top: 5px;
    list-style: none;
    padding-left: 0;
}

    .submenu.level-0 {
        top: 100%;
        left: 0;
    }

    .submenu.level-1 {
        left: calc(100% - 1px);
        top: -5px;
    }

    .submenu.level-2 {
        left: auto;
        right: 100%;
        top: -8px;
    }

    .submenu.level-3 {
        left: 100%;
        top: 0;
    }

    .submenu li {
        position: relative;
    }

        .submenu li a {
            color: #333 !important;
            padding: 8px 20px !important;
            line-height: 1.3;
            display: block;
            transition: background 0.2s;
            white-space: nowrap;
        }

        .submenu li:hover > a {
            background: #e9ecef;
        }

.submenu-toggle {
    background: none;
    border: 0;
    padding: 0 8px;
    margin-left: auto;
}

    .submenu-toggle .fas {
        color: white !important;
        opacity: 0.8;
        transition: transform 0.3s;
    }

@media (min-width: 769px) {
    .has-children:hover > .submenu {
        display: block;
    }

    .nav-item {
        position: relative;
    }

    /* 智能定位修正 */
    .submenu {
        transition: opacity 0.2s;
    }
}

/* ==================== 移动端适配 ==================== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: row;
        align-items: center;
    }

    .nav-toggle {
        display: block !important;
        order: 2;
    }

    .site-title {
        max-width: calc(100% - 50px);
    }

    .nav-toggle i {
        transition: transform 0.3s;
    }

    .nav-toggle.active i {
        transform: rotate(90deg);
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        padding: 15px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

        .nav-links.active {
            display: flex !important;
            flex-direction: column;
        }

        .nav-links a {
            color: #2d3e50 !important;
            padding: 12px 20px !important;
            margin: 4px 0;
            display: flex;
            align-items: center;
            gap: 12px;
        }

            .nav-links a:hover {
                background: rgba(77,111,255,0.08);
            }

    .nav-item {
        position: relative;
        width: 100%;
    }

    .submenu {
        position: static !important;
        margin-left: 20px;
        width: auto !important;
        display: none;
        box-shadow: none;
        border: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        list-style: none;
        padding-left: 0;
    }

        .submenu.active {
            display: block !important;
            max-height: 1000px;
        }

        .submenu.level-1 {
            margin-left: 20px;
            border-left: 2px solid #ddd;
        }

        .submenu.level-2 {
            margin-left: 35px;
        }

    .nav-links .main-nav {
        flex-direction: column;
        width: 100%;
    }

    .submenu-toggle i {
        transition: transform 0.3s ease !important;
    }
}
