/**
 * 用户端聊天界面样式
 * 官方客服风格 - 仿微信/支付宝客服
 */

/* ========== 基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', '微软雅黑', sans-serif;
    font-size: 14px;
    color: #333;
    background-color: #F7F8FA;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== 聊天容器 ========== */
.chat-container {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #F7F8FA;
}

/* ========== 顶部导航栏 ========== */
.chat-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(135deg, #1890FF 0%, #36A3FF 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.15);
    z-index: 100;
}

.header-left, .header-right {
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.header-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 2px;
}

.header-status {
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
    display: inline-block;
}

.status-dot.online {
    background-color: #52c41a;
    box-shadow: 0 0 6px rgba(82, 196, 26, 0.5);
}

.back-btn, .more-btn {
    font-size: 18px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.back-btn:hover, .more-btn:hover {
    opacity: 0.8;
}

/* ========== 消息列表区域 ========== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 66px 15px 130px;
    -webkit-overflow-scrolling: touch;
}

.message-item {
    display: flex;
    margin-bottom: 20px;
    animation: messageIn 0.3s ease-out;
}

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

/* 客服消息(左侧) */
.message-service {
    flex-direction: row;
}

/* 用户消息(右侧) */
.message-user {
    flex-direction: row;
    justify-content: flex-end;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: calc(100% - 60px);
    margin: 0 10px;
}

.message-bubble {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 8px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 客服消息气泡 */
.message-service .message-bubble {
    background-color: #FFFFFF;
    color: #333;
    border-top-left-radius: 2px;
}

/* 用户消息气泡 */
.message-user .message-bubble {
    background-color: #1890FF;
    color: #FFFFFF;
    border-top-right-radius: 2px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    text-align: center;
}

.message-service .message-time {
    text-align: left;
}

.message-user .message-time {
    text-align: left;
}

/* ========== 消息类型样式 ========== */
.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
    display: block;
}

.message-video {
    max-width: 250px;
    max-height: 200px;
    border-radius: 6px;
    display: block;
}

.message-emoji {
    font-size: 48px;
    line-height: 1;
}

.message-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    max-width: 260px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.card-body {
    padding: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.card-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.card-price {
    font-size: 18px;
    font-weight: 600;
    color: #FF4D4F;
}

/* ========== 底部输入栏 ========== */
.chat-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #FFFFFF;
    border-top: 1px solid #E8E8E8;
    padding: 10px 15px;
    z-index: 100;
}

.toolbar {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.tool-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    margin-right: 15px;
    transition: color 0.2s;
    position: relative;
}

.tool-btn:hover {
    color: #1890FF;
}

.input-area {
    display: flex;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    padding: 8px 12px;
    border: 1px solid #E8E8E8;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
    transition: border-color 0.3s;
}

.message-input:focus {
    border-color: #1890FF;
}

.send-btn {
    width: 36px;
    height: 36px;
    margin-left: 10px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #1890FF 0%, #36A3FF 100%);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ========== 表情面板 ========== */
.emoji-panel {
    position: fixed;
    bottom: 120px;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border-top: 1px solid #E8E8E8;
    padding: 15px;
    z-index: 99;
    animation: slideUp 0.3s ease-out;
}

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

.emoji-list {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 28px;
    text-align: center;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.emoji-item:hover {
    transform: scale(1.2);
}

/* ========== 更多功能面板 ========== */
.more-panel {
    position: fixed;
    bottom: 120px;
    left: 0;
    right: 0;
    background: #FFFFFF;
    border-top: 1px solid #E8E8E8;
    padding: 20px 15px;
    z-index: 99;
    animation: slideUp 0.3s ease-out;
}

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

.more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.more-item i {
    width: 56px;
    height: 56px;
    background-color: #F7F8FA;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #666;
    margin-bottom: 8px;
    transition: all 0.3s;
}

.more-item:hover i {
    background-color: #1890FF;
    color: #fff;
    transform: translateY(-2px);
}

.more-item span {
    font-size: 12px;
    color: #666;
}

/* ========== 图片预览模态框 ========== */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    position: relative;
    z-index: 1001;
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* ========== 滚动条样式 ========== */
.chat-messages::-webkit-scrollbar,
.emoji-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb,
.emoji-list::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-track,
.emoji-list::-webkit-scrollbar-track {
    background-color: transparent;
}

/* ========== 响应式设计 ========== */
@media (min-width: 768px) {
    .chat-container {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
    }
}

/* ========== 加载动画 ========== */
.loading {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 13px;
}

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

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