/* =============================================
   DeepSeek Chat - 全面UI优化样式
   仅修改视觉和交互，不涉及任何业务逻辑
   ============================================= */

/* ---------- 全局变量 ---------- */
:root {
    --primary: #4f6bf7;
    --primary-hover: #3b57e0;
    --primary-light: #eef1ff;
    --primary-bg: #f0f4ff;
    --accent: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-body: #f5f7fa;
    --bg-white: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #f8faff;
    --border-light: #eef2f6;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
    --shadow-input: 0 2px 8px rgba(79,107,247,0.10);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'SFMono-Regular', 'JetBrains Mono', 'Consolas', monospace;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

::selection {
    background: var(--primary-light);
    color: var(--primary);
}

/* ---------- Container ---------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- 导航栏 ---------- */
.navbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 56px;
    display: flex;
    align-items: center;
}
.navbar .container {
    max-width: none;
    width: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.navbar-logo:hover {
    color: var(--primary-hover);
}
.navbar-logo::before {
    content: '';
    display: inline-block;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 8px;
}
.navbar-menu {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 4px;
}
.navbar-menu li {
    margin: 0;
}
.navbar-menu a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}
.navbar-menu a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* ---------- Main Container ---------- */
.main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    box-sizing: border-box;
    overflow: visible;
    width: 100%;
    max-width: 100%;
}

/* ---------- Chat Layout ---------- */
.chat-layout {
    display: flex;
    width: 100%;
    height: calc(100vh - 56px);
    position: relative;
}

/* ---------- 侧边栏 ---------- */
.chat-sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    bottom: 0;
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    z-index: 10;
    display: flex;
    flex-direction: column;
}
.chat-sidebar::-webkit-scrollbar {
    width: 4px;
}
.chat-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.sidebar-header {
    padding: 20px 18px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.sidebar-title-group {
    display: flex;
    align-items: center;
    gap: 4px;
}
.sidebar-title-group h3 {
    margin: 0;
}
.sidebar-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-header h3 i {
    color: var(--primary);
}
.new-chat-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}
.new-chat-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,107,247,0.3);
}

.conversation-list {
    padding: 8px 12px 20px;
    flex: 1;
    overflow-y: auto;
}
.conversation-list::-webkit-scrollbar {
    width: 4px;
}
.conversation-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.conversation-item {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    background: transparent;
    border: 1px solid transparent;
    transition: all var(--transition);
    position: relative;
    cursor: pointer;
}
.conversation-item:hover {
    background: var(--bg-white);
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
}
.conversation-item.active {
    background: var(--bg-white);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(79,107,247,0.10);
}

.conversation-title {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}
.conversation-title i {
    color: var(--primary);
    font-size: 13px;
    flex-shrink: 0;
    opacity: 0.7;
}
.conversation-title .title-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    line-height: 1.4;
}
.conversation-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding-left: 21px;
}

.delete-chat-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 13px;
    opacity: 0;
    transition: all var(--transition);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}
.conversation-item:hover .delete-chat-btn {
    opacity: 1;
}
.delete-chat-btn:hover {
    color: var(--danger);
    background: rgba(239,68,68,0.08);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}
.empty-state i {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ---------- Chat Main Area ---------- */
.chat-main {
    flex: 1;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    display: flex;
    justify-content: center;
    position: relative;
    transition: all var(--transition);
}

.chat-center-wrap {
    width: 860px;
    max-width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

/* 侧边栏折叠（桌面端） */
.chat-sidebar.collapsed {
    transform: translateX(-285px);
}

/* 侧边栏折叠按钮 */
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    transition: all var(--transition);
    flex-shrink: 0;
    line-height: 1;
}
.sidebar-collapse-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* 侧边栏折叠后展开标签 */
.sidebar-expand-tab {
    display: none;
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 11;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 0 8px 8px 0;
    padding: 14px 6px;
    cursor: pointer;
    font-size: 13px;
    writing-mode: vertical-lr;
    letter-spacing: 3px;
    box-shadow: 2px 0 12px rgba(79,107,247,0.35);
}
.chat-sidebar.collapsed ~ .sidebar-expand-tab {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    width: 100%;
}

/* ---------- Chat Messages ---------- */
.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 20px 20px;
    scroll-behavior: smooth;
    width: 100%;
    align-items: flex-start;
}
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- Messages ---------- */
.message {
    position: relative;
    overflow: visible;
    max-width: 860px;
    padding: 14px 18px;
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
    margin-bottom: 0;
}

