/* ============================================================
   官网 AI 在线咨询浮窗样式
   与 home.css 共用品牌色板：西启蓝 #1B4DF5 / 深空蓝 #0B2A6B / 启明金 #FFB020
   纯静态样式，不依赖外部字体与 CDN
   ============================================================ */

.ai-consult {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 900;
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- 悬浮入口按钮 ---------- */
.ai-consult-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 52px;
    padding: 0 20px 0 16px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #1B4DF5 0%, #0B2A6B 100%);
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .2px;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(11, 42, 107, .28);
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.ai-consult-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(11, 42, 107, .34);
}

.ai-consult-toggle:focus-visible {
    outline: 3px solid rgba(255, 176, 32, .85);
    outline-offset: 3px;
}

.ai-consult-icon {
    width: 22px;
    height: 22px;
    flex: none;
}

.ai-consult-toggle-text {
    white-space: nowrap;
}

/* 面板打开时隐藏入口按钮，避免和面板打架 */
.ai-consult.is-open .ai-consult-toggle {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

/* ---------- 面板 ---------- */
.ai-consult-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: 374px;
    max-width: calc(100vw - 32px);
    height: 566px;
    max-height: calc(100vh - 130px);
    background: #FFFFFF;
    border: 1px solid #E6E9F2;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(11, 42, 107, .22);
    overflow: hidden;
    transform-origin: right bottom;
    animation: ai-consult-in .2s ease-out both;
}

.ai-consult-panel[hidden] {
    display: none;
}

@keyframes ai-consult-in {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 头部 ---------- */
.ai-consult-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 14px 18px;
    background: linear-gradient(135deg, #0B2A6B 0%, #1B4DF5 100%);
    color: #FFFFFF;
}

.ai-consult-head-copy p {
    margin: 0;
}

.ai-consult-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .3px;
}

.ai-consult-sub {
    margin-top: 2px !important;
    font-size: 12px;
    color: rgba(255, 255, 255, .74);
}

.ai-consult-close {
    width: 28px;
    height: 28px;
    flex: none;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .14);
    color: #FFFFFF;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background .16s ease;
}

.ai-consult-close:hover {
    background: rgba(255, 255, 255, .26);
}

.ai-consult-close:focus-visible {
    outline: 2px solid #FFB020;
    outline-offset: 2px;
}

/* ---------- 消息区 ---------- */
.ai-consult-body {
    flex: 1;
    min-height: 0;
    padding: 16px 14px 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #FFFFFF;
    scrollbar-width: thin;
    scrollbar-color: #C9D2E6 transparent;
}

.ai-consult-body::-webkit-scrollbar {
    width: 6px;
}

.ai-consult-body::-webkit-scrollbar-thumb {
    background: #C9D2E6;
    border-radius: 3px;
}

.ai-msg {
    display: flex;
    margin-bottom: 12px;
}

.ai-msg p {
    margin: 0;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.72;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-msg-bot {
    justify-content: flex-start;
}

.ai-msg-bot p {
    max-width: 88%;
    background: #F5F7FC;
    color: #1A2233;
    border-bottom-left-radius: 5px;
}

.ai-msg-user {
    justify-content: flex-end;
}

.ai-msg-user p {
    max-width: 85%;
    background: linear-gradient(135deg, #1B4DF5 0%, #1740C9 100%);
    color: #FFFFFF;
    border-bottom-right-radius: 5px;
}

/* 等待首字时的三点动画 */
.ai-msg.is-waiting p {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    min-height: 38px;
}

.ai-msg.is-waiting p i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #A8B3C9;
    animation: ai-consult-blink 1.2s infinite ease-in-out;
}

.ai-msg.is-waiting p i:nth-child(2) { animation-delay: .18s; }
.ai-msg.is-waiting p i:nth-child(3) { animation-delay: .36s; }

@keyframes ai-consult-blink {
    0%, 80%, 100% { opacity: .35; transform: translateY(0); }
    40%           { opacity: 1;   transform: translateY(-2px); }
}

/* 流式输出时的光标 */
.ai-msg.is-streaming p::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 13px;
    margin-left: 2px;
    background: #1B4DF5;
    vertical-align: -2px;
    animation: ai-consult-caret 1s steps(2, start) infinite;
}

@keyframes ai-consult-caret {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* 出错提示 */
.ai-msg-error p {
    background: #FFF4F1 !important;
    color: #B4341F !important;
    font-size: 13px;
}

/* ---------- 快捷提问 ---------- */
.ai-consult-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 2px 0 14px;
}

.ai-consult-chips[hidden] {
    display: none;
}

.ai-consult-chips button {
    padding: 7px 12px;
    border: 1px solid #DDE3F2;
    border-radius: 999px;
    background: #FFFFFF;
    color: #37456A;
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}

.ai-consult-chips button:hover {
    border-color: #1B4DF5;
    background: rgba(27, 77, 245, .05);
    color: #1B4DF5;
}

/* ---------- 输入区 ---------- */
.ai-consult-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #EEF1F8;
    background: #FFFFFF;
}

.ai-consult-form textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid #DDE3F2;
    border-radius: 12px;
    background: #FAFBFE;
    color: #1A2233;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: border-color .16s ease, background .16s ease;
}

.ai-consult-form textarea::placeholder {
    color: #9AA4B8;
}

.ai-consult-form textarea:focus {
    border-color: #1B4DF5;
    background: #FFFFFF;
}

.ai-consult-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 0;
    border-radius: 12px;
    background: #1B4DF5;
    color: #FFFFFF;
    cursor: pointer;
    transition: background .16s ease, opacity .16s ease;
}

.ai-consult-send svg {
    width: 18px;
    height: 18px;
}

.ai-consult-send:hover {
    background: #1740C9;
}

.ai-consult-send:disabled {
    background: #C3CCE0;
    cursor: not-allowed;
}

.ai-consult-send:focus-visible {
    outline: 2px solid #FFB020;
    outline-offset: 2px;
}

/* ---------- 免责说明 ---------- */
.ai-consult-note {
    margin: 0;
    padding: 0 14px 12px;
    font-size: 11.5px;
    line-height: 1.6;
    color: #8A93A6;
    background: #FFFFFF;
}

.ai-consult-note a {
    color: #1B4DF5;
    text-decoration: none;
}

.ai-consult-note a:hover {
    text-decoration: underline;
}

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
    .ai-consult {
        right: 14px;
        bottom: 14px;
    }

    .ai-consult-toggle {
        height: 48px;
        padding: 0;
        width: 48px;
        justify-content: center;
        border-radius: 50%;
    }

    .ai-consult-toggle-text {
        display: none;
    }

    .ai-consult-panel {
        position: fixed;
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        max-width: none;
        height: min(78vh, 600px);
    }
}

/* ---------- 无障碍：尊重系统"减少动效"设置 ---------- */
@media (prefers-reduced-motion: reduce) {
    .ai-consult-panel,
    .ai-consult-toggle,
    .ai-msg.is-waiting p i,
    .ai-msg.is-streaming p::after {
        animation: none !important;
        transition: none !important;
    }
}
