/* 智能客服样式表 */

/* 重置样式 */
* {
    box-sizing: border-box;
}

/* 悬浮按钮 */
.chat-widget-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    user-select: none;
}

.chat-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.chat-widget-icon {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 聊天窗口容器 */
.chat-widget-container {
    position: fixed;
    top: 50%;
    right: 20px;
    width: 380px;
    height: 700px;
    max-height: calc(100vh - 40px); /* 确保不超出视口高度，留出20px边距 */
    transform: translateY(-50%); /* 垂直居中 */
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .chat-widget-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        max-height: calc(100vh - 40px);
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
    }

    .chat-widget-toggle {
        bottom: 10px;
        right: 10px;
    }
}

/* 小屏幕适配 */
@media (max-height: 800px) {
    .chat-widget-container {
        height: calc(100vh - 40px);
        max-height: calc(100vh - 40px);
    }
}

/* 超小屏幕适配 */
@media (max-height: 600px) {
    .chat-widget-container {
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
    }
}

/* 聊天窗口头部 */
.chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-widget-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-title-text {
    flex: 1;
}

.chat-widget-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-widget-status {
    font-size: 12px;
    opacity: 0.8;
}

.chat-widget-actions {
    display: flex;
    gap: 8px;
}

.chat-widget-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.chat-widget-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 聊天消息区域 */
.chat-widget-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* 消息样式 */
.chat-widget-message {
    display: flex;
    gap: 12px;
    max-width: 100%;
}

.chat-widget-message-user {
    flex-direction: row-reverse;
}

.chat-widget-message-assistant {
    flex-direction: row;
}

.chat-widget-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden; /* 让图片圆角裁切 */
}

.chat-widget-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-widget-message-user .chat-widget-message-avatar {
    background: #667eea;
    color: white;
}

.chat-widget-message-assistant .chat-widget-message-avatar {
    background: #e9ecef;
    color: #6c757d;
}

.chat-widget-message-content {
    flex: 1;
    min-width: 0;
}

.chat-widget-message-user .chat-widget-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-widget-message-assistant .chat-widget-message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.chat-widget-message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    max-width: 280px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-widget-message-user .chat-widget-message-text {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-widget-message-assistant .chat-widget-message-text {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-widget-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-widget-message-feedback {
    margin-top: 8px;
    display: flex;
    gap: 12px; /* 间距更舒适 */
}

.chat-widget-feedback-btn {
    background: #fff;
    border: 1px solid #e3e7ee;
    color: #5f6b7a;
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

/* 有用/无用 的表情色彩区分 */
.chat-widget-feedback-yes svg {
    color: #22c55e; /* 绿色笑脸 */
}

.chat-widget-feedback-no svg {
    color: #ef4444; /* 红色哭脸 */
}

.chat-widget-feedback-yes.active,
.chat-widget-feedback-yes:hover {
    color: #1f9d4c;
}

.chat-widget-feedback-no.active,
.chat-widget-feedback-no:hover {
    color: #c23333;
}

.chat-widget-feedback-btn:hover {
    background: #f5f7ff;
    border-color: #667eea;
    color: #4f63e3;
    box-shadow: 0 2px 6px rgba(79, 99, 227, 0.15);
}

.chat-widget-feedback-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.chat-widget-feedback-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: #fff;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
}

/* 建议问题 */
.chat-widget-suggestions {
    margin-top: 8px;
}

.chat-widget-suggestions-title {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.chat-widget-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-widget-suggestion-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.chat-widget-suggestion-item:hover {
    background: #f8f9fa;
    border-color: #667eea;
    color: #667eea;
}

/* 输入区域 */
.chat-widget-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.chat-widget-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 24px;
    padding: 8px 16px;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s ease;
}

.chat-widget-input-wrapper:focus-within {
    border-color: #667eea;
}

.chat-widget-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
}

.chat-widget-input::placeholder {
    color: #999;
}

.chat-widget-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-widget-send-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: scale(1.05);
}

.chat-widget-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.chat-widget-input-tips {
    font-size: 11px;
    color: #999;
    margin-top: 6px;
    text-align: center;
}

