/**
 * 聊天窗口样式 - 轻量化、SEO友好
 */

/* 主容器 */
.knmc-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: block !important; /* 强制显示聊天按钮 */
}

/* 位置设置 */
.knmc-chat-bottom_right {
    bottom: 20px;
    right: 20px;
}

.knmc-chat-bottom_left {
    bottom: 20px;
    left: 20px;
}

/* 尺寸设置 */
.knmc-chat-normal .knmc-chat-window {
    width: 380px;
    height: 600px;
}

.knmc-chat-small .knmc-chat-window {
    width: 320px;
    height: 500px;
}

.knmc-chat-large .knmc-chat-window {
    width: 450px;
    height: 700px;
}

/* 聊天按钮 - 带Contact US文字 */
.knmc-chat-button {
    min-width: 60px;
    height: 60px;
    padding: 0 16px;
    background: #FF9860 !important; /* 强制橙色 */
    background-color: #FF9860 !important; /* 强制橙色 */
    border-radius: 30px;
    display: flex !important; /* 确保显示 */
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(255, 152, 96, 0.3);
    transition: all 0.3s ease;
    color: white !important;
    position: relative;
    z-index: 999999 !important;
    pointer-events: auto !important; /* 确保可点击 */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: rgba(255, 152, 96, 0.3); /* 移动端点击高亮 */
    touch-action: manipulation; /* 优化移动端触摸响应 */
}

/* 强制覆盖任何可能的蓝色样式 */
#knmc-chat-toggle,
.knmc-chat-button,
.knmc-chat-widget .knmc-chat-button {
    background: #FF9860 !important;
    background-color: #FF9860 !important;
    color: white !important;
}

.knmc-chat-button-text {
    font-size: 14px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.knmc-chat-button:hover {
    transform: scale(1.1);
    background: #E8854D !important; /* 强制橙色 */
    box-shadow: 0 6px 16px rgba(255, 152, 96, 0.4);
}

.knmc-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #E67A3D;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(230, 122, 61, 0.3);
}

/* 聊天窗口 */
.knmc-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none; /* 默认隐藏，只有点击按钮后才显示 */
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    z-index: 999998;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.knmc-chat-bottom_left .knmc-chat-window {
    right: auto;
    left: 0;
}

/* 窗口头部 */
.knmc-chat-header {
    background: #FF9860 !important;
    background-color: #FF9860 !important;
    color: white !important;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.knmc-chat-header-info {
    flex: 1;
}

.knmc-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    margin-bottom: 4px;
}

.knmc-chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    display: inline-block;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.5);
}

.knmc-chat-status-dot.offline {
    background: #9E9E9E;
    box-shadow: none;
}

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

.knmc-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.knmc-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

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

.knmc-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

.knmc-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #E8854D;
}

.knmc-chat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.knmc-chat-message.visitor {
    align-items: flex-end;
}

.knmc-chat-message.agent {
    align-items: flex-start;
}

.knmc-chat-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
}

.knmc-chat-message.visitor .knmc-chat-message-bubble {
    background: #FF9860 !important;
    background-color: #FF9860 !important;
    color: white !important;
    border-bottom-right-radius: 4px;
}

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

.knmc-chat-message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    padding: 0 4px;
}

.knmc-chat-welcome {
    text-align: center;
    color: #6c757d;
    padding: 20px;
}

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

.knmc-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#knmc-chat-input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 10px 16px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    max-height: 120px;
    overflow-y: auto;
}

#knmc-chat-input:focus {
    outline: none;
    border-color: #FF9860;
}

.knmc-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #FF9860 !important;
    background-color: #FF9860 !important;
    color: white !important;
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.knmc-chat-send-btn:hover {
    background: #E8854D !important;
    background-color: #E8854D !important;
}

.knmc-chat-send-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* 离线表单 */
.knmc-chat-offline-form {
    padding: 16px;
    background: #f8f9fa;
    max-height: 500px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* 表单响应式布局 */
.knmc-form-group {
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
}

.knmc-form-group input,
.knmc-form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
    resize: vertical; /* 允许垂直调整大小 */
}

/* 移动端表单优化 */
@media (max-width: 480px) {
    .knmc-chat-offline-form {
        padding: 12px;
    }
    
    .knmc-form-group {
        margin-bottom: 10px;
    }
    
    .knmc-form-group input,
    .knmc-form-group textarea {
        padding: 8px 12px;
        font-size: 14px; /* 防止iOS自动缩放 */
    }
    
    .knmc-form-group label {
        font-size: 12px;
    }
}

.knmc-chat-form-message {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    color: #6c757d;
    font-size: 13px;
}

.knmc-form-group {
    margin-bottom: 12px;
}

.knmc-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.knmc-form-group input,
.knmc-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.knmc-form-group input:focus,
.knmc-form-group textarea:focus {
    outline: none;
    border-color: #FF9860;
}

.knmc-form-submit {
    width: 100%;
    padding: 12px;
    background: #FF9860 !important;
    background-color: #FF9860 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.knmc-form-submit:hover {
    background: #E8854D !important;
    background-color: #E8854D !important;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .knmc-chat-widget {
        bottom: 10px;
        right: 10px;
        left: auto; /* 保持右侧对齐 */
    }
    
    .knmc-chat-window {
        width: calc(100vw - 20px) !important;
        max-width: 380px;
        height: calc(100vh - 100px) !important;
        max-height: 600px;
        bottom: 80px;
        right: 10px;
        left: auto;
        border-radius: 12px;
    }
    
    .knmc-chat-button {
        width: auto;
        min-width: 56px;
        height: 56px;
        padding: 0 12px;
    }
    
    .knmc-chat-button-text {
        font-size: 12px;
    }
}

/* 小屏幕设备 */
@media (max-width: 480px) {
    .knmc-chat-window {
        width: calc(100vw - 20px) !important;
        right: 10px;
        left: 10px;
    }
    
    .knmc-chat-button {
        padding: 0 10px;
    }
    
    .knmc-chat-button-text {
        font-size: 11px;
    }
}

/* 隐藏状态 */
.knmc-chat-widget.hidden .knmc-chat-window {
    display: none;
}

/* 加载动画 */
.knmc-chat-loading {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}

.knmc-chat-loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

