/* ========================================
   在线客服聊天窗口样式
   ======================================== */

.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 90px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========== 悬浮按钮 ========== */
.chat-widget-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #b00020 0%, #d32f2f 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(176, 0, 32, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chat-widget-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(176, 0, 32, 0.5);
}

.chat-widget-toggle .chat-icon {
    width: 28px;
    height: 24px;
    position: relative;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 700;
    color: #b00020;
    letter-spacing: 1px;
}

.chat-widget-toggle .chat-icon::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 6px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-top: 6px solid #fff;
    border-right: 5px solid transparent;
}

/* 未读消息角标 */
.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    background: #ff4d4f;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========== 聊天面板 ========== */
.chat-widget-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.chat-widget-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 头部 */
.chat-widget-header {
    background: linear-gradient(135deg, #b00020 0%, #d32f2f 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-title {
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-close {
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
}

.chat-widget-close:hover {
    opacity: 1;
}

/* 消息列表 */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* 消息气泡 */
.chat-message {
    display: flex;
    max-width: 80%;
}

.chat-message.visitor {
    align-self: flex-end;
    justify-content: flex-end;
}

.chat-message.agent {
    align-self: flex-start;
    justify-content: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    word-break: break-word;
}

.chat-message.visitor .chat-bubble {
    background: linear-gradient(135deg, #b00020 0%, #d32f2f 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.agent .chat-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* 输入区域 */
.chat-widget-input {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-widget-textarea {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    line-height: 1.5;
}

.chat-widget-textarea:focus {
    border-color: #b00020;
}

.chat-widget-textarea::placeholder {
    color: #999;
}

.chat-widget-send {
    background: linear-gradient(135deg, #b00020 0%, #d32f2f 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    height: 40px;
}

.chat-widget-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(176, 0, 32, 0.3);
}

.chat-widget-send:active {
    transform: translateY(0);
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 20px;
        right: 72px;
    }
    
    .chat-widget-toggle {
        width: 52px;
        height: 52px;
    }
    
    .chat-widget-toggle .chat-icon {
        font-size: 24px;
    }
    
    .chat-widget-panel {
        width: calc(100vw - 40px);
        height: 60vh;
        max-height: 500px;
        bottom: 62px;
        right: -52px; /* 往右偏移，让窗口整体在屏幕内，左右各留20px边距 */
    }
}

/* ========== 客服后台样式 ========== */
.chat-admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.chat-admin-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 100px);
}

.chat-session-list {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
}

.chat-session-list-header {
    padding: 16px;
    background: #fafafa;
    border-bottom: 1px solid #e8e8e8;
    font-weight: 600;
}

.chat-session-items {
    flex: 1;
    overflow-y: auto;
}

.chat-session-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.chat-session-item:hover {
    background: #f5f5f5;
}

.chat-session-item.active {
    background: #fff5f5;
    border-left: 3px solid #b00020;
}

.chat-session-item .session-name {
    font-weight: 500;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-session-item .session-unread {
    background: #ff4d4f;
    color: #fff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.chat-session-item .session-preview {
    font-size: 13px;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-session-item .session-time {
    font-size: 12px;
    color: #bbb;
    margin-top: 4px;
}

/* 删除按钮 */
.chat-session-item .session-delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0;
}

.chat-session-item:hover .session-delete-btn {
    opacity: 1;
}

.chat-session-item .session-delete-btn:hover {
    color: #ff4d4f;
    background: #fff1f0;
}

.chat-session-item .session-delete-btn svg {
    width: 16px;
    height: 16px;
}

.chat-panel {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    font-weight: 600;
    background: #fafafa;
}

.chat-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-panel-input {
    padding: 16px 20px;
    border-top: 1px solid #e8e8e8;
    display: flex;
    gap: 12px;
}

.chat-panel-input textarea {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
}

.chat-panel-input textarea:focus {
    border-color: #b00020;
}

.chat-panel-input button {
    background: linear-gradient(135deg, #b00020 0%, #d32f2f 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-panel-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(176, 0, 32, 0.3);
}

.chat-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
}
