/**
 * 顶部导航栏样式
 * 移植自 pro.meky.space 项目 exam/css/common_layout.css
 */

/* 顶部导航栏固定定位，页面内容整体下移 */
body {
    padding-top: 60px;
}

/* ==================== 顶部导航栏样式 ==================== */
.header-section {
    padding: 0 20px 0 0 !important;
    margin: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    /* 需高于文章页 #navbar 的 z-index:1000，否则下拉菜单会被导航栏遮挡 */
    z-index: 3000 !important;
    background: #fff !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
}

.top-navigation {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 20px;
    width: 100%;
}

.site-logo {
    flex-shrink: 0;
    margin: 0 50px 0 10px;
}

.site-logo img {
    display: block;
    width: auto;
    height: 50px;
}

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-menu li {
    position: relative;
}

.nav-menu li a {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 20px 12px;
    height: 100%;
    color: #000;
    text-decoration: none;
    font-size: 15px;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-menu li a:hover {
    background-color: #f5f9f9;
    color: #2D95FB;
    height: 100%;
    box-sizing: border-box;
    border-bottom: 3px solid #2D95FB;
}

.nav-menu li.active a {
    background-color: #f5f9f9;
    color: #2D95FB;
    height: 100%;
    box-sizing: border-box;
    border-bottom: 3px solid #2D95FB;
}

.nav-menu li.nav-active a {
    background-color: #f5f9f9;
    color: #2D95FB;
    font-weight: 500;
    height: 100%;
    box-sizing: border-box;
    border-bottom: 3px solid #2D95FB;
}

.nav-menu li a i {
    font-size: 16px;
}

.user-info-display {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #000;
    font-size: 14px;
    height: 32px;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 25px;
    flex-shrink: 0;
    margin-left: auto;
}

/* 下拉容器需相对定位，保证下拉菜单绝对定位的参照 */
.top-navigation .dropdown {
    position: relative;
}

.dropdown-menu.drp-mnu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    z-index: 1050;
    border: none;
    border-radius: 0;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    padding: 15px 0;
    margin-top: 0px;
    min-width: 240px !important;
    background: white;
    animation: slideDown 0.3s ease;
    display: none;
}

/* 顶部导航栏 - 课件分类下拉菜单（仅限导航菜单区，不影响右侧用户名下拉 .drp-mnu） */
/* 下拉容器 li 撑满顶栏高度，保证 top:100% 精确落在顶栏底部，不遮挡"课件"按钮 */
.top-navigation .nav-menu li.dropdown {
    align-self: stretch;
    display: flex;
    align-items: center;
}

.top-navigation .nav-menu li.dropdown > a {
    height: 100%;
    box-sizing: border-box;
}

.top-navigation .nav-menu .dropdown > .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3001;
    display: none;
    list-style: none;
    margin: 0;
    min-width: 160px;
    padding: 8px 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    /* 使用带水平位移的关键帧，避免动画期间丢失 translateX(-50%) 导致先偏右后靠左 */
    animation: slideDownCenter 0.3s ease;
}

.top-navigation .nav-menu .dropdown > .dropdown-menu li {
    margin: 0;
}

.top-navigation .nav-menu .dropdown > .dropdown-menu li a {
    display: block;
    padding: 12px 24px;
    height: auto;
    color: #333;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
    border-bottom: none;
    transition: all 0.2s ease;
}

.top-navigation .nav-menu .dropdown > .dropdown-menu li a:hover {
    background-color: #f5f9f9;
    color: #2D95FB;
}

/* 当前选中的科目：浅蓝底蓝字 */
.top-navigation .nav-menu .dropdown > .dropdown-menu li a.active,
.top-navigation .nav-menu .dropdown > .dropdown-menu li a.active:hover {
    background-color: #e8f3ff;
    color: #2D95FB;
    font-weight: 500;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 居中下拉菜单专用：关键帧保留 translateX(-50%)，动画过程始终保持水平居中 */
@keyframes slideDownCenter {
    from {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.dropdown-menu.drp-mnu li {
    margin: 0;
}

.dropdown-menu.drp-mnu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.dropdown-menu.drp-mnu li a:hover {
    background-color: #f5f9f9;
    color: #2D95FB;
}

.dropdown-menu.drp-mnu li a:active,
.dropdown-menu.drp-mnu li a:focus {
    background-color: #f5f9f9;
    color: #2D95FB;
}

.dropdown-menu.drp-mnu li a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.dropdown-menu.drp-mnu li:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

.profile_img {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: none;
    color: #4d94ff;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
    height: 35px;
    justify-content: center;
    font-size: 14px;
    text-decoration: none;
    border: none;
}

.profile_img span {
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #000;
}

.profile_img::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #4d94ff;
    margin-left: 5px;
    vertical-align: middle;
}

.login-link a {
    padding: 8px 20px;
    background-color: #4d94ff;
    color: white;
    text-decoration: none;
    border-radius: 25px;
    transition: background-color 0.3s ease;
}

.login-link a:hover {
    background-color: #66B1FF;
}

/* 顶部导航栏 - 移动端响应式 */
@media (max-width: 768px) {
    body {
        padding-top: 0;
    }

    .header-section {
        padding: 0 !important;
    }

    .top-navigation {
        flex-wrap: wrap;
        height: auto;
        min-height: 50px;
        padding: 8px 15px;
        gap: 8px;
    }

    .site-logo {
        order: 1;
        margin-right: 0;
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .site-logo img:first-child {
        height: 36px;
    }

    .site-logo img:last-child {
        height: 24px;
        margin-top: 6px;
    }

    .nav-menu {
        order: 2;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .nav-menu li a {
        padding: 6px 10px;
        font-size: 13px;
    }

    .nav-menu li.nav-active a {
        background-color: #8BC34A;
        color: white;
        font-weight: 500;
    }

    .user-actions {
        order: 3;
        gap: 8px;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .user-info-display {
        order: 1;
        height: auto;
        gap: 6px;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        width: 100%;
        padding: 4px 0;
        font-size: 12px;
    }

    .user-info-display span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
        display: inline-block;
    }

    .profile_img {
        order: 2;
        padding: 6px 10px;
        font-size: 12px;
        line-height: 1;
        width: auto;
        min-width: 90px;
        max-width: 130px;
        height: 32px;
        justify-content: center;
        align-items: center;
        border-radius: 18px;
        gap: 5px;
    }

    .profile_img span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        max-width: 100px;
        font-size: 12px;
    }

    .dropdown-menu.drp-mnu {
        min-width: 160px;
        margin-top: 5px;
        border-radius: 0;
        padding: 10px 0;
    }

    .dropdown-menu.drp-mnu li a {
        padding: 10px 18px;
        font-size: 13px;
    }
}
