/* ============================================================
 * 千城集 · AI 客服弹窗组件样式
 * 跟随全站 tokens.css 主题变量，深浅色自动切换
 * ============================================================ */

/* 浮球按钮（右下角固定） */
.cs-fab {
    position: fixed;
    right: 20px;
    bottom: 96px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary, #B89040);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform .2s, box-shadow .2s;
}
.cs-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.28);
}
.cs-fab svg {
    width: 28px;
    height: 28px;
}
.cs-fab .cs-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    display: none;
}
.cs-fab .cs-badge.show {
    display: block;
}

/* 聊天窗口（PC 右下弹窗） */
.cs-window {
    position: fixed;
    right: 20px;
    bottom: 156px;
    width: 380px;
    height: 560px;
    background: var(--card-bg, #fff);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    opacity: 0;
    transform: translateY(20px) scale(.96);
    pointer-events: none;
    transition: opacity .22s, transform .22s;
    border: 1px solid var(--border, #e5e5ea);
}
.cs-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 窗口头部 */
.cs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--primary, #B89040);
    color: #fff;
    flex-shrink: 0;
}
.cs-header .cs-title {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cs-header .cs-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34c759;
    box-shadow: 0 0 0 2px rgba(52,199,89,.3);
}
.cs-header .cs-actions {
    display: flex;
    gap: 4px;
}
.cs-header .cs-btn-close {
    background: transparent;
    border: none;
    color: rgba(255,255,255,.85);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.cs-header .cs-btn-close:hover {
    background: rgba(255,255,255,.2);
}
.cs-header .cs-btn-close svg {
    width: 16px;
    height: 16px;
}

/* 快捷问题面板（首次加载显示 3 个） */
.cs-quick {
    padding: 12px 14px 6px;
    background: var(--bg-page, #f5f5f7);
    flex-shrink: 0;
}
.cs-quick-title {
    font-size: 12px;
    color: var(--text-muted, #8e8e93);
    margin-bottom: 8px;
}
.cs-quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cs-quick-item {
    padding: 6px 12px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border, #e5e5ea);
    border-radius: 16px;
    font-size: 13px;
    color: var(--text-primary, #1d1d1f);
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}
.cs-quick-item:hover {
    border-color: var(--primary, #B89040);
    color: var(--primary, #B89040);
    background: rgba(184,144,64,.06);
}

/* 消息列表 */
.cs-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    background: var(--bg-page, #f5f5f7);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cs-messages::-webkit-scrollbar {
    width: 6px;
}
.cs-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,.15);
    border-radius: 3px;
}

/* 消息气泡 */
.cs-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: csFadeIn .18s ease-out;
}
@keyframes csFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.cs-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.cs-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary, #B89040);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cs-msg.user .cs-msg-avatar {
    background: var(--text-tertiary, #aeaeb2);
}
.cs-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}
.cs-msg.ai .cs-msg-bubble {
    background: var(--card-bg, #fff);
    color: var(--text-primary, #1d1d1f);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.cs-msg.user .cs-msg-bubble {
    background: var(--primary, #B89040);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cs-msg-bubble a {
    color: inherit;
    text-decoration: underline;
}
.cs-msg-bubble .cs-link-tag {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 10px;
    background: rgba(184,144,64,.12);
    color: var(--primary, #B89040);
    border-radius: 12px;
    font-size: 12px;
    text-decoration: none;
}

/* 加载中气泡 */
.cs-msg.loading .cs-msg-bubble {
    padding: 14px 18px;
}
.cs-dots {
    display: flex;
    gap: 4px;
}
.cs-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary, #aeaeb2);
    animation: csBounce 1.2s infinite ease-in-out;
}
.cs-dots span:nth-child(2) { animation-delay: .15s; }
.cs-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes csBounce {
    0%, 80%, 100% { transform: scale(.6); opacity: .5; }
    40% { transform: scale(1); opacity: 1; }
}

/* 外网来源标记 */
.cs-external-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: #fff8e1;
    color: #a67c00;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

/* 底部输入区 */
.cs-input-area {
    padding: 10px 12px 12px;
    background: var(--card-bg, #fff);
    border-top: 1px solid var(--border, #e5e5ea);
    flex-shrink: 0;
}
.cs-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.cs-input {
    flex: 1;
    border: 1px solid var(--border, #e5e5ea);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-page, #f5f5f7);
    color: var(--text-primary, #1d1d1f);
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 38px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.cs-input:focus {
    border-color: var(--primary, #B89040);
    box-shadow: 0 0 0 3px rgba(184,144,64,.12);
}
.cs-input::placeholder {
    color: var(--text-muted, #8e8e93);
}
.cs-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary, #B89040);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
}
.cs-send:hover:not(:disabled) {
    transform: scale(1.05);
}
.cs-send:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.cs-send svg {
    width: 18px;
    height: 18px;
}

/* 底部版权 */
.cs-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted, #8e8e93);
    padding: 4px 0 0;
}

/* 移动端（≤768px）：全屏抽屉 */
@media (max-width: 768px) {
    .cs-fab {
        right: 16px;
        bottom: 100px;
        width: 48px;
        height: 48px;
    }
    .cs-window {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        transform: translateY(100%);
        bottom: 0;
    }
    .cs-window.open {
        transform: translateY(0);
    }
    .cs-header {
        padding: 16px;
    }
    .cs-header .cs-title {
        font-size: 16px;
    }
    .cs-input-area {
        padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    }
}

/* 深色主题下的图标微调 */
[data-theme="dark"] .cs-fab svg {
    filter: none;
}