.message + .message {
    margin-top: 14px;
}

.message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    padding-right: 40px;
    box-shadow: 0 2px 8px rgba(79,107,247,0.20);
}

.message-bot {
    align-self: flex-start;
    background-color: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: 18px 18px 18px 4px;
    padding-left: 40px;
    box-shadow: var(--shadow-sm);
}

/* 不同发送者之间的垂直间距 */
.message-bot + .message-user,
.message-user + .message-bot {
    margin-top: 22px;
}

/* 欢迎消息 */
.welcome-message {
    max-width: 480px;
    align-self: center;
    text-align: center;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: var(--shadow-md);
}
.welcome-message i {
    font-size: 48px;
    color: var(--primary);
    margin-bottom: 16px;
    display: block;
}
.welcome-message h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.welcome-message p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ---------- 头像（伪元素） ---------- */
.message-user::before,
.message-bot::before {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.message-user::before {
    content: '我';
    top: 6px;
    right: 6px;
    background: linear-gradient(135deg, #1d4ed8, #4f46e5);
    color: #fff;
    z-index: 3;
    border: 2px solid var(--bg-body);
}

.message-bot::before {
    content: 'AI';
    top: 6px;
    left: 6px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: var(--primary);
    border: 2px solid var(--bg-body);
}

/* ---------- Message Content ---------- */
.message-content {
    padding-right: 36px;
    position: relative;
    width: 100%;
}

.message-content .ai-response {
    line-height: 1.75;
}

/* ---------- Copy Button ---------- */
.copy-btn {
    position: absolute;
    top: 4px;
    right: 2px;
    background: transparent;
    color: inherit;
    border: none;
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
    z-index: 5;
    font-size: 13px;
}
.message:hover .copy-btn {
    opacity: 1;
}
.message-user .copy-btn {
    background: rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.85);
}
.message-user .copy-btn:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
}
.message-bot .copy-btn {
    background: var(--primary-light);
    color: var(--primary);
}
.message-bot .copy-btn:hover {
    background: #dde4ff;
    color: var(--primary-hover);
}

/* ---------- Markdown in messages ---------- */
.message-bot .message-content h1,
.message-bot .message-content h2,
.message-bot .message-content h3 {
    color: var(--text-primary);
    margin-top: 1.2em;
    margin-bottom: 0.6em;
    font-weight: 600;
    line-height: 1.4;
}
.message-bot .message-content h1 { font-size: 1.4em; }
.message-bot .message-content h2 { font-size: 1.2em; }
.message-bot .message-content h3 { font-size: 1.1em; }
.message-bot .message-content h1:first-child,
.message-bot .message-content h2:first-child,
.message-bot .message-content h3:first-child {
    margin-top: 0;
}
.message-bot .message-content p {
    margin-bottom: 0.6em;
}
.message-bot .message-content p:last-child {
    margin-bottom: 0;
}
.message-bot .message-content ul,
.message-bot .message-content ol {
    padding-left: 22px;
    margin-bottom: 0.6em;
}
.message-bot .message-content li {
    margin-bottom: 4px;
}
.message-bot .message-content a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.message-bot .message-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 14px;
    margin: 10px 0;
    color: var(--text-secondary);
    background: var(--primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 8px 14px;
}
.message-bot .message-content hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 16px 0;
}
.message-bot .message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 14px;
}
.message-bot .message-content th,
.message-bot .message-content td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}
.message-bot .message-content th {
    background: var(--primary-light);
    font-weight: 600;
}

/* ---------- Code Blocks ---------- */
.message-content pre {
    background: #0f1825;
    color: #e3e8ee;
    border-radius: var(--radius-md);
    padding: 16px;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,0.06);
    margin: 12px 0;
    position: relative;
    font-size: 13px;
    line-height: 1.6;
}
.message-content pre::-webkit-scrollbar {
    height: 4px;
}
.message-content pre::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}
.message-content code {
    font-family: var(--font-mono);
}
.message-content code:not(pre code) {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.9em;
    border: 1px solid rgba(79,107,247,0.12);
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.6);
    border: none;
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
    z-index: 5;
    font-size: 13px;
}
pre:hover .code-copy-btn {
    opacity: 1;
}
.code-copy-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ---------- 打字指示器 ---------- */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 0;
}
.typing-dots {
    display: flex;
    gap: 5px;
}
.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary);
    opacity: 0.4;
    animation: typing 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 0.9; }
}

