/* ============ 柯基表情状态体系 ============ */
/* 动效关键帧：作用于柯基本体(.chat-fab-corgi / .corgi-flat)，
   不与 #chatFab 的 hover 倾斜/浮动(fabFloaty)冲突——浮动/倾斜在 #chatFab 上，
   表情动画在柯基本体 img 上，二者层级独立 */
@keyframes corgiBob   { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
@keyframes corgiBounce{ 0%,100%{transform:translateY(0)} 30%{transform:translateY(-11px)} 50%{transform:translateY(0)} 65%{transform:translateY(-5px)} }
@keyframes corgiShake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-4px) rotate(-5deg)} 40%{transform:translateX(4px) rotate(5deg)} 60%{transform:translateX(-3px) rotate(-3deg)} 80%{transform:translateX(3px) rotate(3deg)} }
@keyframes corgiWave  { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-14deg)} 75%{transform:rotate(14deg)} }
/* corgiBlink 已废弃：整图 scaleY 压扁不是眨眼；聊天头像改用 SVG 内 .corgi-eyes 真眨眼，FAB 改用 corgiBob 浮动 */

/* FAB 柯基（3D 渲染图） */
.chat-fab[data-corgi-state="thinking"] .chat-fab-corgi { animation: corgiBob .9s ease-in-out infinite; }
.chat-fab[data-corgi-state="success"]  .chat-fab-corgi { animation: corgiBounce .6s ease; }
.chat-fab[data-corgi-state="error"]    .chat-fab-corgi { animation: corgiShake .5s ease; }
.chat-fab[data-corgi-state="welcome"]  .chat-fab-corgi { animation: corgiWave .6s ease; }
.chat-fab[data-corgi-state="idle"]     .chat-fab-corgi { animation: corgiBob 3.2s ease-in-out infinite; }

/* 聊天面板头像（扁平 SVG，聊天打开时 FAB 隐藏，状态落在这） */
.corgi-flat[data-corgi-state="thinking"] { animation: corgiBob .9s ease-in-out infinite; }
.corgi-flat[data-corgi-state="success"]  { animation: corgiBounce .6s ease; }
.corgi-flat[data-corgi-state="error"]    { animation: corgiShake .5s ease; }
.corgi-flat[data-corgi-state="welcome"]  { animation: corgiWave .6s ease; }
/* corgi-flat idle 不再整图眨；眨眼由 corgi-flat.svg 内 .corgi-eyes 层 opacity 脉冲实现
   （睁眼帧 corgi-3d.png ↔ 闭眼帧 corgi-blink.png 切换，非 scaleY 局部压扁——scaleY 压扁是早期被否的假眨眼） */

/* 心情气泡：思考(三点)/成功(✓)/错误(!)，浮在可见柯基正上方 */
.corgi-mood {
    position: fixed;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 26px;
    padding: 0 9px;
    border-radius: 14px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 3px 12px rgba(0,0,0,.2);
    font-size: 15px;
    font-weight: 800;
    pointer-events: none;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.corgi-mood::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fff;
    border-bottom: 0;
}
.corgi-mood.thinking { color: #2563eb; }
.corgi-mood.thinking span {
    display: inline-block;
    width: 5px; height: 5px;
    margin: 0 1.5px;
    border-radius: 50%;
    background: #2563eb;
    animation: corgiDot 1s infinite ease-in-out;
}
.corgi-mood.thinking span:nth-child(2) { animation-delay: .15s; }
.corgi-mood.thinking span:nth-child(3) { animation-delay: .3s; }
.corgi-mood.success { background: #16a34a; color: #fff; }
.corgi-mood.success::after { border-top-color: #16a34a; }
.corgi-mood.error { background: #dc2626; color: #fff; }
.corgi-mood.error::after { border-top-color: #dc2626; }
@keyframes corgiDot { 0%,60%,100%{opacity:.3; transform:translateY(0)} 30%{opacity:1; transform:translateY(-3px)} }
.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    z-index: 1052;
    animation: chatSlideUp 0.25s ease;
}
@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-header {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
}
.chat-title i { font-size: 20px; }
.chat-header-actions { display: flex; gap: 4px; }
.chat-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}
.chat-header-btn:hover { background: rgba(255, 255, 255, 0.3); }
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7f8fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-body::-webkit-scrollbar { width: 5px; }
.chat-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }

/* 消息气泡 */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
    animation: msgFadeIn 0.3s ease;
}
.chat-msg-content {
    min-width: 0;
    max-width: 100%;
    flex: 1;
}
@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}
.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.chat-msg.assistant .chat-msg-avatar {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
}
.chat-msg.user .chat-msg-avatar {
    background: var(--gray-200);
    color: var(--gray-700);
}
.chat-msg.system .chat-msg-avatar {
    background: var(--success-light);
    color: var(--success);
}
.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}
.chat-msg.assistant .chat-msg-bubble {
    background: #ffffff;
    color: var(--gray-900);
    border: 1px solid var(--gray-200);
    border-top-left-radius: 4px;
}
.chat-msg.user .chat-msg-bubble {
    background: var(--primary);
    color: #fff;
    border-top-right-radius: 4px;
}
.chat-msg.system .chat-msg-bubble {
    background: var(--success-light);
    color: var(--success);
    font-size: 12.5px;
    text-align: center;
    border-radius: 8px;
}

