/* =============================================
 * Header 组件样式
 * 通过 html-header/index.ftl 在 <head> 中加载，
 * 确保样式在任何 DOM 渲染前就绪，彻底消除 FOUC
 * ============================================= */

.header {
    position: fixed;
    top: 0;
    width: 100%;
    height: 64px;
    background-color: #f2f4fd;
    display: flex;
    z-index: 1002;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.05);
}

.header-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto;
    padding: 0 20px;
}

.header-left {
    display: flex;
    align-items: center;
    height: 34px;
}

.header-left a img {
    height: 34px;
}

.header-menu {
    display: flex;
    align-items: center;
    padding-left: 60px;
}

.header-menu-item {
    font-size: 16px;
    font-weight: 400;
    margin-right: 40px;
    transition: color 0.3s ease;
    position: relative;
    display: flex;
}

.header-menu-item a {
    color: #253858;
    cursor: pointer;
    display: block;
    text-decoration: none;
}

.header-menu-item a:hover {
    color: #0065ff;
    text-decoration: none;
}

.header-menu-badge-wrapper {
    position: relative;
    pointer-events: none;
}

.header-menu-badge {
    position: absolute;
    top: -0.7em;
    left: -0.3em;
    background-color: #df1d3f;
    color: #ffffff;
    font-size: clamp(0.62rem, 0.75vw, 0.74rem);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.4em;
    padding: 0 0.6em;
    border-radius: 9999px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
}

.header-right-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.vip-entrance-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #FFF7ED;
    transition: all 0.3s ease;
    text-decoration: none;
}

.vip-entrance-btn:hover {
    background-color: #FFEDD5;
    transform: translateY(-1px);
}

.vip-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-login-btn {
    font-size: 14px;
    color: white;
    background-color: #2a63f6;
    padding: 8px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.header-login-btn:hover {
    background-color: #1d4ed8;
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.header-user-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    cursor: default;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-circle {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2a63f6;
}

.header-user-wrapper {
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
}

.header-user-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* User Dropdown Styles */
.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 120px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    display: none;
    z-index: 1000;
    margin-top: 8px;
    border: 1px solid #e2e8f0;
}

/* Hover trigger */
.header-user-wrapper:hover .user-dropdown-menu {
    display: block;
}

/* Invisible bridge to prevent menu from closing when moving mouse from avatar to menu */
.header-user-wrapper::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px; /* Matches margin-top of dropdown */
}

.user-dropdown-item {
    display: block;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
    text-align: center;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background-color: #f3f4f6;
    color: #0065ff;
    text-decoration: none;
}

.user-dropdown-item.logout:hover {
    color: #df1d3f;
}

.hidden {
    display: none !important;
}

/* 下拉菜单样式 */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: #253858;
}

.dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-mega-menu {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #e5e7eb;
    display: none;
}

.dropdown-mega-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    display: none;
}

.dropdown:hover ~ .dropdown-mega-menu .dropdown-mega-container,
.dropdown-mega-menu:hover .dropdown-mega-container {
    display: none;
}

.dropdown-mega-content {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.dropdown-mega-cards {
    flex: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.dropdown-mega-card-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.dropdown-mega-card {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
}

.dropdown-mega-card:hover {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    color: inherit;
}

.dropdown-mega-card-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
}

.dropdown-mega-card-icon img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.dropdown-mega-card-info {
    flex: 1;
    min-width: 0;
}

.dropdown-mega-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.dropdown-mega-card-desc {
    font-size: 12px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dropdown-mega-article {
    flex: 1;
    background-color: #f8fafc;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.dropdown-mega-article-link {
    flex: 1;
    text-decoration: none;
    color: inherit;
    display: block;
}

.dropdown-mega-article-link:hover .dropdown-mega-article {
    background-color: #ffffff;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.dropdown-mega-article-header {
    margin-bottom: 16px;
}

.dropdown-mega-article-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}

.dropdown-mega-article-content {
    color: #475569;
    line-height: 1.6;
}

.dropdown-mega-article-content p {
    margin: 0 0 12px 0;
    font-size: 14px;
}

.dropdown-mega-article-content p:last-child {
    margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .dropdown-mega-content {
        flex-direction: column;
        gap: 30px;
    }

    .dropdown-mega-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dropdown-mega-container {
        padding: 20px;
    }

    .dropdown-mega-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .dropdown-mega-cards {
        grid-template-columns: 1fr;
    }
}