/* ---------- Input Area ---------- */
.chat-input-container {
    flex-shrink: 0;
    background: linear-gradient(to top, var(--bg-body) 60%, transparent);
    padding: 0 20px 20px;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 0 0 1px var(--border-light);
    transition: box-shadow var(--transition), border-color var(--transition);
    position: relative;
    gap: 8px;
}
.input-wrapper:focus-within {
    box-shadow: var(--shadow-input), 0 0 0 1px var(--primary);
}

#chat-input,
.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 15px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.6;
}
#chat-input::placeholder,
.chat-input::placeholder {
    color: var(--text-muted);
}

#chat-send-btn,
.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    font-size: 15px;
}
#chat-send-btn:hover,
.chat-send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(79,107,247,0.35);
}
#chat-send-btn:disabled,
.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#chat-stop-btn,
.chat-stop-btn {
    margin-left: 4px;
    background: #fee2e2;
    color: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 14px;
    height: 36px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
#chat-stop-btn:hover,
.chat-stop-btn:hover {
    background: #fecaca;
    color: #dc2626;
}

/* 模型选择器 */
#model-select,
.model-select {
    font-size: 13px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-body);
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
    flex-shrink: 0;
    max-width: 160px;
    position: static;
    box-shadow: none;
}
#model-select:hover,
.model-select:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}
#model-select:focus,
.model-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79,107,247,0.12);
}

/* 思考模式切换 */
.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.thinking-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    padding: 2px 0;
}
.thinking-toggle input {
    display: none;
}
.thinking-slider {
    position: relative;
    width: 34px;
    height: 20px;
    background: #d1d5db;
    border-radius: 10px;
    transition: background 0.25s;
}
.thinking-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.thinking-toggle input:checked + .thinking-slider {
    background: var(--primary);
}
.thinking-toggle input:checked + .thinking-slider::after {
    transform: translateX(14px);
}
.thinking-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.25s;
    font-weight: 500;
}
.thinking-toggle input:checked ~ .thinking-label {
    color: var(--primary);
}

/* ---------- 复制提示 ---------- */
.copy-tooltip {
    position: fixed;
    background: var(--text-primary);
    color: #fff;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ---------- 确认弹窗 ---------- */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
    animation: fadeIn 0.2s ease;
}

.confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-white);
    padding: 28px 32px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    width: 340px;
    max-width: 90vw;
    text-align: center;
    display: none;
    animation: scaleIn 0.25s ease;
}
.confirm-dialog p {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 20px;
    line-height: 1.6;
}
.confirm-dialog .confirm-btn {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 9px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-right: 10px;
}
.confirm-dialog .confirm-btn:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}
.confirm-dialog .cancel-btn {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    padding: 9px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.confirm-dialog .cancel-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 未登录提示气泡 ---------- */
.login-bubble {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 480px;
    padding: 20px;
    text-align: center;
}
.login-bubble-content {
    background: var(--bg-white);
    padding: 40px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}
.login-bubble-content p {
    font-size: 15px;
    color: var(--text-secondary);
}
.login-bubble-content a {
    color: var(--primary);
    font-weight: 600;
}

/* ---------- Flash Messages ---------- */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.5;
}
.alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}
.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}
#flash-message {
    transition: opacity 0.3s ease;
}

/* ---------- Footer ---------- */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
    padding: 16px 0;
    margin-top: auto;
}
.footer-content {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ---------- Auth Pages ---------- */
/* admin 登录页 */
.admin-login-body {
    background: var(--bg-body);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}
.admin-login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}
.admin-login-box {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 40px 36px;
    border: 1px solid var(--border-light);
}
.admin-login-box h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 28px;
    text-align: center;
}
.admin-login-footer {
    text-align: center;
    margin-top: 16px;
}
.admin-login-footer a {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
    padding: 40px 20px;
}

.auth-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-light);
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 28px;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,107,247,0.10);
}
.form-control::placeholder {
    color: var(--text-muted);
}

.input-group {
    display: flex;
    gap: 8px;
}
.input-group .form-control {
    flex: 1;
}
.input-group .btn {
    flex-shrink: 0;
}

