/**
 * 客服系统样式 - 独立版本
 * 版本: 2.0
 */

/* 基础容器 */
.customer-service-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 默认位置 - 右下角 */
.customer-service-widget.cs-position-default {
    right: 20px;
    bottom: 20px;
}

/* 预设位置 */
.customer-service-widget.cs-left {
    left: 20px;
}

.customer-service-widget.cs-right {
    right: 20px;
}

.customer-service-widget.cs-bottom {
    bottom: 80px;  /* 从20px改为80px，向上提60px */
}

.customer-service-widget.cs-top {
    top: 20px;
}

/* 悬浮球 */
.cs-float-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.cs-float-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.cs-float-button .cs-icon {
    width: 32px;
    height: 32px;
    color: white;
}

.cs-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

/* 聊天窗口 */
.cs-chat-window {
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 10px;
}

/* 聊天头部 */
.cs-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.cs-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cs-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-header-avatar svg {
    width: 24px;
    height: 24px;
}

.cs-header-info {
    display: flex;
    flex-direction: column;
}

.cs-header-title {
    font-size: 16px;
    font-weight: bold;
}

.cs-header-status {
    font-size: 12px;
    opacity: 0.9;
}

.cs-header-actions {
    display: flex;
    gap: 5px;
}

.cs-header-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.cs-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cs-header-actions button svg {
    width: 16px;
    height: 16px;
}

/* 消息列表 */
.cs-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.cs-messages::-webkit-scrollbar {
    width: 6px;
}

.cs-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cs-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.cs-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 欢迎消息 */
.cs-welcome-message {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

.cs-welcome-icon {
    width: 48px;
    height: 48px;
    color: #667eea;
    margin-bottom: 10px;
}

.cs-welcome-message p {
    margin: 5px 0;
    font-size: 14px;
}

.cs-welcome-sub {
    font-size: 12px;
    color: #bbb;
}

/* 消息项 */
.cs-message {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cs-message.cs-user {
    flex-direction: row-reverse;
}

.cs-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cs-message-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.cs-message.cs-admin .cs-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.cs-message.cs-user .cs-message-avatar {
    background: #42a5f5;
}

.cs-message-content {
    max-width: 70%;
}

.cs-message-bubble {
    padding: 10px 15px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.cs-message.cs-admin .cs-message-bubble {
    background: white;
    color: #333;
    border-radius: 12px 12px 12px 4px;
}

.cs-message.cs-user .cs-message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

.cs-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 5px;
}

.cs-message.cs-user .cs-message-time {
    text-align: right;
}

/* 系统消息 */
.cs-system-message {
    text-align: center;
    padding: 8px 15px;
    margin: 10px auto;
    color: #999;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.cs-system-icon {
    width: 14px;
    height: 14px;
}

/* 正在输入提示 */
.cs-typing-indicator {
    padding: 10px 15px;
    display: flex;
    gap: 4px;
}

.cs-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.cs-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.cs-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 输入区域 */
.cs-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.cs-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.cs-input:focus {
    outline: none;
    border-color: #667eea;
}

.cs-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.cs-send-btn:hover {
    transform: scale(1.05);
}

.cs-send-btn:active {
    transform: scale(0.95);
}

.cs-send-btn svg {
    width: 20px;
    height: 20px;
}

/* 主题 - 蓝色 */
.customer-service-widget.cs-theme-blue .cs-float-button,
.customer-service-widget.cs-theme-blue .cs-chat-header,
.customer-service-widget.cs-theme-blue .cs-send-btn {
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
}

.customer-service-widget.cs-theme-blue .cs-message.cs-user .cs-message-bubble {
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
}

.customer-service-widget.cs-theme-blue .cs-welcome-icon {
    color: #42a5f5;
}

.customer-service-widget.cs-theme-blue .cs-message.cs-admin .cs-message-avatar {
    background: linear-gradient(135deg, #42a5f5 0%, #1e88e5 100%);
}

/* 主题 - 绿色 */
.customer-service-widget.cs-theme-green .cs-float-button,
.customer-service-widget.cs-theme-green .cs-chat-header,
.customer-service-widget.cs-theme-green .cs-send-btn {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
}

.customer-service-widget.cs-theme-green .cs-message.cs-user .cs-message-bubble {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
}

.customer-service-widget.cs-theme-green .cs-welcome-icon {
    color: #66bb6a;
}

.customer-service-widget.cs-theme-green .cs-message.cs-admin .cs-message-avatar {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
}

/* 响应式设计 */
@media (max-width: 480px) {
    .cs-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        position: fixed;
        bottom: 0;
        left: 10px;
        right: 10px;
    }
    
    .customer-service-widget.cs-left,
    .customer-service-widget.cs-right {
        left: auto;
        right: 20px;
    }
}

/* 暗黑模式支持 */
@media (prefers-color-scheme: dark) {
    .cs-chat-window {
        background: #2d2d2d;
    }
    
    .cs-messages {
        background: #1a1a1a;
    }
    
    .cs-message.cs-admin .cs-message-bubble {
        background: #3d3d3d;
        color: #e0e0e0;
    }
    
    .cs-input-area {
        background: #2d2d2d;
        border-top-color: #3d3d3d;
    }
    
    .cs-input {
        background: #3d3d3d;
        color: #e0e0e0;
        border-color: #4d4d4d;
    }
    
    .cs-input:focus {
        border-color: #667eea;
    }
}

/* 图片上传按钮 */
.cs-image-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cs-image-btn:hover {
    background: #e0e0e0;
    border-color: #ccc;
    color: #333;
}

.cs-image-btn svg {
    width: 20px;
    height: 20px;
}

/* 图片预览区域 */
.cs-image-preview {
    padding: 10px 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.cs-image-preview img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 8px;
    border: 1px solid #ddd;
    object-fit: cover;
}

.cs-preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s;
}

.cs-preview-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* 图片消息 */
.cs-message-image {
    max-width: 200px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.cs-message-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.2s;
}

.cs-message-image img:hover {
    transform: scale(1.02);
}

/* 暗色主题下的图片按钮 */
.customer-service-widget.cs-dark-theme .cs-image-btn {
    background: #3d3d3d;
    border-color: #4d4d4d;
    color: #e0e0e0;
}

.customer-service-widget.cs-dark-theme .cs-image-btn:hover {
    background: #4d4d4d;
    border-color: #5d5d5d;
}

.customer-service-widget.cs-dark-theme .cs-image-preview {
    background: #2d2d2d;
    border-top-color: #3d3d3d;
}
