/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

/* 聊天容器 */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(30, 64, 175, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transition: all 0.3s ease;
    border: 1px solid rgba(30, 64, 175, 0.08);
}

.chat-container.minimized {
    display: none;
}

/* 聊天头部 */
.chat-header {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-info {
    display: flex;
    align-items: center;
}

.header-info .avatar {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.header-info .avatar i {
    font-size: 20px;
    color: #ffffff;
}

.header-info .info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.header-info .status {
    font-size: 12px;
    opacity: 0.95;
    display: flex;
    align-items: center;
}

.header-info .status.online::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    margin-right: 5px;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse-online 2s ease-in-out infinite;
}

@keyframes pulse-online {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
    }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions .btn-minimize {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    padding: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.header-actions .btn-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.header-actions .btn-minimize i {
    font-size: 14px;
}

/* 明显的返回按钮 */
.header-actions .btn-back {
    background: rgba(255, 255, 255, 0.95);
    color: #1e40af;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.header-actions .btn-back i {
    color: #1e40af;
    font-size: 12px;
}

.header-actions .btn-back:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f7f7f7;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

.welcome-message {
    text-align: center;
    margin-bottom: 20px;
}

.system-message {
    background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
    border-radius: 8px;
    padding: 12px 16px;
    display: inline-block;
    color: #1e40af;
    font-size: 14px;
    border: 1px solid rgba(30, 64, 175, 0.1);
    box-shadow: 0 2px 4px rgba(30, 64, 175, 0.06);
}

.system-message i {
    margin-right: 8px;
    color: #2563eb;
}

/* 消息样式 */
.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

.message.user {
    justify-content: flex-end;
}

.message.admin {
    justify-content: flex-start;
}

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
    margin: 0 8px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    order: 1;
}

.message.admin .message-avatar {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
}

.message-content {
    max-width: 70%;
    position: relative;
}

.message-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
    line-height: 1.4;
    font-size: 14px;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    margin-right: 8px;
}

.message.admin .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    margin-left: 8px;
}

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

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

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

/* 图片消息 */
.message-image {
    max-width: 200px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

/* 输入区域 */
.chat-input-area {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 15px;
}

.input-tools {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.tool-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    font-size: 16px;
}

.tool-btn:hover {
    background: #eff6ff;
    color: #2563eb;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

#messageInput {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

#messageInput:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#sendBtn {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

#sendBtn:hover {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.4);
}

#sendBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 表情面板 */
.emoji-panel {
    position: absolute;
    bottom: 120px;
    left: 15px;
    right: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

.emoji {
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    text-align: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.emoji:hover {
    background: #f0f0f0;
}

/* 聊天切换按钮 */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
    z-index: 999;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.4);
}

.chat-toggle i {
    font-size: 24px;
}

.chat-toggle .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .chat-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chat-toggle {
        bottom: 15px;
        right: 15px;
    }
}

/* 加载动画 */
.loading-dots {
    display: inline-block;
    position: relative;
    width: 40px;
    height: 20px;
}

.loading-dots div {
    position: absolute;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: loading-dots 1.2s linear infinite;
}

.loading-dots div:nth-child(1) {
    left: 4px;
    animation-delay: 0s;
}

.loading-dots div:nth-child(2) {
    left: 16px;
    animation-delay: -0.4s;
}

.loading-dots div:nth-child(3) {
    left: 28px;
    animation-delay: -0.8s;
}

@keyframes loading-dots {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 消息状态 */
.message-status {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.message.user .message-status {
    text-align: right;
}

.message-status.sending {
    color: #ff9800;
}

.message-status.sent {
    color: #4caf50;
}

.message-status.failed {
    color: #f44336;
    cursor: pointer;
}

/* 快捷回复按钮区域 */
.quick-replies-container {
    margin: 0 0 8px 0;
    padding: 0;
}

.quick-replies-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-reply-btn {
    background: #ffffff;
    border: 1px solid rgba(37, 99, 235, 0.2);
    color: #1e40af;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
}

.quick-reply-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.quick-reply-btn:hover {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: rgba(37, 99, 235, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.quick-reply-btn:hover::before {
    transform: scaleY(1);
}

.quick-reply-btn:active {
    transform: translateY(0);
}

/* 滚动到底部按钮 */
.scroll-to-bottom {
    position: absolute;
    bottom: 140px;
    right: 20px;
    width: 35px;
    height: 35px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.scroll-to-bottom:hover {
    background: rgba(0, 0, 0, 0.8);
}

.scroll-to-bottom.show {
    display: flex;
}
