/* AI问答专用样式 */
:root {
    --primary-color: #007aff;
    --secondary-color: #5856d6;
    --accent-color: #34c759;
    --text-color: #1c1c1e;
    --light-text: rgba(255, 255, 255, 0.9);
    --bg-color: rgba(255, 255, 255, 0.8);
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --blur-effect: blur(20px);
}

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: #f2f2f7;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* 主容器 */
.content-holder {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-qa-container {
    width: 96%;
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.qa-chatbox {
    background: rgba(255, 255, 255, 0.8);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur-effect);
    border: 1px solid var(--border-color);
    animation: fadeInUp 1s ease-out 0.3s both;
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    position: relative;
    margin-bottom: 0;
    min-height: 400px;
}

/* 头部样式 */
.ai-header {
    text-align: center;
    animation: fadeInDown 1s ease-out;
    margin-bottom: 15px;
    margin-top: 20px;
}

.ai-header .logo {
    display: inline-block;
    margin-bottom: 10px;
}

.ai-header .logo img {
    width: 150px;
    height: auto;
}

.ai-title {
    font-size: 36px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-subtitle {
    font-size: 16px;
    color: #666;
    font-weight: 300;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.ai-header .welcome {
    color: #555;
    font-size: 14px;
    font-weight: 300;
}

.system-message {
    color: #555;
}

/* 聊天框样式 */
/* 已在文件顶部定义 */

/* 聊天消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    margin-top: 5px;
    padding-right: 10px;
    max-width: 100%;
    overflow-x: hidden;
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    transition: var(--transition);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 消息样式 - 微信聊天风格 */
.message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.5s ease-out;
}

.qa-chatbox .chat-messages .message.user,
.qa-chatbox .chat-messages .message.user-message {
    justify-content: flex-end !important;
    flex-direction: row !important;
    text-align: right !important;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
}

.qa-chatbox .chat-messages .message.user .message-content,
.qa-chatbox .chat-messages .message.user-message .message-content {
    background: #07C160 !important;
    color: white !important;
    border-radius: 18px !important;
    text-align: right !important;
    max-width: 70% !important;
    padding: 12px 16px !important;
    margin-right: 10px !important;
    margin-left: 0 !important;
    order: 1 !important;
}

.qa-chatbox .chat-messages .message.user .message-avatar,
.qa-chatbox .chat-messages .message.user-message .message-avatar {
    order: 2 !important;
    margin: 0 !important;
}

.message.ai {
    justify-content: flex-start;
}

/* 头像样式 - 微信风格 */
.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    margin: 0 10px;
    object-fit: cover;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent-color) 0%, #218838 100%);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(52, 199, 89, 0.2);
}

