/**
 * ChestnutCMS 客服组件样式
 */

/* 客服容器 */
.customer-service-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* 竖直长方形客服按钮，贴右边，距离底部120px，文字竖排 */
.cs-float-button {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px; /* 竖直按钮宽度 */
    height: 140px; /* 竖直按钮高度 */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    color: white;
    z-index: 10000;
    right: 0;
    bottom: 120px;
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-left: none;
    padding: 0;
}

.cs-float-button .cs-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 10px;
    margin-right: 0;
}

.cs-float-button .cs-button-text {
    display: inline-block;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    margin: 0;
    letter-spacing: 2px;
}

.cs-float-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #5a6fd8 0%, #5a3b8a 100%);
}

/* 兼容原有定位类，强制贴右边 */
.cs-float-button.bottom-right,
.cs-float-button.top-right {
    right: 0 !important;
    left: auto !important;
}
.cs-float-button.bottom-left,
.cs-float-button.top-left {
    left: 0 !important;
    right: auto !important;
    border-radius: 0 8px 8px 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* 移除原有圆形样式 */
/* border-radius: 50%; 被覆盖为8px圆角 */

/* 聊天窗口 */
.cs-chat-window {
    position: fixed;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    z-index: 10000;
}

/* 聊天窗口底部距离页面底部80px */
.cs-chat-window.bottom-right {
    bottom: 80px;
    right: 20px;
}

.cs-chat-window.bottom-left {
    bottom: 80px;
    left: 20px;
}

.cs-chat-window.top-right {
    top: 20px;
    right: 20px;
}

.cs-chat-window.top-left {
    top: 20px;
    left: 20px;
}

/* 聊天窗口头部 */
.cs-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.cs-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
}

.cs-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 2px;
}

.cs-status {
    font-size: 12px;
    opacity: 0.9;
}

.cs-status.online {
    color: #52c41a;
}

.cs-status.offline {
    color: #ff4d4f;
}

.cs-header-actions {
    display: flex;
    gap: 8px;
}

.cs-btn-minimize,
.cs-btn-close {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color 0.2s;
}

.cs-btn-minimize:hover,
.cs-btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 消息区域 */
.cs-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    max-height: 300px;
    background: #f8f9fa;
}

.cs-message {
    margin-bottom: 16px;
    display: flex;
}

.cs-message-left {
    justify-content: flex-start;
}

.cs-message-right {
    justify-content: flex-end;
}

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

.cs-message-text {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.cs-message-left .cs-message-text {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.cs-message-right .cs-message-text {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.cs-message-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.cs-message-time {
    font-size: 11px;
    color: #999;
}

.cs-message-left .cs-message-meta {
    text-align: left;
}

.cs-message-right .cs-message-meta {
    text-align: right;
    flex-direction: row-reverse;
}

/* 已读状态样式 */
.cs-read-status {
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.cs-read-status.read {
    color: #52c41a;
}

.cs-read-status.unread {
    color: #faad14;
}

.cs-icon-check::before {
    content: '✓';
    font-weight: bold;
}

/* 输入区域 */
.cs-input-area {
    border-top: 1px solid #e8e8e8;
    background: white;
}

.cs-input-toolbar {
    display: flex;
    padding: 8px 16px;
    gap: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.cs-btn-emoji,
.cs-btn-file,
.cs-btn-quick {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background-color 0.2s;
}

.cs-btn-emoji:hover,
.cs-btn-file:hover,
.cs-btn-quick:hover {
    background: #e6e6e6;
}

.cs-btn-quick {
    background: #e6f7ff;
    border: 1px solid #91d5ff;
}

.cs-btn-quick:hover {
    background: #bae7ff;
}

.cs-input-wrapper {
    display: flex;
    padding: 12px 16px;
    gap: 12px;
    align-items: flex-end;
}

.cs-input {
    flex: 1;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.cs-input:focus {
    border-color: #667eea;
}

.cs-btn-send {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.cs-btn-send:hover {
    background: #5a6fd8;
}

.cs-btn-send:active {
    background: #4c63d2;
}

/* 深色主题 */
.cs-chat-window.dark {
    background: #2f2f2f;
    color: white;
}

.cs-chat-window.dark .cs-header {
    background: linear-gradient(135deg, #434343 0%, #000000 100%);
}

.cs-chat-window.dark .cs-messages {
    background: #1f1f1f;
}

.cs-chat-window.dark .cs-message-left .cs-message-text {
    background: #3f3f3f;
    color: white;
}

.cs-chat-window.dark .cs-input-area {
    background: #2f2f2f;
    border-top-color: #404040;
}

.cs-chat-window.dark .cs-input {
    background: #3f3f3f;
    border-color: #555;
    color: white;
}

.cs-chat-window.dark .cs-input:focus {
    border-color: #667eea;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .cs-chat-window {
        width: calc(100vw - 40px) !important;
        height: calc(100vh - 160px) !important;
        bottom: 60px !important;
        right: 20px !important;
        left: 20px !important;
    }

    .cs-float-button {
        bottom: 60px;
        width: 36px;
        height: 100px;
        padding: 0;
    }
    .cs-float-button .cs-icon {
        width: 16px;
        height: 16px;
        margin-bottom: 6px;
    }
    .cs-float-button .cs-button-text {
        font-size: 12px;
        letter-spacing: 1px;
    }

    .cs-messages {
        max-height: calc(100vh - 300px);
    }
}

/* 滚动条样式 */
.cs-messages::-webkit-scrollbar {
    width: 6px;
}

.cs-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.cs-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.cs-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 动画效果 */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cs-chat-window {
    animation: slideInUp 0.3s ease-out;
}

/* 消息动画 */
@keyframes messageSlideIn {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cs-message {
    animation: messageSlideIn 0.2s ease-out;
}

/* 重连动画效果 */
@keyframes reconnectPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

.cs-chat-window.cs-reconnected {
    animation: reconnectPulse 1s ease-out;
}

/* 留言模式指示器 */
.cs-message-mode-indicator {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    background: #fff7e6;
    color: #fa8c16;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    border: 1px solid #ffd666;
    animation: messageModePulse 2s infinite;
}

@keyframes messageModePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 系统消息样式增强 */
.cs-message.cs-message-system {
    justify-content: center;
    margin: 8px 0;
}

.cs-message.cs-message-system .cs-message-content {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 8px 16px;
    font-size: 12px;
    color: #0369a1;
    text-align: center;
    max-width: 80%;
}

.cs-message.cs-message-system.success .cs-message-content {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.cs-message.cs-message-system.warning .cs-message-content {
    background: #fffbeb;
    border-color: #fed7aa;
    color: #ea580c;
}

.cs-message.cs-message-system.error .cs-message-content {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}
