/* ============================================================
   Emoji 禁用规则（强制，详见 docs/页面模块创建规范.md）
   空白字体接管 U+1F000-1FAFF emoji 区段（📖🏠🎬🔥 等），与 style.css 中规则保持一致；
   ✓ ✗ ❌ ✅ ★ 等普通符号不在覆盖区段内，不受影响。
   ============================================================ */
@font-face { font-family: 'XD Emoji Block'; src: url('../fonts/emoji-blank.woff2') format('woff2'); font-display: block; unicode-range: U+1F000-1FAFF; }
@font-face { font-family: 'Apple Color Emoji'; src: url('../fonts/emoji-blank.woff2') format('woff2'); font-display: block; unicode-range: U+1F000-1FAFF; }
@font-face { font-family: 'Segoe UI Emoji'; src: url('../fonts/emoji-blank.woff2') format('woff2'); font-display: block; unicode-range: U+1F000-1FAFF; }
@font-face { font-family: 'Noto Color Emoji'; src: url('../fonts/emoji-blank.woff2') format('woff2'); font-display: block; unicode-range: U+1F000-1FAFF; }

/* ============================================================
   Agent 智能体悬浮助手样式
   ============================================================ */

/* 左下角呼唤按钮 */
.agent-trigger {
    /* 呼吸光环取色（后台「图标管理」自定义背景色时由 JS 覆盖为同色系，默认紫色） */
    --agent-glow-rgb: 108, 92, 231;
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 37px;
    height: 37px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000; /* 高于沉浸式播放器全屏遮罩(9999)，确保任何页面可见 */
    box-shadow: 0 4px 16px rgba(var(--agent-glow-rgb), 0.35), 0 0 0 0 rgba(var(--agent-glow-rgb), 0.4);
    transition: all 0.3s ease;
    border: none;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.agent-trigger:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 24px rgba(var(--agent-glow-rgb), 0.45), 0 0 0 0 rgba(var(--agent-glow-rgb), 0.3);
}
.agent-trigger:active {
    transform: translateY(0) scale(0.97);
}
.agent-trigger.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.8);
}

/* ============================================================
   三页叠卡系统（站内信 + 聊天 + Agent+）
   ============================================================ */
.tab-card-stack {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 998;
    pointer-events: none;
}
.tab-card-stack.active {
    pointer-events: auto;
}