.message.user .message-avatar::before {
    content: '';
    background-image: url('../images/q.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.message.ai .message-avatar {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Logo头像样式 */
.avatar-logo {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 消息气泡样式 - 微信风格 */
.message-content {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    overflow-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 用户消息气泡 - 蓝色 */
.message.user .message-content {
    background: var(--primary-color);
    color: white;
    border-radius: 18px;
    text-align: right;
}

/* AI消息气泡 - 灰色 */
.message.ai .message-content {
    background: #f2f2f7;
    color: var(--text-color);
    border-radius: 18px;
}

/* 消息气泡悬停效果 */
.message-content:hover {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

/* 输入区域样式 */
.input-area {
    display: flex;
    gap: 12px;
    align-items: center;
    animation: fadeInUp 1s ease-out 0.6s both;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    margin-top: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    border-bottom-left-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    padding: 16px;
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur-effect);
    border: 1px solid var(--border-color);
}

.qa-chatbox {
    background: rgba(255, 255, 255, 0.8);
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 20px;
    box-shadow: var(--shadow);
    backdrop-filter: var(--blur-effect);
    border: 1px solid var(--border-color);
    animation: fadeInUp 1s ease-out 0.3s both;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 400px;
    width: 100%;
    position: relative;
}

#user-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-color);
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: var(--transition);
}

#user-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

#send-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #218838 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    max-height: 60px;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

#send-btn img {
    height: 18px;
    width: auto;
    object-fit: contain;
}

#send-btn:hover {
    background: linear-gradient(135deg, #34c759 0%, #28a745 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.4);
}

#send-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(52, 199, 89, 0.3);
}

/* 加载动画 */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-style: normal;
    font-size: 14px;
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

/* 代码块样式 */
.code-block {
    margin: 12px 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background-color: #f2f2f7;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.copy-btn:hover {
    background-color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.copy-btn.copied {
    background-color: rgba(52, 199, 89, 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.copied-icon {
    display: none;
}

.copy-btn.copied .copy-icon {
    display: none;
}

.copy-btn.copied .copied-icon {
    display: inline;
}

pre {
    background-color: #f5f5f5;
    padding: 12px;
    margin: 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

code {
    background-color: #e0e0e0;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    color: #333;
    border: 1px solid #d0d0d0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* AI消息中的code标签样式 */
.message.ai .message-content code {
    background-color: #d0d0d0;
    color: #222;
    border-color: #c0c0c0;
}

/* 热门问题样式 */
.quick-questions {
    margin-top: 30px;
    text-align: center;
    animation: fadeInUp 1s ease-out 0.9s both;
}

.quick-questions h3 {
    color: var(--text-color);
    font-size: 20px;
    margin-bottom: 20px;
    font-weight: 400;
    text-shadow: none;
}

.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.quick-tag {
    padding: 10px 16px;
    background: rgba(0, 122, 255, 0.05);
    color: var(--primary-color);
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(0, 122, 255, 0.2);
    text-shadow: none;
    font-weight: 500;
}

.quick-tag:hover {
    background: rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

/* 消息内容中的列表样式 */
.message-content ul {
    list-style-type: none;
    padding-left: 20px;
    margin: 10px 0;
}

.message-content ul li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    font-size: 16px;
    line-height: 1.4;
}

/* 确保列表项中的p标签不会影响项目符号 */
.message-content ul li p {
    margin: 0;
    padding: 0;
}

/* 修复嵌套的p标签导致的项目符号位置问题 */
.message-content ul li::before {
    content: "·";
    position: absolute;
    left: 0;
    top: 5px;
    font-size: 18px;
    color: var(--text-color);
    font-weight: bold;
    z-index: 1;
}

/* AI消息中的列表样式 */
.message.ai .message-content ul li::before {
    color: var(--text-color);
}

/* 用户消息中的列表样式 */
.message.user .message-content ul li::before {
    color: white;
}

/* 有序列表样式 */
.message-content ol {
    list-style-type: decimal;
    padding-left: 30px;
    margin: 10px 0;
}

.message-content ol li {
    margin-bottom: 8px;
    font-size: 16px;
    line-height: 1.4;
}

.message-content ol li p {
    margin: 0;
    padding: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-title {
        font-size: 32px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .input-area {
        flex-direction: column;
        align-items: stretch;
    }
    
    #send-btn {
        align-self: center;
    }
    
    .quick-tags {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 10px;
        padding-right: 10px;
    }
    
    .quick-tag {
        white-space: nowrap;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* 额外的交互效果 */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
}



/* 加载状态的改进 */
.loading-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-title {
        font-size: 32px;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .input-area {
        flex-direction: column;
        align-items: stretch;
    }
    
    #send-btn {
        align-self: center;
    }
    
    .quick-tags {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 10px;
        padding-right: 10px;
    }
    
    .quick-tag {
        white-space: nowrap;
    }
}

/* 响应式调整 */
@media (max-width: 480px) {
    .ai-qa-container {
        padding: 80px 15px 40px;
    }
    
    .qa-chatbox {
        padding: 20px;
    }
    
    .message-content {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    #user-input {
        padding: 15px 20px;
        font-size: 14px;
    }
    
    #send-btn {
        padding: 15px 30px;
        font-size: 14px;
    }
}

/* 深色模式优化 */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #5a7fb9;
        --secondary-color: #4a6fa5;
        --accent-color: #44b963;
        --text-color: #e0e0e0;
        --light-text: rgba(255, 255, 255, 0.9);
        --bg-color: rgba(255, 255, 255, 0.05);
        --border-color: rgba(255, 255, 255, 0.1);
        --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    }
    
    body, html {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }
    
    .qa-chatbox,
    .input-area {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.18);
    }
    
    .ai-title {
        color: #fff;
        text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
    
    .ai-subtitle {
        color: rgba(255, 255, 255, 0.8);
    }
    
    .ai-header .welcome,
    .system-message {
        color: white;
    }
    
    .quick-questions h3 {
        color: white;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    
    .quick-tag {
        background: rgba(255, 255, 255, 0.15);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.18);
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }
    
    .quick-tag:hover {
        background: rgba(255, 255, 255, 0.3);
    }
    
    .loading-container {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .loading-spinner {
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top: 2px solid white;
    }
    
    .message.ai .message-content {
        background: rgba(255, 255, 255, 0.85);
        color: #333;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #2d5a91;
        --secondary-color: #1d4a81;
        --accent-color: #147c34;
        --border-color: rgba(0, 0, 0, 0.3);
        --bg-color: rgba(255, 255, 255, 0.9);
        --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    }
    
    .qa-chatbox,
    .input-area {
        border: 2px solid rgba(0, 0, 0, 0.3);
    }
    
    .quick-tag {
        border: 2px solid rgba(74, 111, 165, 0.4);
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 代码块样式 */
pre {
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.4;
}

code {
    background-color: transparent;
    color: #444;
}

/* 消息中的代码块样式 */
.message-content pre {
    background-color: #f0f0f0;
}

.message-content code {
    color: #444;
}

/* 用户消息中的代码块样式 */
.qa-chatbox .chat-messages .message.user .message-content pre {
    background-color: rgba(255, 255, 255, 0.2);
}

.qa-chatbox .chat-messages .message.user .message-content code {
    color: white;
}