// 导入全局样式变量
@import '@/styles/variables.scss';

.header {
    width: 100%;
    height: $header-height;
    padding: 0 $spacing-6;
    background: rgba($bg-secondary, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba($border-base, 0.5);
    box-shadow: $shadow-sm;
    position: fixed;
    top: 0;
    left: 0;
    z-index: $z-index-fixed;
    transition: $transition-base;

    &.scrolled {
        background: $bg-secondary;
        box-shadow: $shadow-md;
    }

    // 汉堡菜单按钮（移动端）
    .mobile-menu-btn {
        display: none;  // 默认隐藏
        font-size: 20px;
        color: $text-primary;
        margin-right: $spacing-2;
        padding: $spacing-2;
        border: none;
        background: transparent;
        cursor: pointer;
        transition: all 0.2s ease;

        &:hover {
            background: $bg-tertiary;
            border-radius: $radius-md;
        }

        @media (max-width: 768px) {
            display: block;  // 移动端显示
        }
    }

    &-container {
        display: flex;
        align-items: center;
        justify-content: space-between;  // 两端对齐
        width: 100%;  // 占满宽度
        gap: $spacing-6;
    }

    // Logo 区域 + 智能问答 wrapper
    &-logo-wrapper {
        display: flex;
        align-items: center;
        gap: $spacing-5;
        flex-shrink: 0;
    }

    // Logo 区域
    &-logo-section {
        display: flex;
        align-items: center;
        cursor: pointer;
        gap: $spacing-3;
        min-width: 240px;  // 桌面端最小宽度
        flex-shrink: 0;  // 不允许收缩
        transition: $transition-base;

        &:hover {
            transform: translateX($spacing-1);
        }

        .logo-image {
            height: $spacing-9;  // 固定高度
            width: auto;   // 宽度自适应
            object-fit: contain;
            flex-shrink: 0;
        }
        
        // Logo 图形与文字之间的竖线间隔
        .logo-divider {
            width: 1px;
            height: $font-xl;
            background: $border-base;  // 浅灰色
            flex-shrink: 0;
        }

        .logo-text-section {
            display: flex;
            flex-direction: column;
            gap: $spacing-1;

            .logo-title {
                font-size: $font-xl;
                font-weight: $font-weight-bold;
                color: $text-primary;
                margin: 0;
                white-space: nowrap;  // 不换行
            }

            .logo-subtitle {
                font-size: 10px;  // 副标题字体减小
                font-weight: $font-weight-semibold;
                color: $primary-light;
                text-transform: uppercase;
                letter-spacing: 0.1em;
                margin: 0;
            }
        }
    }
    
    // 平板端（≤1024px）样式调整
    @media (max-width: $screen-lg) {
        &-logo-section {
            min-width: 180px;  // 平板端最小宽度减小
            
            .logo-image {
                height: $font-xl;  // 平板端保持
            }
        }
        
        // 平板端隐藏智能问答按钮
        .quick-access-btn {
            display: none;
        }
    }
    
    // 移动端（≤768px）样式调整
    @media (max-width: $screen-md) {
        &-logo-section {
            min-width: 140px;  // 移动端最小宽度更小
            
            .logo-image {
                height: $spacing-8;  // 移动端稍微减小
            }
            
            .logo-title {
                font-size: $font-lg;  // 标题字体减小
            }
            
            .logo-subtitle {
                font-size: 10px;  // 副标题字体减小
            }
        }
    }

    // 右侧功能区
    &-right {
        display: flex;
        align-items: center;
        gap: $spacing-5;
        margin-left: auto;
    }

    // 搜索框 - 已注释
    // .header-search {
    //     position: relative;
    //     width: 400px;
    //     max-width: 100%;

    //     .search-icon {
    //         position: absolute;
    //         left: 16px;
    //         top: 50%;
    //         transform: translateY(-50%);
    //         font-size: 20px;
    //         color: $text-hint;
    //         pointer-events: none;
    //     }

    //     .search-input {
    //         width: 100%;
    //         height: 40px;
    //         padding: 0 16px 0 48px;
    //         background: rgba($bg-tertiary, 0.8);
    //         border: 1px solid transparent;
    //         border-radius: 8px;
    //         font-size: 14px;
    //         color: $text-primary;
    //         outline: none;
    //         transition: all 0.2s ease;

    //         &::placeholder {
    //             color: #9CA3AF;
    //         }

    //         &:focus {
    //             background: rgba(255, 255, 255, 1);
    //             border-color: #3B82F6;
    //             box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    //         }

    //         &:hover {
    //             background: $bg-secondary;
    //         }
    //     }
    // }

    // 安全状态指示器
    .security-status {
        display: flex;
        align-items: center;
        gap: $spacing-1;
        padding: $spacing-2 $spacing-3;
        background: rgba($bg-tertiary, 0.8);
        border-radius: $radius-full;
        font-size: 12px;
        color: $text-hint;
        font-weight: 500;
        cursor: default;
        transition: all 0.2s ease;

        &:hover {
            background: rgba($bg-tertiary, 1);
        }

        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: $success-color;
            animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        }
    }

    // 智能问答快捷入口
    .quick-access-btn {
        display: flex;
        align-items: center;
        gap: $spacing-1;
        padding: $spacing-2 $spacing-3;
        background: linear-gradient(135deg, $primary-light 0%, $primary-color 100%);  // 企业 Logo 蓝色渐变
        border: none;
        border-radius: 9999px;
        font-size: 13px;
        font-weight: 600;
        color: $bg-secondary;
        cursor: pointer;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(0, 160, 202, 0.3);

        &:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 160, 202, 0.4);
        }

        &:active {
            transform: translateY(0);
        }

        .iconify, .anticon {
            font-size: 16px;
        }
    }

    // 通知按钮
    .notification-btn {
        width: $card-btn-size;
        height: $card-btn-size;
        border-radius: $radius-lg;
        display: flex;
        align-items: center;
        justify-content: center;
        color: $text-hint;
        background: transparent;
        border: none;
        cursor: pointer;
        transition: all 0.2s ease;
        position: relative;

        &:hover {
            background: $bg-tertiary;
            color: $primary-color;
        }

        .iconify {
            font-size: 24px;
        }

        .notification-dot {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 10px;
            height: 10px;
            background: $error-color;
            border-radius: 50%;
            border: 2px solid $bg-secondary;
            animation: bounce 1s infinite;
        }
    }

    // 用户下拉菜单
    .user-dropdown-wrapper {
        position: relative;
    }

    .user-section {
        display: flex;
        align-items: center;
        gap: $spacing-2;
        padding: $spacing-2 $spacing-3;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        background: transparent;
        border: none;

        &:hover {
            background: $bg-tertiary;
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: $bg-secondary;
            border: 2px solid transparent;
            overflow: hidden;
            transition: all 0.2s ease;

            img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
        }

        &:hover .user-avatar {
            border-color: $primary-color;
        }

        .user-info {
            display: flex;
            flex-direction: column;
            gap: $spacing-1;
            text-align: left;
            min-width: 80px;

            .user-name {
                font-size: $font-md;
                font-weight: $font-semibold;
                color: $text-primary;
                transition: color 0.2s ease;
                white-space: nowrap;
            }

            &:hover .user-name {
                color: $primary-color;
            }

            .user-dept {
                font-size: $font-xs;
                color: $text-hint;
                white-space: nowrap;
            }
        }

        .user-dropdown-icon {
            font-size: $icon-md;
            color: $text-hint;
            transition: color 0.2s ease;
        }
    }

    .user-dropdown-menu {
        position: absolute;
        top: calc(100% + $spacing-2);
        right: 0;
        min-width: 200px;
        background: $bg-secondary;
        border-radius: $radius-xl;  // 12px
        box-shadow: $shadow-xl;
        border: 1px solid $border-base;
        padding: $spacing-2;
        z-index: $z-index-dropdown;
        animation: dropdownSlide 0.2s ease;

        .user-dropdown-header {
            padding: $spacing-3 $spacing-4;
            border-bottom: 1px solid $border-light;
            margin-bottom: $spacing-2;

            .user-dropdown-name {
                font-size: $font-md;
                font-weight: $font-weight-semibold;
                color: $text-primary;
                margin-bottom: 4px;
            }

            .user-dropdown-dept {
                font-size: $font-xs;
                color: $text-hint;
            }
        }

        .user-dropdown-item {
            display: flex;
            align-items: center;
            gap: $spacing-2;
            padding: $spacing-2 $spacing-3;
            border-radius: $radius-md;
            width: 100%;
            background: transparent;
            border: none;
            cursor: pointer;
            transition: all 0.2s ease;
            text-align: left;
            font-size: $font-md;
            color: $text-primary;

            &:hover {
                background: $bg-tertiary;
                color: $primary-color;

                .iconify {
                    color: $primary-color;
                }
            }

            &.danger {
                color: $error-color;

                &:hover {
                    background: rgba($error-color, 0.1);
                }

                .iconify {
                    color: $error-color;
                }
            }

            &.divider {
                height: 1px;
                background: $border-base;
                margin: 8px 0;
                padding: 0;
                cursor: default;

                &:hover {
                    background: $border-base;
                }
            }

            .iconify {
                font-size: $icon-md;
                color: $text-hint;
                transition: color 0.2s ease;
            }
        }
    }
}

// 动画
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

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

// 响应式
@media (max-width: 1024px) {
    .header {
        padding: 0 16px;

        .user-info {
            display: none;
        }
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 12px;

        .security-status span {
            display: none;
        }

        .notification-btn {
            width: 36px;
            height: 36px;
        }

        .user-avatar {
            width: 32px;
            height: 32px;
        }
    }
}
