/**
 * 全局消息栏样式
 * Global Message Bar CSS
 *
 * 职责：仅负责全局消息提示的展示样式
 * 位置：主页右上角，输入邀请码左侧（挂载在 .global-message-bar-mount）
 * 特点：轻量、独立、纯展示
 */

/* ==================== 挂载点（位于 header-right-section，输入邀请码左侧） ==================== */

.global-message-bar-mount {
    display: flex;
    align-items: center;
    min-width: 0;
    flex-shrink: 0;
}

/* ==================== 容器布局 ==================== */

.global-message-bar-container {
    position: static;
    left: auto;
    top: auto;
    z-index: 9999; /* 确保在最上层 */
    pointer-events: none; /* 容器不阻挡鼠标事件 */
    min-width: 0; /* 在 flex 中可收缩，无消息时少占空间 */
}

/* ==================== 消息栏主体 ==================== */
/* 底框效果与「输入邀请码」一致：圆角块状背景 + 类型颜色区分 */

.global-message-bar {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--radius-md, 8px);
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    min-height: 36px;
    font-family: 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary, #e0e0e0);
    max-width: 400px;
    min-width: 120px;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ==================== 隐藏状态 ==================== */

.global-message-bar--hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    /* 隐藏时完全不可见但仍占据空间，避免布局跳动 */
}

/* ==================== 显示状态（可见） ==================== */

.global-message-bar--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== 图标区域 ==================== */

.global-message-bar__icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    position: relative; /* chat 类型头像图标定位用 */
}

/* 图标通过伪元素实现（可使用 Unicode 字符或 Font Awesome） */
.global-message-bar__icon::before {
    content: 'ℹ'; /* 默认信息图标（可根据类型动态更改） */
    display: block;
}

/* ==================== 文本区域 ==================== */

.global-message-bar__text {
    flex: 1;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 文本超长时显示省略号，完整内容通过 title 属性展示 */
}

/* ==================== 消息类型样式 ==================== */
/* 底框背景、边框与文字/图标按类型区分（与输入邀请码底框同风格） */

/* 信息类型（默认：蓝底框） */
.global-message-bar--info {
    background: #1e3a4f;
    border-color: rgba(100, 181, 246, 0.35);
    color: #64b5f6;
}

.global-message-bar--info .global-message-bar__icon::before {
    content: 'ℹ';
    color: #64b5f6;
}

/* 成功类型（绿底框） */
.global-message-bar--success {
    background: #1a2e22;
    border-color: rgba(129, 199, 132, 0.35);
    color: #81c784;
}

.global-message-bar--success .global-message-bar__icon::before {
    content: '✓';
    color: #81c784;
}

/* 警告类型（黄/琥珀底框） */
.global-message-bar--warning {
    background: #3d3420;
    border-color: rgba(255, 183, 77, 0.35);
    color: #ffb74d;
}

.global-message-bar--warning .global-message-bar__icon::before {
    content: '⚠';
    color: #ffb74d;
}

/* 错误类型（红底框） */
.global-message-bar--error {
    background: #3d2525;
    border-color: rgba(229, 115, 115, 0.35);
    color: #e57373;
}

.global-message-bar--error .global-message-bar__icon::before {
    content: '✕';
    color: #e57373;
}

/* 聊天新消息类型：绿底框，头像轮廓图标，与成功类同色系便于识别新消息 */
.global-message-bar--chat {
    background: #1a2e22;
    border-color: rgba(129, 199, 132, 0.35);
    color: #81c784;
}

.global-message-bar--chat .global-message-bar__icon::before {
    content: '';
    display: block;
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.global-message-bar--chat .global-message-bar__icon::after {
    content: '';
    display: block;
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 7px;
    border-radius: 6px 6px 0 0;
    background: currentColor;
}

/* ==================== 响应式适配 ==================== */

@media (max-width: 768px) {
    .global-message-bar {
        max-width: calc(100vw - 76px);
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .global-message-bar__icon {
        width: 18px;
        height: 18px;
        margin-right: 8px;
        font-size: 14px;
    }
}

/* ==================== 动画增强（可选） ==================== */

/* 淡入动画 */
@keyframes global-message-bar-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡出动画 */
@keyframes global-message-bar-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* 应用动画的类（由 JS 控制） */
.global-message-bar--animating-in {
    animation: global-message-bar-fade-in 0.3s ease forwards;
}

.global-message-bar--animating-out {
    animation: global-message-bar-fade-out 0.3s ease forwards;
}
