/**
 * 聊天窗口 - 表情工具模块样式（独立样式，仅本面板使用）
 * 类名前缀：chat-window-emoji-*
 * 字体：Microsoft YaHei（符合项目字体规范）
 */

/* 表情按钮样式（继承工具按钮基础样式，与其他工具按钮保持一致） */
.chat-window-panel .chat-window-emoji-btn {
    /* 继承 .chat-window-tool-btn 的样式，无需额外设置 */
}

/* 表情按钮激活状态 */
.chat-window-panel .chat-window-emoji-btn.is-active {
    background: var(--cw-hover, #282828);
}

/* 表情按钮的SVG图标样式（与其他工具按钮一致） */
.chat-window-panel .chat-window-emoji-btn .chat-window-tool-svg {
    /* 继承 .chat-window-tool-svg 的样式，无需额外设置 */
}

.chat-window-panel .chat-window-emoji-btn.is-active .chat-window-tool-svg {
    color: var(--cw-text, #e8e8e8);
}

/* 输入区域需要相对定位，以便表情面板可以绝对定位 */
.chat-window-panel .chat-window-input-area {
    position: relative;
}

/* 表情面板容器 */
.chat-window-emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 360px;
    max-height: 400px;
    background: var(--cw-bg-panel, #1e1e1e);
    border: 1px solid var(--cw-border, #2e2e2e);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 8px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
}

/* 表情面板隐藏状态 */
.chat-window-emoji-panel[hidden],
.chat-window-emoji-panel[aria-hidden="true"] {
    display: none !important;
}

/* 表情面板头部 */
.chat-window-emoji-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--cw-border-subtle, #262626);
    background: var(--cw-bg-deep, #141414);
}

.chat-window-emoji-title {
    font-size: 13px;
    font-weight: normal;
    color: var(--cw-text-title, #f0f0f0);
}

.chat-window-emoji-close {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--cw-text-muted, #909090);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-window-emoji-close:hover {
    background: var(--cw-hover, #282828);
    color: var(--cw-text, #e8e8e8);
}

/* 表情包标签页（预留，当前仅默认表情包） */
.chat-window-emoji-tabs {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--cw-border-subtle, #262626);
    background: var(--cw-bg-deep, #141414);
    gap: 8px;
}

.chat-window-emoji-tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--cw-text-muted, #909090);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-window-emoji-tab:hover {
    color: var(--cw-text, #e8e8e8);
    background: var(--cw-hover, #282828);
}

.chat-window-emoji-tab.is-active {
    color: var(--cw-text, #e8e8e8);
    background: var(--cw-hover, #282828);
}

/* 表情内容区 */
.chat-window-emoji-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--cw-bg-panel, #1e1e1e);
}

/* 滚动条样式 */
.chat-window-emoji-content {
    scrollbar-width: thin;
    scrollbar-color: var(--cw-scroll-thumb, #404040) var(--cw-scroll-track, #252525);
}

.chat-window-emoji-content::-webkit-scrollbar {
    width: 6px;
}

.chat-window-emoji-content::-webkit-scrollbar-track {
    background: var(--cw-scroll-track, #252525);
}

.chat-window-emoji-content::-webkit-scrollbar-thumb {
    background: var(--cw-scroll-thumb, #404040);
    border-radius: 3px;
}

.chat-window-emoji-content::-webkit-scrollbar-thumb:hover {
    background: var(--cw-scroll-thumb-hover, #4a4a4a);
}

/* 表情网格 */
.chat-window-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

/* 表情项 */
.chat-window-emoji-item {
    width: 100%;
    aspect-ratio: 1;
    padding: 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex; /* 默认flex布局 */
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
    visibility: hidden; /* 初始隐藏，图片加载成功后再显示 */
    opacity: 0;
}

/* 表情项显示状态（图片加载成功后） */
.chat-window-emoji-item[data-loaded="true"] {
    visibility: visible;
    opacity: 1;
}

.chat-window-emoji-item:hover {
    background: var(--cw-hover, #282828);
    border-color: var(--cw-border, #2e2e2e);
}

.chat-window-emoji-item:active {
    background: var(--cw-active, #2a2a2a);
    transform: scale(0.95);
}

/* 表情图片 */
.chat-window-emoji-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    pointer-events: none;
}

/* 表情项文本占位（图片加载失败时显示） */
.chat-window-emoji-item:not(:has(.chat-window-emoji-img)) {
    font-size: 11px;
    color: var(--cw-text-muted, #909090);
    text-align: center;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 消息中的表情样式（聊天界面中显示更大，便于识别） */
.chat-window-panel .chat-window-message-body .chat-window-msg-emoji {
    display: inline-block;
    width: auto;
    height: 52px;
    max-width: 96px;
    max-height: 96px;
    min-width: 32px;
    min-height: 32px;
    vertical-align: middle;
    margin: 0 3px;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    flex-shrink: 0;
}
/* 消息气泡内表情优先使用较大尺寸（约 52px 高度，视觉更清晰） */
.chat-window-panel .chat-window-message-bubble .chat-window-message-body .chat-window-msg-emoji {
    height: 52px;
    min-height: 52px;
    max-height: 72px;
}

/* 用户列表中的表情样式（最后一条消息摘要） */
.chat-window-panel .chat-window-user-msg .chat-window-msg-emoji {
    display: inline-block;
    width: 16px;
    height: 16px;
    max-width: 16px;
    max-height: 16px;
    vertical-align: middle;
    margin: 0 1px;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    flex-shrink: 0;
}

/* 响应式：小屏幕调整 */
@media (max-width: 480px) {
    .chat-window-emoji-panel {
        width: 100%;
        max-width: 360px;
    }

    .chat-window-emoji-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }
}

