/* AI聊天窗口样式 */

/* 聊天组件容器 */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* 聊天按钮 */
.chat-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #0052d9 0%, #003cab 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 82, 217, 0.4);
    transition: all 0.3s ease;
}

.chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 82, 217, 0.6);
}

.chat-button-icon {
    font-size: 20px;
}

.chat-button-text {
    font-size: 14px;
    font-weight: 500;
}

/* 聊天窗口 - 以1440x900为标准 */
.chat-window {
    position: absolute;
    bottom: 10px;
    right: 0;
    width: 480px;
    height: auto;
    min-height: 520px;
    max-height: calc(100vh - 60px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 82, 217, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 82, 217, 0.1);
}

.chat-window.hidden {
    display: none;
}

/* 头部 */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: linear-gradient(135deg, #0052d9 0%, #003cab 100%);
    color: white;
    flex-shrink: 0;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-avatar {
    font-size: 24px;
}

.chat-header-name {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-status {
    font-size: 12px;
    opacity: 0.9;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 人工客服按钮特殊样式 */
.chat-header-btn.transfer-btn {
    width: auto;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.25);
}

/* 消息区域 - 固定高度 */
.chat-messages {
    flex: none;
    height: 420px;
    max-height: 420px;
    overflow-y: auto;
    padding: 20px;
    background: #f5f7fa;
    scroll-behavior: smooth;
    position: relative;
}

.message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.ai {
    align-items: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: linear-gradient(135deg, #0052d9 0%, #003cab 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    line-height: 1.6;
}

.message.user .message-content {
    background: linear-gradient(135deg, #0052d9 0%, #003cab 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 82, 217, 0.3);
    line-height: 1.6;
}

.message.system {
    align-items: center;
}

.message.system .message-content {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    font-size: 13px;
    max-width: 90%;
    text-align: center;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* 快捷操作按钮 */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
}

.quick-action-btn {
    padding: 6px 12px;
    background: #f0f5ff;
    border: 1px solid #d9e6ff;
    border-radius: 16px;
    color: #0052d9;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: #0052d9;
    color: white;
    border-color: #0052d9;
}

/* 示例对话区域 */
.chat-examples {
    flex: 1;
    padding: 10px;
    background: #f9f9ff;
    border-top: 1px solid #eee;
    min-height: 200px;
    overflow-y: auto;
}

.chat-examples.hidden {
    display: none;
}

.examples-title {
    font-size: 14px;
    color: #0052d9;
    margin-bottom: 8px;
    font-weight: 500;
}

.examples-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.example-category {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-label {
    font-size: 14px;
    color: #666;
    font-weight: 600;
    padding: 2px 0;
    border-bottom: 1px solid #e8e8ff;
    margin-bottom: 2px;
}

.example-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e0e0ff;
    border-radius: 8px;
    color: #555;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    line-height: 1.5;
    width: 100%;
}

.example-btn:hover {
    background: #f0f5ff;
    border-color: #0052d9;
    color: #0052d9;
    transform: translateX(2px);
}

/* 输入区域 */
.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: white;
    border-top: 2px solid #e0e8ff;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #0052d9;
}

.chat-send-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #0052d9 0%, #003cab 100%);
    border: none;
    border-radius: 20px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: fit-content;
}

.typing-indicator::before {
    content: "小智正在输入";
    font-size: 12px;
    color: #999;
    margin-right: 4px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #0052d9;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 回到底部按钮 */
.scroll-bottom-btn {
    position: absolute;
    bottom: 120px;
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 12px;
    color: #0052d9;
    transition: all 0.2s;
    z-index: 10;
}

.scroll-bottom-btn:hover {
    background: #f0f5ff;
    border-color: #0052d9;
    transform: translateY(-2px);
}

.scroll-bottom-btn.hidden {
    display: none;
}

.scroll-bottom-btn span:first-child {
    font-size: 16px;
    line-height: 1;
}

/* iframe嵌入模式：聊天窗口占满整个iframe */
.in-iframe .chat-widget {
    position: static;
    width: 100%;
    height: 100%;
}

.in-iframe .chat-window {
    position: static;
    width: 100%;
    height: 100%;
    min-height: auto;
    max-height: none;
    border-radius: 16px;
    box-shadow: none;
    border: none;
    overflow: hidden;
}

/* iframe 模式下消息区域自适应高度 */
.in-iframe .chat-messages {
    flex: 1 1 auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow-y: auto !important;
}

/* 1440px屏幕优化 */
@media (min-width: 1400px) {
    .chat-window {
        width: 520px;
    }
}

@media (min-width: 1600px) {
    .chat-window {
        width: 560px;
    }
}

/* ========== 咨询信息收集模态框样式 ========== */

/* 遮罩层 */
.consultation-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 表单容器 */
.consultation-form-container {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

/* 表单头部 */
.consultation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.consultation-header h4 { margin:0; font-size:18px; color:#333; }
.consultation-close {
    background:none; border:none; font-size:24px; cursor:pointer;
    color:#999; line-height:1; transition:color .2s;
}
.consultation-close:hover { color:#333; }

/* 表单内容区 */
.consultation-body { padding:20px; }
.form-field { margin-bottom:16px; }
.form-field label { display:block; margin-bottom:6px; font-size:14px; color:#555; }
.required-mark { color:#e74c3c; margin-right:2px; }
.form-field span { color:#999; font-size:12px; }
.form-field input, .form-field textarea {
    width:100%; padding:10px 12px; border:1px solid #ddd; border-radius:6px;
    font-size:14px; box-sizing:border-box; outline:none; transition:border-color .2s;
}
.form-field input:focus, .form-field textarea:focus { border-color:#0052d9; }
.form-field textarea { resize:vertical; min-height:80px; }

/* 表单底部按钮区 */
.consultation-footer {
    display:flex; gap:10px; padding:16px 20px;
    border-top:1px solid #eee; justify-content:flex-end;
}
.btn-cancel, .btn-submit {
    padding:8px 20px; border:none; border-radius:6px;
    font-size:14px; cursor:pointer; transition:all .2s;
}
.btn-cancel { background:#f5f5f5; color:#666; }
.btn-cancel:hover { background:#e0e0e0; }
.btn-submit { background:#0052d9; color:white; }
.btn-submit:hover { background:#003cab; }