/* 呼出按钮组（底部一排） */
.tab-trigger-group {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 999;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.tab-trigger-group.compact {
    bottom: 12px;
    right: 12px;
    gap: 6px;
}

/* 单个呼出按钮 */
.tab-trigger {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    user-select: none;
}
.tab-trigger:hover { transform: translateY(-2px) scale(1.05); }
.tab-trigger:active { transform: scale(0.95); }

.tab-trigger-msg { background: linear-gradient(135deg, #00b894 0%, #00cec9 100%); }
.tab-trigger-chat { background: linear-gradient(135deg, #fdcb6e 0%, #f39c12 100%); }
.tab-trigger-friends { background: linear-gradient(135deg, #e17055 0%, #fab1a0 100%); }

/* 未读气泡 */
.tab-trigger .badge-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(231,76,60,0.3);
}

/* 叠卡面板容器 */
.tab-card-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.tab-card-panel.open {
    height: 75vh;
    max-height: 600px;
    z-index: 1001; /* 确保高于 agent-panel (1000) */
}

/* Tab 头部切换栏 */
.tab-card-header {
    display: flex;
    align-items: center;
    padding: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
    color: #fff;
    flex-shrink: 0;
}
.tab-card-nav {
    display: flex;
    flex: 1;
}
.tab-card-nav-item {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.6);
    transition: all 0.2s;
    position: relative;
    border-bottom: 3px solid transparent;
}
.tab-card-nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab-card-nav-item.active {
    color: #fff;
    border-bottom-color: var(--primary-light);
    background: rgba(255,255,255,0.08);
}
.tab-card-nav-item .badge-unread {
    position: absolute;
    top: 4px;
    right: 8px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0px 4px;
    border-radius: 8px;
    min-width: 14px;
}

/* 关闭按钮 */
.tab-card-close {
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.tab-card-close:hover { background: rgba(255,255,255,0.1); }

/* 三页内容区 */
.tab-card-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}
.tab-card-page {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow-y: auto;
    padding: 16px;
    opacity: 0;
    transform: translateX(30px);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}
.tab-card-page.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* 移动端 */
@media (max-width: 480px) {
    .tab-card-panel.open { height: 85vh; max-height: none; border-radius: 12px 12px 0 0; z-index: 1001; }
    .tab-trigger { width: 36px; height: 36px; font-size: 14px; }
    .tab-trigger-group { bottom: 8px; right: 8px; gap: 4px; }
    .tab-card-nav-item { font-size: 13px; padding: 10px 4px; }
    .agent-trigger { bottom: 16px; left: 16px; width: 32px; height: 32px; font-size: 13px; z-index: 10000; }
    .agent-panel { bottom: 84px; width: calc(100vw - 32px); max-width: 320px; z-index: 10000; }
}

/* 呼吸光环动画 */
@keyframes agentPulse {
    0% { box-shadow: 0 4px 16px rgba(var(--agent-glow-rgb), 0.35), 0 0 0 0 rgba(var(--agent-glow-rgb), 0.4); }
    70% { box-shadow: 0 4px 16px rgba(var(--agent-glow-rgb), 0.35), 0 0 0 12px rgba(var(--agent-glow-rgb), 0); }
    100% { box-shadow: 0 4px 16px rgba(var(--agent-glow-rgb), 0.35), 0 0 0 0 rgba(var(--agent-glow-rgb), 0); }
}
.agent-trigger.pulse {
    animation: agentPulse 2s infinite;
}

/* 后台「图标管理」勾选「透明背景」时：无底色、无投影，只显示图标本身
   （须写在 .agent-trigger.pulse 之后，同优先级下由后置规则关闭呼吸光环动画） */
.agent-trigger.no-bg,
.agent-trigger.no-bg:hover,
.agent-trigger.no-bg:active {
    background: transparent;
    box-shadow: none;
    animation: none;
}

/* Agent 弹窗面板 */
.agent-panel {
    position: fixed;
    bottom: 24px;
    left: 73px;
    width: 360px;
    max-width: calc(100vw - 120px);
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    z-index: 10000; /* 与呼唤按钮同级且 DOM 在后，高于播放器遮罩(9999) */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: translateX(-20px) scale(0.95);
    pointer-events: none;
}
.agent-panel.open {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: auto;
}

/* 弹窗头部 */
.agent-panel-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    color: #fff;
    gap: 10px;
}
.agent-panel-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.agent-panel-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
}
.agent-panel-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    line-height: 1;
}
.agent-panel-close:hover {
    background: rgba(255,255,255,0.2);
}

/* 消息区域 */
.agent-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 120px;
}
.agent-panel-body::-webkit-scrollbar {
    width: 4px;
}
.agent-panel-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

/* 消息气泡 */
.agent-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: agentMsgIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes agentMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.agent-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.agent-message-content {
    flex: 1;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: #333;
    word-break: break-word;
}
.agent-message-content strong {
    display: block;
    font-weight: 600;
    margin-bottom: 3px;
    color: #6c5ce7;
    font-size: 13.5px;
}
.agent-message-content .agent-msg-action {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: #6c5ce7;
    color: #fff;
    border-radius: 14px;
    font-size: 12px;
    text-decoration: none;
    transition: background 0.2s;
    cursor: pointer;
}
.agent-message-content .agent-msg-action:hover {
    background: #5b4bd6;
}

/* 快捷对话区 */
.agent-panel-footer {
    padding: 10px 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-height: 40px;
}
.agent-chip {
    padding: 5px 12px;
    background: #f0f0f0;
    border: none;
    border-radius: 14px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.agent-chip:hover {
    background: #e8e0ff;
    color: #6c5ce7;
}

/* 输入区 */
.agent-input-area {
    display: flex;
    padding: 8px 12px;
    border-top: 1px solid #f0f0f0;
    gap: 6px;
}
.agent-input-area input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    padding: 7px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.agent-input-area input:focus {
    border-color: #6c5ce7;
}
.agent-input-area button {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #6c5ce7;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}
.agent-input-area button:hover {
    background: #5b4bd6;
}

/* ============================================================
   单一智能触发键（全站非 messages.php 页面）
   上下文感知 + 长按菜单选择，支持自由拖拽
   ============================================================ */
.tab-drawer-group {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}
.tab-drawer-group.dragging {
    cursor: grabbing;
}

/* 单一触发按钮 */
.tab-trigger-btn {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    z-index: 2;
}
.tab-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.28), 0 4px 12px rgba(0,0,0,0.15);
}
.tab-trigger-btn:active {
    transform: scale(0.95);
}

/* 触发键未读总数气泡 */
.tab-trigger-btn .trigger-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(231,76,60,0.4);
    line-height: 1.2;
    border: 2px solid #fff;
}