/* RAG 参考来源：强制换行/截断，防止长链接顶出对话框 */
.chat-sources {
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--gray-600);
    margin-top: 4px;
}
.chat-sources .badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* AI正在输入 */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}
.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-300);
    animation: typingBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 项目确认卡片 */
.chat-project-card {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 14px;
    margin-top: 8px;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    box-sizing: border-box;
}
.chat-project-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    word-break: break-word;
}
.chat-project-card-title i { color: var(--primary); }
.chat-project-card table {
    width: 100%;
    font-size: 12.5px;
    border-collapse: collapse;
    table-layout: fixed;
}
/* ==================== 定向推荐树形选择 ==================== */
.recommend-tree { max-height: 360px; overflow-y: auto; border: 1px solid var(--gray-200); border-radius: 8px; padding: 4px 0; }
.recommend-tree-item {
    display: flex; align-items: center; padding: 8px 12px; cursor: pointer;
    transition: background .15s; border-radius: 0;
    user-select: none; -webkit-user-select: none;
}
.recommend-tree-item:hover { background: var(--gray-50); }
.recommend-tree-item.selected { background: #e8f4fd; color: var(--primary); font-weight: 600; }
.recommend-tree-item .toggle-icon {
    width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
    margin-right: 6px; font-size: 12px; color: var(--gray-500); flex-shrink: 0;
    transition: transform .2s;
}
.recommend-tree-item .toggle-icon.expanded { transform: rotate(90deg); }
.recommend-tree-item .tree-label { flex: 1; font-size: 13px; }
.recommend-tree-item .tree-badge { font-size: 11px; color: var(--gray-400); margin-left: 6px; flex-shrink: 0; }
.recommend-tree-children { overflow: hidden; transition: max-height .25s ease; }
.recommend-tree-children.collapsed { max-height: 0 !important; }
.recommend-tree-child { padding-left: 36px; }
.recommend-tree-section-title {
    padding: 8px 12px 4px; font-size: 11px; font-weight: 700; color: var(--gray-400);
    text-transform: uppercase; letter-spacing: .5px;
}
.recommend-tree-empty { padding: 24px; text-align: center; color: var(--gray-400); font-size: 13px; }

.chat-project-card table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: top;
}
.chat-project-card table td:first-child {
    color: var(--gray-500);
    white-space: nowrap;
    width: 80px;
}
.chat-project-card table td:last-child {
    color: var(--gray-900);
    font-weight: 500;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.chat-project-card-actions {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chat-project-card-actions button {
    flex: 1;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-project-card-actions .btn-confirm {
    background: var(--primary);
    color: #fff;
}
.chat-project-card-actions .btn-confirm:hover {
    background: var(--primary-dark);
}
.chat-project-card-actions .btn-confirm:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}
.chat-project-card-actions .btn-cancel {
    background: var(--gray-100);
    color: var(--gray-700);
}
.chat-project-card-actions .btn-cancel:hover {
    background: var(--gray-200);
}

/* 聊天输入区 */
.chat-footer {
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}
/* 拖拽文件到对话框时的高亮反馈 */
.chat-input-area.chat-dragover {
    outline: 2px dashed var(--primary);
    outline-offset: -4px;
    background: var(--primary-light, #eff6ff);
    border-radius: 10px;
}
.chat-upload-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s;
}
.chat-upload-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
/* 话筒录音中：红底白图标 + 呼吸动画，明确"正在录"的状态 */
.chat-mic-recording {
    border-color: #dc3545 !important;
    background: #dc3545 !important;
    color: #fff !important;
    animation: chatMicPulse 1.1s ease-in-out infinite;
}
@keyframes chatMicPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}
.chat-input {
    flex: 1;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
    resize: none;
    max-height: 100px;
    min-height: 36px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    line-height: 1.5;
}
.chat-input:focus { border-color: var(--primary); }
.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.2s;
}
.chat-send-btn:hover { background: var(--primary-dark); }
.chat-send-btn:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}
.chat-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 反馈 / 报bug 表单 */
.chat-feedback {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f7f8fa;
    overflow-y: auto;
    padding: 16px;
    gap: 12px;
}
.chat-feedback-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}
.chat-feedback-head i { color: var(--primary); margin-right: 4px; }
.fb-type-row { display: flex; gap: 14px; font-size: 13px; color: var(--gray-600); }
.fb-type-row label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.fb-input, .fb-textarea {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}
.fb-textarea { min-height: 110px; }
.fb-input:focus, .fb-textarea:focus { outline: none; border-color: var(--primary); }
.fb-page { font-size: 11px; color: var(--gray-400); word-break: break-all; }
.fb-submit {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.fb-submit:hover { background: var(--primary-dark); }
.fb-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.fb-msg { font-size: 12.5px; min-height: 16px; }

/* 文件上传中 */
.chat-upload-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--primary-light);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

