/* AI 客服 - 一体式页面 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f0f2f5; height: 100vh; }

.app-container { display: flex; height: 100vh; }

/* ========== 左侧管理后台 ========== */
.admin-panel {
    width: 380px;
    min-width: 380px;
    background: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e8e8e8;
    overflow: hidden;
}
.admin-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.admin-header h1 { font-size: 18px; color: #1a1a2e; margin-bottom: 4px; }
.admin-header p { font-size: 12px; color: #999; }

.admin-tabs { display: flex; border-bottom: 1px solid #eee; padding: 0 16px; }
.tab-btn {
    padding: 10px 16px;
    border: none;
    background: none;
    font-size: 13px;
    cursor: pointer;
    color: #888;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.tab-btn.active { color: #667eea; border-bottom-color: #667eea; font-weight: 600; }
.tab-btn:hover { color: #667eea; }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 16px; }
.tab-content.active { display: flex; flex-direction: column; }

/* 添加表单 */
.add-form {
    background: #f8f9ff;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}
.add-form input, .add-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    margin-bottom: 8px;
    transition: border-color 0.2s;
    font-family: inherit;
}
.add-form input:focus, .add-form textarea:focus { border-color: #667eea; }
.add-form textarea { resize: vertical; min-height: 60px; }

.form-row { display: flex; gap: 8px; }
.form-row input { flex: 1; margin-bottom: 0; }

.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-add { background: #667eea; color: white; }
.btn-add:hover { background: #5a6fd6; }
.btn-del { background: none; color: #ff4757; padding: 4px 10px; font-size: 12px; }
.btn-del:hover { background: #fff0f0; border-radius: 6px; }

/* 列表 */
.item-list { flex: 1; }
.empty-state {
    text-align: center;
    padding: 30px;
    color: #bbb;
    font-size: 13px;
}

.faq-item {
    background: #fafafa;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.faq-item .q { font-weight: 600; font-size: 13px; color: #333; margin-bottom: 2px; }
.faq-item .a { font-size: 12px; color: #666; line-height: 1.5; }
.faq-item .cat { display: inline-block; background: #f0f2ff; color: #667eea; padding: 1px 6px; border-radius: 3px; font-size: 11px; margin-top: 4px; }

.doc-item {
    background: #fafafa;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.doc-item .name { font-size: 13px; font-weight: 500; }
.doc-item .meta { font-size: 11px; color: #999; margin-top: 2px; }

/* 底部操作区（清空全部按钮） */
.admin-footer-actions {
    padding: 12px 0;
    border-top: 1px solid #f0f0f0;
    margin-top: auto;
    text-align: center;
}
.btn-reset-all {
    background: #fff1f0;
    color: #ff4757;
    border: 1px solid #ffd4d0;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}
.btn-reset-all:hover {
    background: #ff4757;
    color: white;
    border-color: #ff4757;
}

/* 上传区域 */
.upload-area {
    cursor: pointer;
    text-align: center;
    padding: 24px;
}
.upload-area:hover { background: #f0f2ff; }
.upload-icon { font-size: 28px; margin-bottom: 6px; }
.upload-area p { font-size: 13px; color: #666; }

/* ========== 右侧客服演示 ========== */
.chat-demo {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fb;
}

.demo-header {
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.demo-header-left { display: flex; align-items: center; gap: 12px; }
.badge {
    background: #52c41a;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.demo-title { font-size: 16px; font-weight: 600; color: #333; }
.demo-header-right { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #52c41a; display: inline-block; }
.status-text { font-size: 13px; color: #888; }
.btn-reset {
    background: none;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
}
.btn-reset:hover { background: #f5f5f5; }

.demo-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.demo-messages::-webkit-scrollbar { width: 4px; }
.demo-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.msg { display: flex; gap: 10px; max-width: 80%; animation: msgIn 0.3s ease; }
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

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

.msg-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.bot-avatar { background: #667eea; color: white; }
.user-avatar { background: #52c41a; color: white; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.msg-bot .msg-bubble { background: white; border: 1px solid #e8e8e8; border-bottom-left-radius: 4px; color: #333; }
.msg-user .msg-bubble { background: #667eea; color: white; border-bottom-right-radius: 4px; }

.demo-input {
    padding: 12px 24px 16px;
    background: white;
    border-top: 1px solid #e8e8e8;
}
.quick-btns { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.quick-btns button {
    padding: 5px 12px;
    border: 1px solid #ddd;
    border-radius: 14px;
    background: white;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}
.quick-btns button:hover { background: #667eea; color: white; border-color: #667eea; }

.input-row { display: flex; gap: 8px; }
.input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}
.input-row input:focus { border-color: #667eea; }

.btn-send {
    width: 38px; height: 38px; border-radius: 50%;
    background: #667eea; color: white; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.btn-send:hover { background: #5a6fd6; }

/* 加载动画 */
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #bbb; animation: t 1.4s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes t { 0%,60%,100% { opacity: 0.3; } 30% { opacity: 1; } }

/* Toast */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background: #333; color: white; padding: 10px 20px;
    border-radius: 8px; font-size: 13px; z-index: 99999;
    animation: ti 0.3s ease;
}
.toast.error { background: #ff4757; }
@keyframes ti { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; } }