/* 加载状态 */
.chat-widget-loading {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.chat-widget-loading-text {
    font-size: 14px;
    color: #666;
}

/* 反馈弹窗 */
.chat-widget-feedback-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1003;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.chat-widget-feedback-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
}

.chat-widget-feedback-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-feedback-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.chat-widget-feedback-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-feedback-close:hover {
    color: #666;
}

.chat-widget-feedback-body {
    padding: 20px;
}

.chat-widget-feedback-rating {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.chat-widget-feedback-btn {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e9ecef;
    background: white;
    color: #666;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-widget-feedback-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.chat-widget-feedback-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.chat-widget-feedback-comment textarea {
    width: 100%;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-widget-feedback-comment textarea:focus {
    border-color: #667eea;
}

.chat-widget-feedback-footer {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    text-align: right;
}

.chat-widget-feedback-submit {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-widget-feedback-submit:hover {
    background: #5a6fd8;
}

.chat-widget-feedback-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 动画效果 */
.chat-widget-container {
    animation: slideInUp 0.3s ease-out;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-widget-message {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 暗色主题支持 */
@media (prefers-color-scheme: dark) {
    .chat-widget-container {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    .chat-widget-messages {
        background: #2a2a2a;
    }

    .chat-widget-message-text {
        background: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-widget-message-assistant .chat-widget-message-text {
        background: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-widget-input-container {
        background: #1a1a1a;
        border-top-color: #3a3a3a;
    }

    .chat-widget-input-wrapper {
        background: #2a2a2a;
        border-color: #3a3a3a;
    }

    .chat-widget-input {
        color: #e0e0e0;
    }

    .chat-widget-input::placeholder {
        color: #888;
    }
}


/* FAQ 顶部面板 */
.chat-widget-faq-panel {
    background: #f3f5fb;
    border-bottom: 1px solid #e6e8f0;
    padding: 10px 20px 12px;
    max-height: 350px; /* 限制高度，避免遮挡聊天区 */
    overflow-y: auto; /* 超出滚动 */
}

.chat-widget-faq-title {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    position: sticky;
    top: 0;
    background: #f3f5fb;
    padding-top: 2px;
}

.chat-widget-faq-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.chat-widget-faq-item {
    background: #fff;
    border: 1px solid #e6e8f0;
    border-radius: 16px;
    padding: 8px 12px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-widget-faq-item:hover {
    background: #f8f9ff;
    border-color: #667eea;
    color: #4f63e3;
}

/* === 主题色覆盖：#18B0A3 === */
:root {
    --chat-primary: #18B0A3;
    --chat-primary-dark: #149788; /* 深一阶用于渐变/hover */
}

/* 顶部头部渐变 */
.chat-widget-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
}

/* 悬浮按钮颜色 */
.chat-widget-toggle {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    box-shadow: 0 4px 20px rgba(24, 176, 163, 0.4);
}
.chat-widget-toggle:hover {
    box-shadow: 0 6px 25px rgba(24, 176, 163, 0.6);
}

/* 用户消息气泡与头像底色 */
.chat-widget-message-user .chat-widget-message-text {
    background: var(--chat-primary);
}
.chat-widget-message-user .chat-widget-message-avatar {
    background: var(--chat-primary);
}

/* 发送按钮 */
.chat-widget-send-btn {
    background: var(--chat-primary);
}
.chat-widget-send-btn:hover:not(:disabled) {
    background: var(--chat-primary-dark);
}

/* 输入框聚焦边框 */
.chat-widget-input-wrapper:focus-within {
    border-color: var(--chat-primary);
}

/* 反馈按钮交互（即便已关闭，保留主题一致性） */
.chat-widget-feedback-btn:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
    box-shadow: 0 2px 6px rgba(24, 176, 163, 0.15);
}
.chat-widget-feedback-btn:focus {
    box-shadow: 0 0 0 3px rgba(24, 176, 163, 0.2);
}
.chat-widget-feedback-btn.active {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    border-color: var(--chat-primary);
}

/* 建议/FAQ 项 hover 色 */
.chat-widget-suggestion-item:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}
.chat-widget-faq-item:hover {
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}
