/* 沂蒙精神智能问答系统 - 主样式表 */

:root {
    /* 沂蒙红·流光渐变 */
    --primary-gradient: linear-gradient(120deg, #B71C1C, #D32F2F, #E53935);
    /* 鎏金点缀 */
    --gold-accent: #FFD54F;
    /* 远山灰背景 */
    --bg-color: #FAFAFA;
    /* 玻璃态 */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: 1px solid rgba(255, 255, 255, 0.9);
    --shadow-float: 0 10px 40px -10px rgba(183, 28, 28, 0.15);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    /* 使用系统字体，移除Google Fonts依赖 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans SC", sans-serif,
                 "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #333;
    /* 动态背景层 */
    background: radial-gradient(circle at 0% 0%, rgba(255, 235, 238, 0.5) 0%, transparent 50%),
                radial-gradient(circle at 100% 100%, rgba(255, 248, 225, 0.5) 0%, transparent 50%);
    background-size: 200% 200%;
    animation: bgBreath 15s ease infinite alternate;
}

@keyframes bgBreath {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

/* 顶部导航：极简与通透 */
header {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
    background: rgba(250, 250, 250, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.03);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 32px;
    height: 32px;
    background: var(--primary-gradient);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: white;
    box-shadow: 0 4px 10px rgba(183, 28, 28, 0.3);
}

.brand-text h1 {
    /* 使用系统字体替代Google Fonts */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Serif SC", serif;
    font-size: 1.15rem;
    color: #2c3e50;
    font-weight: 700;
    letter-spacing: 1px;
}

.brand-text span {
    font-size: 0.65rem;
    color: #B71C1C;
    letter-spacing: 2px;
    text-transform: uppercase;
    display: block;
    margin-top: -2px;
}

/* 聊天区域 */
#chat-box {
    flex: 1;
    padding: 20px 20px 140px 20px; /* 底部留白给悬浮栏 */
    overflow-y: overlay;
    scroll-behavior: smooth;
}

/* 隐藏滚动条但保留功能 */
#chat-box::-webkit-scrollbar { width: 4px; }
#chat-box::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }

/* 消息气泡容器 */
.msg-row {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    opacity: 0;
    transform: translateY(20px);
    animation: msgEnter 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes msgEnter {
    to { opacity: 1; transform: translateY(0); }
}

.msg-row.user { flex-direction: row-reverse; }

/* 头像 */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    position: relative;
}

.avatar.bot {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: var(--shadow-card);
    color: #B71C1C;
}

.avatar.user {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 10px rgba(211, 47, 47, 0.25);
}

/* 气泡本体 */
.bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.7;
    position: relative;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s;
}

/* Markdown 样式 */
.bubble h1, .bubble h2, .bubble h3, .bubble h4 {
    color: #B71C1C;
    margin-top: 1.2em;
    margin-bottom: 0.8em;
    font-weight: 600;
}

.bubble h1 { font-size: 1.3em; }
.bubble h2 { font-size: 1.2em; }
.bubble h3 { font-size: 1.1em; }
.bubble h4 { font-size: 1.05em; }

.bubble p {
    margin: 0.8em 0;
}

.bubble ul, .bubble ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
}

.bubble li {
    margin: 0.4em 0;
}

.bubble strong {
    color: #B71C1C;
    font-weight: 600;
}

.bubble blockquote {
    border-left: 4px solid #B71C1C;
    padding-left: 1em;
    margin: 1em 0;
    color: #666;
    background: rgba(183, 28, 28, 0.05);
    padding: 0.8em;
    border-radius: 8px;
}

.bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.bubble pre {
    background: rgba(0,0,0,0.05);
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

.bubble pre code {
    background: none;
    padding: 0;
}

.msg-row.bot .bubble {
    background: #fff;
    color: #444;
    border-top-left-radius: 4px;
    border: 1px solid rgba(255, 235, 238, 0.5); /* 极淡的红色边框 */
}

/* 模拟富文本强调 */
.bubble strong {
    color: #B71C1C;
    font-weight: 600;
}

.msg-row.user .bubble {
    background: var(--primary-gradient);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 8px 20px -5px rgba(211, 47, 47, 0.4);
}

/* 底部交互区：悬浮岛设计 */
footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 16px 20px 16px;
    background: linear-gradient(to top, rgba(250,250,250,1) 50%, rgba(250,250,250,0));
    z-index: 100;
}

/* 快捷标签 */
.tags-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 4px;
    margin-bottom: 8px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.tags-container::-webkit-scrollbar { display: none; }

.chip {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0,0,0,0.06);
    color: #555;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.chip i { font-style: normal; font-size: 1rem; }

.chip:active { transform: scale(0.95); }
.chip:hover {
    border-color: #EF9A9A;
    color: #D32F2F;
    background: #FFEBEE;
}

/* 输入框容器 */
.input-deck {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(25px);
    border-radius: 28px;
    padding: 6px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-float);
    border: 1px solid rgba(255,255,255,0.8);
    position: relative;
}

input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 1rem;
    outline: none;
    color: #333;
    font-family: inherit;
}

input::placeholder { color: #BBB; letter-spacing: 0.5px; }

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background: #222; /* 深色按钮形成对比 */
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.send-btn.active {
    background: var(--primary-gradient);
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.4);
    transform: scale(1.05);
}

/* 发送按钮loading状态 */
.send-btn.loading {
    background: #999 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.send-btn.loading svg {
    animation: spin 1s linear infinite;
}

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

/* 输入框禁用状态 */
#input:disabled {
    background: rgba(0,0,0,0.02);
    cursor: not-allowed;
}

/* 正在输入动画 */
.typing-indicator {
    padding: 12px 18px;
    background: #fff;
    border-radius: 18px;
    border-top-left-radius: 4px;
    display: inline-flex;
    gap: 4px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    margin-left: 52px; /* avatar width + gap */
    display: none; /* 默认隐藏 */
}

.dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 状态指示器容器 */
.status-indicator {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 52px;
    margin-bottom: 16px;
    gap: 8px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-size: 0.85rem;
    color: #666;
}

.status-icon {
    font-size: 1.1rem;
}

/* 打字圆点动画 */
.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #B71C1C;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.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; }

/* 消息时间戳 */
.msg-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #eee;
}

.msg-time strong {
    color: #B71C1C;
    font-weight: 500;
}

/* AI生成标识 */
.ai-identifier {
    color: #999999;
    font-size: 12px;
    margin-top: 12px;
    text-align: right;
    font-style: italic;
    opacity: 0.8;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* 清空历史按钮 */
.clear-history-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    color: #666;
}

.clear-history-btn:hover {
    background: #FFEBEE;
    color: #D32F2F;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.15);
}

.clear-history-btn:active {
    transform: scale(0.95);
}

/* 重试按钮 */
.retry-btn {
    background: #B71C1C;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(183, 28, 28, 0.2);
}

.retry-btn:hover {
    background: #D32F2F;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
    transform: translateY(-1px);
}

.retry-btn:active {
    transform: translateY(1px);
}
