/* ============================================================
   Boss — 老板的第二大脑 | Design System
   风格：简洁白底 + 金色点缀 + 扁平纯色 + Inter 字体
   ============================================================ */

@import url('https://fonts.loli.net/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
    /* 白色基调 */
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-card: #ffffff;
    --bg-card-hover: #fffdf5;
    --bg-input: #f5f5f5;

    /* 金色品牌色 */
    --gold: #c9a84c;
    --gold-light: #d4b565;
    --gold-dark: #a68a3a;
    --gold-glow: rgba(201, 168, 76, 0.08);
    --gold-border: rgba(201, 168, 76, 0.35);
    --gold-bg: #fdf8ec;

    /* 文字 */
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-gold: #a68a3a;

    /* 功能色 */
    --green: #10b981;
    --red: #ef4444;
    --blue: #3b82f6;
    --orange: #f59e0b;

    /* 来源标签色 */
    --tag-personal: #6366f1;
    --tag-industry: #10b981;
    --tag-public: #3b82f6;

    /* 间距 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* 字体 */
    --font: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ===== 通用按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font);
}

.btn-gold {
    background: var(--gold);
    color: #ffffff;
}
.btn-gold:hover {
    background: var(--gold-dark);
}
.btn-gold:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid #e0e0e0;
}
.btn-outline:hover {
    border-color: var(--gold-border);
    color: var(--text-gold);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
}
.btn-ghost:hover {
    color: var(--text-gold);
}

/* ===== 表单 ===== */
input, textarea, select {
    font-family: var(--font);
    background: var(--bg-input);
    border: 1px solid #e5e5e5;
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    width: 100%;
    transition: border-color 0.2s;
    outline: none;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--gold);
}
input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* ===== 来源标签 ===== */
.source-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
}
.source-tag.personal {
    background: rgba(99, 102, 241, 0.1);
    color: var(--tag-personal);
}
.source-tag.industry {
    background: rgba(16, 185, 129, 0.1);
    color: var(--tag-industry);
}
.source-tag.public {
    background: rgba(59, 130, 246, 0.1);
    color: var(--tag-public);
}

/* ===== 主容器 ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ===== 聊天头部 (纯功能按钮) ===== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: transparent;
    z-index: 10;
}
.header-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}
.header-btn:hover {
    background: #f5f5f5;
    color: var(--text-primary);
}
@media (max-width: 768px) {
    .chat-header {
        padding: 12px 16px;
    }
    .header-btn .btn-text {
        display: none; /* 移动端隐藏文字只留图标 */
    }
}

/* ===== 聊天主体 ===== */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center; /* 核心消息流居中显示 */
    scroll-behavior: smooth;
}
.chat-body-content {
    width: 95%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
}

/* ===== 欢迎屏 (完全左对齐结构) ===== */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0 5%;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}
.welcome-avatar {
    width: auto;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 20px;
}
.welcome-brand {
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #CFAB51 0%, #E6C57A 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--gold); /* 降级 */
    letter-spacing: -0.5px;
}
/* ===== 文字提问列表 (左对齐无边框) ===== */
.quick-questions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 40px;
    width: 100%;
}
.quick-q-btn {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    font-family: var(--font);
    text-align: left;
}
.quick-q-btn .q-icon {
    margin-right: 12px;
    font-size: 18px;
    color: var(--text-muted);
}
.quick-q-btn:hover {
    color: var(--text-gold);
}

/* ===== 场景卡片 — 一行横向卡片 ===== */
.scene-scroll-wrapper {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    display: flex;
    justify-content: center;
    padding-bottom: 30px;
}
.scene-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 5%;
    max-width: 800px;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
/* 隐藏网页底部的横向滚动条！ */
body { overflow-x: hidden; }
.scene-grid::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.scene-card {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid #e8e8e8;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}
.scene-card:hover {
    border-color: var(--gold-border);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(201, 168, 76, 0.08);
}
.scene-icon {
    font-size: 20px;
    margin-bottom: 4px;
}
.scene-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.scene-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.scene-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    white-space: normal; /* 允许折行 */
}

/* ===== 消息气泡容器 (支持头像) ===== */
.msg-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    width: 100%;
}
.msg-row.user-row {
    justify-content: flex-end;
}

.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%; /* 极简圆形，最高级 */
    background: #fff;
    border: 1px solid #f0f0f0;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.msg-avatar img {
    width: 80%; height: 80%;
    object-fit: contain;
}

