/* 客服聊天页面样式 - 模拟微信 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #EDEDED;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* 头部 */
.chat-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #F7F7F7;
    border-bottom: 1px solid #D9D9D9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

.back-btn, .more-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.back-btn:active, .more-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.back-btn .material-symbols-outlined,
.more-btn .material-symbols-outlined {
    font-size: 24px;
    color: #000;
}

.header-info {
    flex: 1;
    text-align: center;
}

.service-title {
    font-size: 17px;
    font-weight: 600;
    color: #000;
    margin-bottom: 2px;
}

.service-status {
    font-size: 12px;
    color: #999;
}

.service-status.online {
    color: #07C160;
}

/* 聊天容器 */
.chat-container {
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
    padding: 16px 16px 80px;
    -webkit-overflow-scrolling: touch;
}

/* 消息日期 */
.message-date {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin: 16px 0;
}

/* 消息项 */
.message-item {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease;
}

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

/* 系统消息 */
.message-item.system {
    justify-content: center;
}

.message-item.system .message-content {
    max-width: 80%;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    text-align: center;
}

.message-item.system .message-content p {
    margin: 4px 0;
}

/* 接收的消息（客服） */
.message-item.received {
    flex-direction: row;
}

.message-item.received .avatar {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 10px;
    flex-shrink: 0;
}

.message-item.received .message-content {
    max-width: 70%;
    background: #FFF;
    padding: 10px 14px;
    border-radius: 0 8px 8px 8px;
    font-size: 15px;
    color: #000;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* 发送的消息（用户） */
.message-item.sent {
    flex-direction: row-reverse;
}

.message-item.sent .avatar {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-left: 10px;
    flex-shrink: 0;
}

.message-item.sent .message-content {
    max-width: 70%;
    background: #95EC69;
    padding: 10px 14px;
    border-radius: 8px 0 8px 8px;
    font-size: 15px;
    color: #000;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

/* 图片消息 */
.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
    display: block;
}

.message-item.sent .message-image {
    background: transparent;
    padding: 0;
}

.message-item.received .message-image {
    background: transparent;
    padding: 0;
}

/* 视频消息 */
.message-video {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    display: block;
}

.message-item.sent .message-video {
    background: transparent;
    padding: 0;
}

.message-item.received .message-video {
    background: transparent;
    padding: 0;
}

/* 消息时间 */
.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.message-item.received .message-time {
    text-align: left;
}

/* 输入区域 */
.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #F7F7F7;
    border-top: 1px solid #D9D9D9;
    padding: 8px 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    z-index: 100;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.tool-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.tool-btn .material-symbols-outlined {
    font-size: 24px;
    color: #666;
}

.input-wrapper {
    flex: 1;
    background: #FFF;
    border-radius: 6px;
    border: 1px solid #D9D9D9;
    display: flex;
    align-items: flex-end;
    padding: 8px 12px;
    max-height: 120px;
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    background: transparent;
    font-family: inherit;
}

.emoji-btn {
    width: 24px;
    height: 24px;
    margin-left: 8px;
}

.emoji-btn .material-symbols-outlined {
    font-size: 20px;
}

.send-btn {
    padding: 0 16px;
    height: 36px;
    background: #07C160;
    color: #FFF;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.send-btn:active {
    opacity: 0.8;
}

/* 附件菜单 */
.attachment-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.attachment-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.attachment-panel {
    position: relative;
    background: #F7F7F7;
    border-radius: 16px 16px 0 0;
    padding: 24px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.attachment-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.attachment-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.attachment-item:active .attachment-icon {
    transform: scale(0.95);
}

.attachment-icon .material-symbols-outlined {
    font-size: 28px;
    color: #FFF;
}

.attachment-label {
    font-size: 13px;
    color: #666;
}

/* 加载状态 */
.message-loading {
    display: inline-block;
    width: 40px;
    text-align: center;
}

.message-loading::after {
    content: '...';
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* 响应式调整 */
@media (max-width: 375px) {
    .message-item.received .message-content,
    .message-item.sent .message-content {
        max-width: 65%;
    }
    
    .message-image,
    .message-video {
        max-width: 180px;
        max-height: 180px;
    }
    
    .attachment-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    
    .attachment-icon {
        width: 50px;
        height: 50px;
    }
}



/* 转人工按钮栏 */
#preInputBar{
  position: fixed;
  left: 0; right: 0;
  bottom: 56px;
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px;
  background: rgba(247,247,247,0.98);
  border-top: 1px solid #eee;
  z-index: 100;
}

#preInputBar #humanBtn{
  background:#eaeaea; color:#333; border:none; border-radius:16px; padding:4px 10px; font-size:12px;
}

/* 增加底部留白，避免被 preInputBar 遮挡 */
.chat-container{
  padding-bottom: 120px;
}
