/* AI 客服悬浮气泡 — 平台右下角 */
#ais-wrap { position: fixed; right: 24px; bottom: 24px; z-index: 10500; font-size: 14px; }

#ais-bubble { width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff; font-size: 26px; display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 4px 16px rgba(13,110,253,.4); transition: transform .15s; user-select: none; }
#ais-bubble:hover { transform: scale(1.08); }
#ais-bubble.ais-hidden { display: none; }

#ais-window { display: none; width: 360px; height: 520px; max-height: calc(100vh - 60px); max-width: calc(100vw - 40px);
    background: #fff; border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.18); overflow: hidden;
    flex-direction: column; }
#ais-window.ais-open { display: flex; }

#ais-header { flex-shrink: 0; padding: 12px 16px; background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
#ais-header-btns a { color: rgba(255,255,255,.85); text-decoration: none; margin-left: 12px; font-size: 15px; }
#ais-header-btns a:hover { color: #fff; }
#ais-mode-switch { border: 1px solid rgba(255,255,255,.6); border-radius: 12px; padding: 2px 10px; font-size: 13px !important; }
#ais-mode-switch:hover { background: rgba(255,255,255,.15); }

#ais-msgs { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px; background: #f7f8fa; }
#ais-msgs .ais-placeholder { color: #98a2b3; text-align: center; padding-top: 80px; line-height: 2; font-size: 13px; }

.ais-msg { margin: 6px 0; padding: 8px 12px; border-radius: 10px; max-width: 85%; word-break: break-word;
    overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.ais-user { background: #0d6efd; color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.ais-bot { background: #fff; color: #212529; border: 1px solid #e9ecef; border-bottom-left-radius: 3px; }
.ais-error { background: #fde8e8; color: #b42318; }
.ais-tool { color: #98a2b3; font-size: 11px; margin: 4px 0; }

.ais-code { background: #f1f3f5; color: #333; padding: 8px 10px; border-radius: 6px; overflow-x: auto;
    max-width: 100%; margin: 4px 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
.ais-inline { background: #f1f3f5; color: #c7254e; padding: 0 4px; border-radius: 3px; font-size: 12px; word-break: break-all; }

/* 人工客服 */
.ais-admin { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; border-bottom-left-radius: 3px; }
.ais-system { text-align: center; color: #98a2b3; font-size: 11px; margin: 8px 0; }
.ais-human-entry { text-align: center; margin: 8px 0; }
.ais-human-btn { padding: 6px 18px; border: 1px solid #0d6efd; border-radius: 20px; background: #fff;
    color: #0d6efd; cursor: pointer; font-size: 13px; transition: all .15s; }
.ais-human-btn:hover { background: #0d6efd; color: #fff; }

#ais-inputbar { flex-shrink: 0; display: flex; gap: 6px; padding: 10px; border-top: 1px solid #e9ecef; background: #fff; }
#ais-input { flex: 1; border: 1px solid #dee2e6; border-radius: 8px; padding: 8px 12px; font-size: 13px; outline: none; }
#ais-input:focus { border-color: #0d6efd; }
#ais-inputbar button { border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer;
    background: #0d6efd; color: #fff; white-space: nowrap; }
#ais-inputbar button:disabled { opacity: .5; cursor: default; }
#ais-stop { background: #dc3545 !important; }

/* 移动端适配 */
@media (max-width: 768px) {
    #ais-wrap { right: 12px; bottom: 12px; }
    #ais-bubble { width: 48px; height: 48px; font-size: 22px; }
    #ais-window {
        width: calc(100vw - 16px); height: 80vh; max-width: 100vw;
        border-radius: 12px 12px 0 0;
        position: fixed; bottom: 0; left: 8px; right: 8px;
    }
    #ais-header { padding: 10px 14px; font-size: 13px; }
    #ais-header-btns a { font-size: 13px; margin-left: 8px; }
    #ais-msgs { padding: 8px; }
    .ais-msg { max-width: 90%; font-size: 12px; padding: 6px 10px; }
    #ais-inputbar { padding: 8px; gap: 4px; }
    #ais-input { padding: 6px 10px; font-size: 12px; }
    #ais-inputbar button { padding: 6px 12px; font-size: 12px; }
}
@media (max-width: 380px) {
    #ais-window { height: 90vh; left: 4px; right: 4px; width: calc(100vw - 8px); }
    #ais-bubble { width: 42px; height: 42px; font-size: 20px; }
    .ais-msg { max-width: 92%; }
}

/* marked.js 表格 + 图片（客服气泡） */
#ais-msgs .aic-table-wrap {
    overflow-x: auto;
    margin: 6px 0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
#ais-msgs .aic-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: #1e1e2e;
    color: #cdd6f4;
}
#ais-msgs .aic-table-wrap thead {
    background: #313244;
}
#ais-msgs .aic-table-wrap th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #45475a;
    white-space: nowrap;
}
#ais-msgs .aic-table-wrap td {
    padding: 4px 8px;
    border-bottom: 1px solid #45475a;
}
#ais-msgs .aic-table-wrap tr:last-child td {
    border-bottom: none;
}
.ais-msg img {
    max-width: 100%;
    border-radius: 8px;
    margin: 4px 0;
}
.ais-msg ul, .ais-msg ol {
    margin: 4px 0;
    padding-left: 18px;
}
.ais-msg li {
    margin: 2px 0;
}