/* AI配置区域 */
.ai-config-section {
    max-width: 560px;
}
.ai-config-form {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
}
.ai-config-form .form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.ai-config-form .form-text {
    font-size: 12px;
    color: var(--gray-500);
}
.ai-config-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.ai-config-status.on {
    background: var(--success-light);
    color: var(--success);
}
.ai-config-status.off {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* ==================== 联系人组件 ==================== */
.contact-row {
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px 0 4px 0;
    border: 1px solid #e5e7eb;
}
.contact-row:hover {
    border-color: var(--primary);
    background: #eff6ff;
}
.contact-badge {
    display: inline-block;
    background: #f3f4f6;
    border-radius: 6px;
    padding: 2px 8px;
    margin: 0 4px 4px 0;
    font-size: 12px;
    white-space: nowrap;
}

/* ==================== 自动联想下拉 ==================== */
.autocomplete-wrapper {
    position: relative;
}
.autocomplete-wrapper .ac-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(37,99,235,.15);
}
.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    max-height: 260px;
    overflow-y: auto;
}
.autocomplete-dropdown.show {
    display: block;
}
.ac-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f3f4f6;
    transition: background .15s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active {
    background: #eff6ff;
    color: #1d4ed8;
}
.ac-item .ac-icon {
    color: #9ca3af;
    font-size: 13px;
    flex-shrink: 0;
}
.ac-item .ac-icon.ai { color: #8b5cf6; }
.ac-item .ac-highlight {
    color: #2563eb;
    font-weight: 600;
}
.ac-loading {
    padding: 14px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}
.ac-empty {
    padding: 14px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}
.ac-group-label {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
}

/* ==================== 支付系统样式 ==================== */
.payment-method-btn {
    transition: all 0.2s ease;
    padding: 10px 16px;
    font-size: 14px;
}
.payment-method-btn:hover {
    border-color: #2563eb !important;
    color: #2563eb;
}
.payment-method-btn.active {
    background: #eff6ff !important;
}
.quick-amt {
    min-width: 56px;
    transition: all 0.15s ease;
}
.quick-amt.btn-primary {
    background: #2563eb !important;
    border-color: #2563eb !important;
    color: #fff !important;
}


/* ==================== 智能匹配报告 ==================== */
.report-doc {
    font-size: 14px;
    color: #1f2937;
}
.report-meta {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 14px;
}
.report-section {
    margin-bottom: 8px;
}
.report-h {
    font-size: 16px;
    font-weight: 700;
    color: #1f4e79;
    border-left: 4px solid #2563eb;
    padding-left: 10px;
    margin: 20px 0 10px;
}
.kv-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.kv-item {
    flex: 1 1 45%;
    min-width: 220px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
}
.kv-k {
    color: #6b7280;
    margin-right: 6px;
}
.kv-v {
    font-weight: 600;
    word-break: break-word;
}
.ai-summary-box {
    background: #f0f7ff;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.8;
}
.suggestion-list {
    font-size: 14px;
    padding-left: 20px;
    margin: 0;
}
.suggestion-list li {
    margin-bottom: 6px;
    line-height: 1.7;
}
/* 报告弹窗内复用 match-card / match-score / scoreClass 已由全局样式覆盖，
   这里仅补充报告场景下的间距一致性 */
.report-doc .match-card {
    margin-top: 10px;
}

/* 科纪广场设置：分组白名单行 */
.plaza-group-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px;
    border-bottom: 1px solid #f1f5f9;
}
.plaza-group-row:last-child { border-bottom: none; }
.plaza-group-name { font-weight: 600; font-size: 14px; }
.plaza-group-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; }