.msg {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    animation: msgIn 0.25s ease-out;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg.user {
    background: var(--gold-bg);
    border: 1px solid rgba(201, 168, 76, 0.15);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.msg.ai {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    border: 1px solid #eee;
    border-bottom-left-radius: 4px;
}

/* AI 消息内 Markdown */
.msg.ai h1, .msg.ai h2, .msg.ai h3 { color: var(--text-gold); margin: 16px 0 8px; }
.msg.ai h1 { font-size: 20px; }
.msg.ai h2 { font-size: 18px; }
.msg.ai h3 { font-size: 16px; }
.msg.ai p { margin: 8px 0; }
.msg.ai a { color: var(--gold); text-decoration: underline; }
.msg.ai blockquote {
    border-left: 3px solid var(--gold);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}
.msg.ai table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}
.msg.ai th, .msg.ai td {
    padding: 8px 12px;
    border: 1px solid #e5e5e5;
    text-align: left;
}
.msg.ai th { background: var(--gold-bg); color: var(--text-gold); font-weight: 600; }
.msg.ai ul, .msg.ai ol { padding-left: 20px; }
.msg.ai li { margin: 4px 0; }
.msg.ai code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-primary);
}
.msg.ai pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 12px 0;
}
.msg.ai pre code {
    background: none;
    color: inherit;
    padding: 0;
}
.msg.ai hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 16px 0;
}

/* ===== 思考动画 ===== */
.thinking {
    display: flex;
    gap: 6px;
    padding: 4px 0;
}
.thinking span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--gold);
    opacity: 0.4;
    animation: blink 1.4s infinite both;
}
.thinking span:nth-child(2) { animation-delay: 0.2s; }
.thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ===== 新版输入气泡 (类似截图) ===== */
.chat-footer {
    padding: 16px 24px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--bg-primary);
    border-top: 1px solid #f0f0f0;
}
.chat-input-bubble {
    display: flex;
    flex-direction: column;
    max-width: 820px;
    margin: 0 auto;
    background: #f6f6f6;
    border-radius: 20px;
    padding: 12px 14px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.chat-input-bubble:focus-within {
    background: #fff;
    border-color: var(--gold-border);
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.08);
}
.chat-input-bubble textarea {
    width: 100%;
    background: transparent;
    border: none !important;
    padding: 4px 8px;
    margin-bottom: 8px;
    resize: none;
    min-height: 48px;
    max-height: 150px;
    font-size: 15px;
    line-height: 1.5;
    outline: none !important;
    box-shadow: none !important;
}

/* 操作行 */
.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.actions-left {
    display: flex;
    gap: 12px;
}
.action-btn {
    background: transparent;
    border: none;
    padding: 6px;
    border-radius: 8px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.action-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--gold);
}

/* 圆形发送按钮 */
.send-btn-circle {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--gold);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}
.send-btn-circle:hover {
    background: var(--gold-dark);
    transform: scale(1.05);
}
.send-btn-circle svg {
    margin-top: 1px; /* 视觉微调 */
}

/* ===== 决策重心菜单 (Focus Menu) ===== */
.focus-menu {
    position: absolute;
    bottom: calc(100% + 12px); /* 永远悬浮在输入区域上方 */
    left: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(201, 168, 76, 0.2);
    border-radius: 16px;
    padding: 8px;
    width: 240px;
    display: none;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.12);
    z-index: 999; /* 确保置顶 */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.focus-menu.open {
    display: flex;
    animation: menuUp 0.2s ease-out;
}
@keyframes menuUp {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.focus-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}
.focus-item:hover {
    background: var(--gold-bg);
}
.focus-item.active {
    background: var(--gold-bg);
    color: var(--text-gold);
}
.focus-item .mode-icon {
    font-size: 18px;
}
.focus-item .mode-info {
    display: flex;
    flex-direction: column;
}
.focus-item .mode-name {
    font-size: 14px;
    font-weight: 600;
}
.focus-item .mode-desc {
    font-size: 11px;
    opacity: 0.7;
}

/* 激活态滑块图标 */
.action-btn.active {
    color: var(--gold);
    transform: scale(1.1);
}
.send-btn-circle:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
}

/* ===== 历史记录面板 ===== */
.history-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 90;
}
.history-overlay.open { display: block; }

.history-panel {
    position: fixed;
    top: 0; right: -360px;
    width: 340px; height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid #f0f0f0;
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
    transition: right 0.3s ease;
    box-shadow: -4px 0 16px rgba(0,0,0,0.08);
}
.history-panel.open { right: 0; }

.history-panel .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.history-panel .header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-item {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border: 1px solid #f0f0f0;
    transition: all 0.2s;
}
.history-item:hover {
    border-color: var(--gold-border);
    background: var(--gold-bg);
}
.history-item .title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-item .time {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .chat-header { padding: 12px 16px; }
    .chat-body { padding: 16px; }
    .chat-footer { padding: 12px 16px; }
    .msg { max-width: 92%; font-size: 14px; padding: 14px 16px; }
    .welcome-brand { font-size: 36px; }
    .welcome-sub { font-size: 14px; margin-bottom: 32px; }
    .scene-grid { gap: 8px; }
    .scene-card { padding: 10px 16px; }
    .history-panel { width: 280px; right: -300px; }
}

@media (max-width: 480px) {
    .scene-grid { gap: 8px; }
    .scene-card { padding: 10px 14px; }
    .scene-title { font-size: 13px; }
}
