* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
}

header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    text-align: center;
    flex-shrink: 0;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.status {
    font-size: 14px;
    opacity: 0.8;
}

.chat-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.conversations-panel {
    width: 300px;
    background: #ecf0f1;
    border-right: 2px solid #bdc3c7;
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
}

.conversations-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
    font-size: 16px;
}

.conversation-item {
    background: white;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    border-left: 4px solid #3498db;
    transition: all 0.3s ease;
    position: relative;
}

.conversation-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.conversation-item.active {
    background: #e3f2fd;
    border-left-color: #e74c3c;
}

.conversation-name {
    font-weight: bold;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.unread-badge {
    background: #e74c3c;
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    min-width: 18px;
    text-align: center;
}

.conversation-info {
    font-size: 11px;
    color: #7f8c8d;
    margin: 3px 0;
}

.conversation-preview {
    font-size: 12px;
    color: #7f8c8d;
    margin: 5px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-status {
    font-size: 11px;
    color: #7f8c8d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    display: inline-block;
    margin-right: 5px;
}

.status-dot.offline {
    background: #95a5a6;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* 防止flex item溢出 */
}

.chat-header {
    background: #34495e;
    color: white;
    padding: 12px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.customer-details {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 3px;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.3s ease;
}

.action-button:hover {
    background: rgba(255,255,255,0.3);
}

.messages-container {
    flex: 1;
    padding: 8px 12px; /* 更紧凑的内边距 */
    overflow-y: auto;
    background: #ededed; /* 微信背景色 */
    display: flex;
    flex-direction: column;
    gap: 0; /* 确保消息之间没有额外间距 */
}

.message {
    max-width: 60%;
    padding: 7px 11px;
    margin: 1px 10px; /* 更小的上下间距 */
    border-radius: 4px; /* 微信的圆角较小 */
    line-height: 1.35;
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: none; /* 微信无阴影 */
}

/* 欢迎消息样式 - 微信风格居中显示 */
.message-welcome {
    max-width: 280px !important;
    text-align: center;
    margin: 4px auto !important;
    align-self: center !important;
    line-height: 1.5;
    padding: 6px 10px !important;
    background: #dadada !important; /* 微信灰色系统提示背景 */
    border: none !important;
    box-shadow: none !important;
    color: #666 !important;
}

.message-welcome .message-content {
    text-align: center;
    line-height: 1.5;
    font-size: 13px;
    color: #2c3e50;
    margin: 0 !important;
    padding: 0 !important;
}

.message-welcome .message-sender {
    display: none !important;
}

.message-welcome .message-time {
    text-align: center;
    margin: 3px 0 0 0 !important;
    padding: 0 !important;
    font-size: 11px;
}

.message-time {
    font-size: 10px;
    color: #999;
    margin: 0;
    padding: 0;
    display: block;
}

.message-sender {
    font-size: 11px;
    font-weight: 500;
    margin: 0 0 2px 0;
    padding: 0;
    display: block;
    color: #666;
}

.message-content {
    margin: 0;
    padding: 0;
    font-size: 15px; /* 微信字体稍大 */
    line-height: 1.35; /* 更紧凑的行高 */
}

/* 修改消息状态排列 */
.message-status {
    display: flex;
    gap: 4px;
    align-items: center;
    margin: 2px 0 0 0;
    padding: 0;
    font-size: 9px;
    opacity: 0.7;
}

.message-status-item {
    display: flex;
    align-items: center;
}

.welcome-message {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 15px;
}

.message-input-container {
    padding: 15px;
    background: white;
    border-top: 2px solid #ecf0f1;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    min-height: 60px;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid #bdc3c7;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.message-input:focus {
    border-color: #3498db;
}

.send-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s ease;
    font-size: 14px;
}

.send-button:hover {
    background: #2980b9;
}

.send-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

.no-conversation {
    text-align: center;
    color: #7f8c8d;
    padding: 30px 15px;
    font-style: italic;
}

.admin-panel {
    background: #e74c3c;
    color: white;
    padding: 12px 15px;
    text-align: center;
    flex-shrink: 0;
}

.admin-button {
    background: #c0392b;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 4px;
    transition: background 0.3s ease;
    font-size: 12px;
}

.admin-button:hover {
    background: #a93226;
}

.admin-button.secondary {
    background: #34495e;
}

.admin-button.secondary:hover {
    background: #2c3e50;
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 0;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    .container {
        height: 100vh;
        height: 100dvh; /* 动态视口高度，适配移动端 */
        border-radius: 0;
        margin: 0;
    }
    
    header {
        padding: 10px 15px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .status {
        font-size: 12px;
    }
    
    .conversations-panel {
        width: 250px;
        padding: 10px;
    }
    
    .conversation-item {
        padding: 10px;
        margin-bottom: 6px;
    }
    
    .chat-header {
        padding: 10px 12px;
    }
    
    .messages-container {
        padding: 8px; /* 更紧凑 */
    }
    
    .message {
        max-width: 90%;
        padding: 7px 11px;
        margin: 1px 0; /* 更小的间距 */
    }
    
    .message-input-container {
        padding: 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 6px;
    }
    
    .emoji-button, .image-button {
        min-width: 36px;
        height: 36px;
        padding: 6px;
    }
    
    .message-input {
        padding: 8px 10px;
        font-size: 15px;
    }
    
    .send-button {
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .admin-panel {
        padding: 10px 12px;
    }
    
    .admin-button {
        padding: 5px 10px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .conversations-panel {
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        display: block;
    }
    
    .conversations-panel.show {
        left: 0;
    }
    
    .chat-panel {
        width: 100%;
    }
    
    .message {
        max-width: 95%;
    }
    
    .toggle-conversations {
        display: block;
        background: rgba(255,255,255,0.2);
        color: white;
        border: none;
        padding: 8px 12px;
        border-radius: 4px;
        cursor: pointer;
        margin-right: 10px;
        font-size: 20px;
        line-height: 1;
    }
    
    .toggle-conversations:hover {
        background: rgba(255,255,255,0.3);
    }
}

/* 移动端对话列表切换按钮 */
.toggle-conversations {
    display: none;
}

/* 图片消息样式 */
.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
    display: block;
    margin: 5px 0;
}

.message-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .message-image {
        max-width: 200px;
        max-height: 200px;
    }
}