/* === AI 对话页面样式 === */
@font-face { font-family: "NavXingShu"; src: url("/fonts/HongLeiXingShuJianTi-2.otf") format("opentype"); font-display: swap; }

:root {
    --bg: #000;
    --card: #121212;
    --border: #222;
    --text: #fff;
    --sub: #666;
    --accent: #fff;
    --font-cn: "NavXingShu", 'Noto Sans SC';
    --font-en: 'Inter';
    --font-mono: 'JetBrains Mono', monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%; overflow: hidden;
    background: var(--bg); color: var(--text);
    font-family: var(--font-en), var(--font-cn), sans-serif;
    font-weight: 300; -webkit-font-smoothing: antialiased;
}
body {
    display: flex; flex-direction: column;
}

/* 通用输入 */
input, select, button, textarea {
    font-family: var(--font-en), var(--font-cn), sans-serif;
    font-weight: 400; outline: none;
}
select, select option { background: #000; color: #fff; }
select optgroup { background: #000; color: #888; }
.btn {
    padding: 10px 24px; background: var(--text); color: var(--bg);
    border: none; border-radius: 10px; cursor: pointer;
    font-size: 14px; font-weight: 500; transition: opacity 0.3s;
}
.btn:hover { opacity: 0.8; }
.btn-ghost {
    padding: 10px 24px; background: transparent; color: var(--text);
    border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
    font-size: 14px; transition: all 0.3s;
}
.btn-ghost:hover { border-color: #555; background: #1a1a1a; }
.btn-sm {
    padding: 6px 14px; font-size: 12px; border-radius: 8px;
    background: transparent; color: var(--sub); border: 1px solid var(--border);
    cursor: pointer; transition: all 0.3s; white-space: nowrap;
}
.btn-sm:hover { color: var(--text); border-color: #555; background: #1a1a1a; }

/* ---- 顶栏 ---- */
.top-bar {
    flex-shrink: 0;
    max-width: 900px; width: 100%; margin: 0 auto;
    padding: 16px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.top-bar a {
    color: var(--sub); text-decoration: none; font-size: 13px;
    letter-spacing: 2px; transition: color 0.3s;
}
.top-bar a:hover { color: var(--text); }
.top-bar h1 {
    font-size: 14px; font-weight: 400; letter-spacing: 4px;
    opacity: 0.5;
}

/* ---- 控制栏 ---- */
.ctrl-bar {
    flex-shrink: 0;
    max-width: 900px; width: 100%; margin: 0 auto;
    padding: 0 20px 12px;
    display: flex; align-items: center; gap: 12px;
}
.chat-model-select {
    padding: 6px 12px; font-size: 12px; border-radius: 8px;
    border: 1px solid var(--border); background: #000; color: #fff;
    cursor: pointer; max-width: 240px; transition: border-color 0.3s;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
    padding-right: 28px;
}
.chat-model-select:focus { border-color: #555; }
.chat-model-select optgroup { color: #888; font-style: normal; background: #000; }
.chat-model-select option { color: #fff; background: #000; padding: 4px 8px; }

/* 历史对话下拉 */
.history-wrap { position: relative; }
.history-wrap .btn-ghost.btn-sm {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
}
.history-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    width: 320px; max-height: 400px; overflow-y: auto;
    background: #111; border: 1px solid #333; border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6); z-index: 100;
}
.history-dropdown.open { display: block; }
.history-dropdown::-webkit-scrollbar { width: 4px; }
.history-dropdown::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.history-list { padding: 6px; }
.history-empty {
    padding: 24px; text-align: center; color: #555; font-size: 13px;
}
.history-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    transition: background 0.2s; gap: 8px;
}
.history-item:hover { background: #1a1a1a; }
.history-item.active { background: #1e1e2e; }
.history-item-info { flex: 1; min-width: 0; }
.history-item-title {
    font-size: 13px; color: #ccc; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.history-item-time {
    font-size: 11px; color: #555; margin-top: 2px;
}
.history-item-del {
    flex-shrink: 0; width: 24px; height: 24px; border: none;
    background: transparent; color: #555; font-size: 16px;
    cursor: pointer; border-radius: 4px; display: flex;
    align-items: center; justify-content: center; transition: all 0.2s;
}
.history-item-del:hover { color: #ef5350; background: rgba(239,83,80,0.1); }

/* ---- 聊天区 ---- */
.chat-body {
    flex: 1; overflow: hidden;
    max-width: 900px; width: 100%; margin: 0 auto;
    padding: 0 20px;
    display: flex; flex-direction: column;
}
.chat-messages {
    flex: 1; overflow-y: auto;
    background: #0a0a0a; border: 1px solid var(--border); border-radius: 12px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 14px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.chat-welcome {
    color: #444; font-size: 14px; text-align: center;
    margin: auto; letter-spacing: 1px;
}

.chat-msg {
    max-width: 85%; padding: 10px 14px; border-radius: 12px;
    font-size: 14px; line-height: 1.7; word-break: break-word;
    animation: chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.chat-msg.user {
    align-self: flex-end; background: #1a1a2e;
    border: 1px solid #2a2a4a; color: #ccc;
}
.chat-msg.assistant {
    align-self: flex-start; background: #141414;
    border: 1px solid var(--border); color: rgba(255,255,255,0.85);
}
.chat-msg.assistant strong { color: #fff; font-weight: 600; }
.chat-msg.assistant code {
    background: #1e1e1e; padding: 1px 5px; border-radius: 4px;
    font-family: var(--font-mono); font-size: 13px;
}
.chat-msg.assistant pre {
    background: #111; border: 1px solid #222; border-radius: 8px;
    padding: 12px; margin: 8px 0; overflow-x: auto; font-size: 13px;
    font-family: var(--font-mono); line-height: 1.5;
}
.chat-msg.assistant pre code {
    background: none; padding: 0; font-size: inherit;
}
.chat-msg.error {
    align-self: center; background: transparent;
    border: 1px solid #4a2020; color: #ef5350; font-size: 13px;
}

.chat-typing::after {
    content: ''; display: inline-block; width: 6px; height: 14px;
    background: #666; margin-left: 2px; vertical-align: text-bottom;
    animation: blink 0.8s infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* 聊天附件预览 */
.chat-attach-preview {
    display: none; gap: 8px; flex-wrap: wrap;
}
.chat-attach-preview.has-file { display: flex; }
.chat-attach-item {
    position: relative; width: 72px; height: 72px; border-radius: 8px;
    overflow: hidden; border: 1px solid var(--border);
}
.chat-attach-item img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.chat-attach-item .remove-attach {
    position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
    background: rgba(0,0,0,0.7); border: none; color: #fff; border-radius: 50%;
    font-size: 14px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; line-height: 1; padding: 0;
}
.chat-attach-item .remove-attach:hover { background: #e53935; }

/* 用户消息中的图片 */
.chat-msg.user img.chat-user-img {
    max-width: 200px; max-height: 150px; border-radius: 6px;
    display: block; margin-top: 6px;
}

/* ---- 底部输入区 ---- */
.chat-footer {
    flex-shrink: 0;
    max-width: 900px; width: 100%; margin: 0 auto;
    padding: 12px 20px 16px;
}
.chat-attach-btn, .chat-mic-btn {
    padding: 8px 10px; min-width: auto; display: flex; align-items: center;
    justify-content: center; border-radius: 10px;
}
.chat-attach-btn:disabled, .chat-mic-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.chat-attach-btn svg, .chat-mic-btn svg { display: block; }

/* 麦克风录音状态 */
.chat-mic-btn.recording {
    border-color: #ef5350; color: #ef5350;
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,83,80,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239,83,80,0); }
}

/* 录音指示器 */
.record-indicator {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px; margin-bottom: 8px;
    background: rgba(239,83,80,0.08); border: 1px solid rgba(239,83,80,0.2);
    border-radius: 10px; font-size: 13px; color: #ef5350;
}
.rec-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #ef5350; animation: recBlink 1s infinite;
}
@keyframes recBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* 音频附件预览 */
.chat-audio-item {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 8px;
    border: 1px solid var(--border); background: #1a1a1a;
    font-size: 12px; color: var(--sub);
}
.chat-audio-item svg { flex-shrink: 0; }
.chat-audio-item .remove-attach {
    width: 18px; height: 18px; background: transparent;
    border: none; color: #555; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px; transition: all 0.2s; margin-left: 4px;
}
.chat-audio-item .remove-attach:hover { color: #ef5350; }

/* 用户语音消息标记 */
.msg-audio-badge {
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; color: #888; margin-bottom: 4px;
}
.msg-audio-badge svg { flex-shrink: 0; }

/* AI 消息朗读按钮 */
.tts-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border: none; border-radius: 6px;
    background: transparent; color: #555; cursor: pointer;
    transition: all 0.2s; margin-top: 6px; padding: 0;
}
.tts-btn:hover { color: var(--text); background: #1e1e1e; }
.tts-btn.tts-playing { color: #4caf50; background: rgba(76,175,80,0.1); }
.tts-btn svg { display: block; }

.chat-input-row {
    display: flex; gap: 10px; align-items: flex-end;
}
.chat-input {
    flex: 1; padding: 10px 14px; background: #0a0a0a;
    border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; font-size: 14px; resize: none;
    font-family: var(--font-en), var(--font-cn), sans-serif;
    line-height: 1.5; max-height: 120px; transition: border-color 0.3s;
}
.chat-input:focus { border-color: #555; outline: none; }
.chat-send { white-space: nowrap; min-width: 60px; }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- 响应式 ---- */
@media (max-width: 600px) {
    .top-bar { padding: 12px 12px; }
    .ctrl-bar { padding: 0 12px 10px; flex-wrap: wrap; }
    .chat-body { padding: 0 12px; }
    .chat-footer { padding: 10px 12px 14px; }
    .chat-messages { padding: 12px; }
    .chat-msg { max-width: 92%; }
    .chat-model-select { max-width: 100%; flex: 1; }
    .history-dropdown { width: calc(100vw - 24px); right: -12px; }
}
