:root {
    --primary: #05202d;
    --primary-light: #05202d;
    --primary-hover: #05202d;
    --accent: #d4a017;
    --accent-hover: #b8860b;
    --bg: #ffffff;
    --chat-bg: #ffffff;
    --visitor-bubble: #6327ee;
    --visitor-text: #ddc6c6;
    --agent-bubble: #ffffff;
    --agent-text: #555555;
    --border: #dddddd;
    --text-primary: #1a202c;
    --text-secondary: #555555;
    --text-muted: #999999;
    --shadow: none;
    --shadow-sm: none;
    --radius: 8px;
    --radius-lg: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    height: 100%;
    background: transparent;
}

body {
    font-family: var(--font);
    background: transparent;
    color: var(--text-primary);
    height: 100vh;
    min-height: 100vh;
    position: relative;
    z-index: 0;
    display: block;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

body .page-bg {
    position: fixed;
    inset: 0;
    background: var(--bg) url('/assets/bg.jpg') center/cover no-repeat;
    z-index: 0;
    pointer-events: none;
}

/* === 聊天容器 === */
.chat-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* === 顶部栏 === */
.chat-header {
    background: transparent !important;
    background-image: none !important;
    color: #000;
    padding: 0 16px;
    height: 37px;
    display: flex;
    align-items: center;
    /* gap: 12px; */
    flex-shrink: 0;
    border-bottom: none;
    text-shadow: none;
}

.chat-header .header-back {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.chat-header .header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.chat-header .header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

.chat-header .header-info { flex: 1; }
.chat-header .header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.chat-header .header-status {
    font-size: 20px;
    color: #000;
    margin-top: 0;
}
.chat-header .header-status .dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #48bb78;
    margin-right: 4px;
    vertical-align: middle;
}

/* === 消息区域 === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    background: transparent !important;
    background-image: none !important;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* === 欢迎消息 === */
.welcome-section {
    display: none;
    text-align: center;
    padding: 12px 0 8px;
}
.welcome-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    background: var(--chat-bg);
    display: inline-block;
    padding: 10px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* === FAQ 卡片 === */
.faq-section {
    display: none;
}
.faq-title {
    display: none;
}
.faq-grid {
    display: none;
}
.faq-item {
    display: none;
}
.faq-item:hover {
    display: none;
}

.faq-bubble {
    padding: 12px;
}

.faq-intro {
    font-weight: 700;
    margin: 0 0 6px;
}

.faq-question {
    cursor: pointer;
    padding: 4px 0;
    line-height: 1.5;
    word-break: break-word;
    color: blue;
}

.faq-question span {
    font-weight: 600;
}

/* === 消息气泡 === */
.message-row {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-end;
    gap: 8px;
}
.message-row.visitor { flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}
.msg-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.message-row.agent .msg-avatar {
    background: var(--primary);
    color: #fff;
}
.message-row.visitor .msg-avatar {
    background: var(--accent);
    color: #fff;
}

.msg-content { max-width: 72%; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.message-row.agent .msg-bubble {
    background: var(--agent-bubble);
    color: var(--agent-text);
    border: 1px solid var(--border);
    border-top-left-radius: 0;
}
.message-row.visitor .msg-bubble {
    background: var(--visitor-bubble);
    color: var(--visitor-text);
    border-top-right-radius: 0;
}

.msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
    display: none;
}
.message-row.visitor .msg-time { text-align: right; }

/* === 图片消息 === */
.msg-bubble img.msg-image {
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    object-fit: cover;
}

/* === 文件消息 === */
.msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    text-decoration: none;
    color: inherit;
}
.msg-file-icon {
    font-size: 28px;
    flex-shrink: 0;
}
.msg-file-info { flex: 1; min-width: 0; }
.msg-file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-file-size {
    font-size: 11px;
    color: var(--text-muted);
}

/* === 系统消息 === */
.message-row.system {
    justify-content: center;
}
.message-row.system .msg-bubble {
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 4px 12px;
}

/* === 日期分割 === */
.date-divider {
    text-align: center;
    padding: 8px 0;
    font-size: 11px;
    color: var(--text-muted);
}
.date-divider span {
    background: var(--bg);
    padding: 2px 12px;
    border-radius: 10px;
}

/* === 输入状态 === */
.typing-indicator {
    padding: 0 20px 6px;
    font-size: 12px;
    color: var(--text-muted);
    height: 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* === 输入区域 === */
.chat-input-area {
    padding: 0 12px;
    background: transparent !important;
    background-image: none !important;
    border-top: none;
    flex-shrink: 0;
    position: relative;
    height: 94px;
}

.chat-input-area.toolbar-open {
    height: 138px;
}

.input-toolbar {
    display: none;
    gap: 4px;
    height: 44px;
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    align-items: center;
}

.chat-input-area.toolbar-open .input-toolbar {
    display: flex;
}

.toolbar-toggle {
    position: absolute;
    right: 76px;
    top: 9px;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    z-index: 10;
    color: #666;
    padding: 0;
}

.toolbar-toggle::before {
    content: '+';
    display: block;
    font-size: 22px;
    line-height: 32px;
    text-align: center;
}

.chat-input-area.toolbar-open .toolbar-toggle::before {
    content: '−';
}
.toolbar-btn {
    width: 34px; height: 34px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all 0.2s;
    position: relative;
}
.toolbar-btn:hover {
    background: var(--bg);
    color: var(--primary);
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    border: 0;
    border-radius: 0;
    padding: 0 120px 0 12px;
    font-size: 16px;
    font-family: var(--font);
    resize: none;
    outline: none;
    min-height: 50px;
    max-height: 50px;
    line-height: 50px;
    transition: border-color 0.2s;
    background: transparent;
}
.input-row textarea:focus {
    border-color: transparent;
    background: transparent;
}
.input-row textarea::placeholder { color: var(--text-muted); }

.send-btn {
    width: 60px; height: 32px;
    border: none;
    background: #e79be9;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
    position: absolute;
    right: 12px;
    top: 9px;
}
.send-btn:hover { background: #e79be9; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === 表情选择器 === */
.emoji-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 8px;
    width: 320px;
    max-height: 280px;
    background: var(--chat-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    z-index: 100;
    overflow: hidden;
}
.emoji-picker.show { display: block; }

.emoji-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.emoji-tab {
    padding: 8px 12px;
    font-size: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.emoji-tab:hover, .emoji-tab.active {
    background: var(--bg);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    max-height: 230px;
    overflow-y: auto;
}
.emoji-item {
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.emoji-item:hover { background: var(--bg); transform: scale(1.15); }

/* === 图片预览蒙层 === */
.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lightbox.show { display: flex; }
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

/* === 上传进度 === */
.upload-preview {
    display: none;
    padding: 8px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: 10px;
}
.upload-preview.show { display: flex; }
.upload-thumb {
    width: 48px; height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--border);
}
.upload-info { flex: 1; min-width: 0; }
.upload-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.upload-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}
.upload-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}
.upload-cancel {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

/* === 新消息提示 === */
.new-msg-toast {
    display: none;
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    animation: slideUp 0.3s;
}
.new-msg-toast.show { display: block; }

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* === 响应式 - 手机全屏 === */
@media (max-width: 768px) {
    body {
        align-items: stretch;
        justify-content: stretch;
        background: transparent;
    }
    .chat-container {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }
    .emoji-picker {
        width: calc(100vw - 28px);
        left: 0;
    }
}

/* === 加载动画 === */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 20px;
}
.loading-spinner::after {
    content: '';
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 隐藏文件输入 */
.hidden-input { display: none; }
