/**
 * 文件路径: /home/ubuntu/talktalk_backend/public/css/chat.css
 * 功能用途: 聊天区域及气泡样式
 * 版本: v3.1
 * 最后修改: 2025-12-01 - 设置聊天窗口背景为半透明
 */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    position: relative;
}

[data-theme="dark"] .chat-container {
    background-color: rgba(55, 71, 79, 0.7);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    padding-bottom: 140px; /* Space for pet */
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.message.user .message-bubble {
    background-color: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

[data-theme="dark"] .message.user .message-bubble {
    color: var(--text-inverted);
}

.message.assistant .message-bubble {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* 消息元数据 */
.message-info {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.8;
    padding: 0 5px;
}

/* 正在输入/流式传输 */
.message.streaming .message-bubble::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: currentColor;
    border-radius: 50%;
    margin-left: 5px;
    animation: pulse 1s infinite;
}

/* 底部输入区 */
.chat-input-area {
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px var(--spacing-lg);
    border-top: 1px solid rgba(0,0,0,0.05);
    position: relative; /* Ensure z-index works */
    z-index: 30; /* Above pet container */
}

[data-theme="dark"] .chat-input-area {
    background-color: rgba(55, 71, 79, 0.7);
    border-top-color: rgba(255, 255, 255, 0.1);
}

.input-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
    min-height: 62px; /* Enforce consistent height (40px button + 22px margin) to prevent layout jump */
}

/* 语音动效波纹 (Overlay) */
.voice-active-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    backdrop-filter: blur(2px);
}

.voice-waves {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 40px;
}

.wave {
    width: 6px;
    background-color: var(--secondary-color);
    border-radius: 3px;
    animation: wave 1s infinite ease-in-out;
}

.wave:nth-child(1) { height: 20px; animation-delay: 0.1s; }
.wave:nth-child(2) { height: 30px; animation-delay: 0.2s; }
.wave:nth-child(3) { height: 40px; animation-delay: 0.3s; }
.wave:nth-child(4) { height: 30px; animation-delay: 0.2s; }
.wave:nth-child(5) { height: 20px; animation-delay: 0.1s; }

@keyframes wave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.5); }
}

/* 对话界面需要相对定位 */
#chat-interface {
    position: relative;
}

/* 右上角关闭按钮区域 - 骑在聊天窗口边缘 */
.chat-close-area {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 50px;
    height: 50px;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: rgba(150, 150, 150, 0.4);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-close-area:hover .chat-close-btn,
.chat-close-area.active .chat-close-btn {
    background-color: rgba(244, 67, 54, 0.85);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.4);
}

.chat-close-btn:hover {
    background-color: rgba(244, 67, 54, 1);
}

[data-theme="dark"] .chat-close-btn {
    background-color: rgba(100, 100, 100, 0.5);
    color: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .chat-close-area:hover .chat-close-btn,
[data-theme="dark"] .chat-close-area.active .chat-close-btn {
    background-color: rgba(244, 67, 54, 0.85);
    color: #fff;
}