/* 弹出菜单 */
.tab-trigger-menu {
    position: absolute;
    top: 50%;
    right: calc(100% + 8px);
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    z-index: 1;
    animation: menuSlideIn 0.2s ease;
}
@keyframes menuSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(8px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* 菜单项 */
.tab-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    min-width: 100px;
}
.tab-menu-item:hover {
    background: rgba(0,0,0,0.05);
}
.tab-menu-item:active {
    background: rgba(0,0,0,0.08);
}

/* 菜单图标 */
.tab-menu-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

/* 菜单标签 */
.tab-menu-label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    flex: 1;
}

/* 菜单未读气泡 */
.tab-menu-badge {
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    line-height: 1.3;
}

/* ============================================================
   抽屉式弹窗覆盖层 + iframe 面板
   ============================================================ */
.tab-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.tab-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.tab-drawer-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: #fff;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.tab-drawer-panel.open {
    height: 80vh;
    max-height: 700px;
}

/* 面板头部 */
.tab-drawer-header {
    display: flex;
    align-items: center;
    padding: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
    color: #fff;
    flex-shrink: 0;
    border-radius: 18px 18px 0 0;
}
.tab-drawer-nav {
    display: flex;
    flex: 1;
}
.tab-drawer-nav-item {
    flex: 1;
    padding: 14px 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.6);
    transition: all 0.2s;
    position: relative;
    border-bottom: 3px solid transparent;
}
.tab-drawer-nav-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}
.tab-drawer-nav-item.active {
    color: #fff;
    border-bottom-color: #a29bfe;
    background: rgba(255,255,255,0.08);
}
.tab-drawer-nav-item .badge-unread {
    position: absolute;
    top: 6px;
    right: 10px;
    background: #e74c3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0px 4px;
    border-radius: 8px;
    min-width: 14px;
}
.tab-drawer-close {
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.tab-drawer-close:hover {
    background: rgba(255,255,255,0.1);
}

/* iframe 容器 */
.tab-drawer-iframe-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
}
.tab-drawer-iframe-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
.tab-drawer-iframe-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.8);
    z-index: 1;
    font-size: 14px;
    color: #666;
}
.tab-drawer-iframe-loading.hidden {
    display: none;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .tab-drawer-group {
        right: 8px;
    }
    .tab-trigger-btn {
        width: 42px;
        height: 42px;
        font-size: 19px;
    }
    .tab-trigger-btn .trigger-badge {
        font-size: 10px;
        padding: 1px 4px;
        min-width: 16px;
        top: -3px;
        right: -3px;
    }
    .tab-trigger-menu {
        right: calc(100% + 6px);
        padding: 4px;
        gap: 2px;
        border-radius: 12px;
    }
    .tab-menu-item {
        padding: 6px 10px;
        min-width: 90px;
    }
    .tab-menu-icon {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    .tab-menu-label {
        font-size: 12px;
    }
    .tab-drawer-panel.open {
        height: 90vh;
        max-height: none;
        border-radius: 14px 14px 0 0;
    }
    .tab-drawer-nav-item {
        font-size: 13px;
        padding: 12px 4px;
    }
}