.btn {
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79,107,247,0.3);
}
.btn-block {
    width: 100%;
}
.btn-secondary {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--border-light);
    color: var(--text-primary);
}
.btn-outline-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    font-size: 13px;
}
.btn-outline-secondary:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.text-center { text-align: center; }
.mt-3 { margin-top: 16px; }

.forgot-password-link {
    font-size: 14px;
    color: var(--text-secondary);
}
.forgot-password-link:hover {
    color: var(--primary);
}

.auth-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    padding: 10px 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.auth-footer a {
    color: var(--primary);
    font-weight: 500;
    margin-left: 4px;
}

/* ---------- Profile Page ---------- */
.profile-wrapper {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 20px;
}

.profile-header {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.profile-info {
    display: flex;
    align-items: center;
    gap: 20px;
}
.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    flex-shrink: 0;
}
.profile-details h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.profile-details p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.profile-body {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.profile-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    padding: 0;
}
.tab-item {
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    cursor: pointer;
}
.tab-item:hover {
    color: var(--text-primary);
    background: var(--bg-body);
}
.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    padding: 28px 0;
}
.tab-pane h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.tab-pane > p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) and (min-width: 769px) {
    .chat-sidebar {
        width: 240px;
    }
    .chat-sidebar.collapsed {
        transform: translateX(-245px);
    }
}

@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
        height: calc(100vh - 56px);
    }

    .chat-sidebar {
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: 56px;
        left: 0;
        height: calc(100% - 56px);
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    }
    .chat-sidebar.active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex !important;
        position: fixed;
        bottom: 24px;
        left: 24px;
        width: 48px;
        height: 48px;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        box-shadow: 0 4px 16px rgba(79,107,247,0.35);
        z-index: 101;
        cursor: pointer;
        transition: all var(--transition);
    }
    .sidebar-toggle:hover {
        transform: scale(1.05);
    }

    .chat-main {
        margin-left: 0;
        width: 100%;
        height: 100%;
    }

    .chat-center-wrap {
        max-width: 100%;
    }

    .chat-container {
        width: 100%;
        max-width: 100%;
    }

    .chat-messages {
        padding: 16px 16px 12px;
    }

    .chat-input-container {
        padding: 0 16px 16px;
    }

    .input-wrapper {
        padding: 6px 6px 6px 12px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    #chat-input {
        font-size: 14px;
        padding: 8px 0;
        min-height: 40px;
    }

    #model-select {
        font-size: 12px;
        padding: 4px 8px;
        max-width: 130px;
    }

    .thinking-label {
        font-size: 11px;
    }

    .message {
        max-width: 90%;
        padding: 12px 14px;
        font-size: 14px;
    }
    .message-user {
        padding-right: 36px;
    }
    .message-bot {
        padding-left: 36px;
    }

    .message-user::before {
        width: 26px;
        height: 26px;
        font-size: 10px;
        right: 5px;
        top: 5px;
    }
    .message-bot::before {
        width: 26px;
        height: 26px;
        font-size: 10px;
        left: 5px;
        top: 5px;
    }

    .auth-card {
        padding: 32px 24px;
    }

    .profile-wrapper {
        padding: 16px 12px;
    }
    .profile-header {
        padding: 20px;
    }
    .tab-content {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 95%;
        padding: 10px 12px;
        font-size: 13px;
    }
    .message-user {
        padding-right: 32px;
    }
    .message-bot {
        padding-left: 32px;
    }

    .chat-messages {
        padding: 12px 12px 16px;
    }

    .navbar .container {
        padding: 0 12px;
    }
    .navbar-logo {
        font-size: 1rem;
    }
    .navbar-logo::before {
        width: 24px;
        height: 24px;
    }
    .navbar-menu a {
        padding: 6px 10px;
        font-size: 13px;
    }

    #chat-send-btn {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* ---------- 隐藏PC端移动端按钮 ---------- */
@media (min-width: 769px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* ---------- Sidebar Toggle in Mobile (already defined above) ---------- */
/* Double definition prevention - only one should win */

/* ---------- Login Bubble already styled above ---------- */

/* ---------- 编码块内表格等细节 ---------- */

/* ---------- Smooth hover for conversation items (done above) ---------- */

/* 修复移动端会话标题 */
@media (max-width: 768px) {
    .conversation-item .conversation-title {
        max-width: 100%;
    }
    .conversation-item .delete-chat-btn {
        opacity: 0.6;
    }
}

/* 代码高亮基础 */
.hljs {
    background: transparent !important;
}
