/* =========================================================
   多多兔AI学习助手 · ai_assistant.css（整理版）
   ========================================================= */

/* ========== 通用容器 ========== */
.container {
    width: 100%;
    min-height: 500px;
    margin: 0;
    padding: 0;
    background: #fff;
    border-radius: 18px;
}

/* ========== 加载动画 ========== */
.loading {
    color: #666;
    font-size: 0.9rem;
    margin: 10px 0;
    padding-left: 5px;
}
.loading::after {
    content: '';
    animation: loading 1s infinite;
    margin-left: 5px;
}
@keyframes loading {
    0%   { content: '.'; }
    33%  { content: '..'; }
    66%  { content: '...'; }
    100% { content: '.'; }
}

/* =========================================================
   结果区域（旧版静态搜索页使用）
   ========================================================= */
#resultArea {
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

/* 工具栏 */
.result-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #eee;
}
.tool-btn {
    background: none;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    color: #666;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tool-btn:hover {
    background-color: #e9ecef;
    color: #333;
}
.tool-btn i {
    font-size: 1.1rem;
}

/* 问题标题 */
.question-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 16px 16px 12px 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #007bff;
}

/* 内容区域 */
.result-content {
    min-height: 500px;
    padding: 10px 16px 16px 16px;
    font-size: 1rem;
    color: #333;
    line-height: 1.6;
    word-break: break-word;
}

/* =========================================================
   Markdown 渲染样式（同时作用于 .result-content 和 .message-content）
   ========================================================= */
.result-content h1,
.result-content h2,
.result-content h3,
.result-content h4,
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 12px 0 8px;
    font-weight: 700;
    color: #0d2b3e;
    line-height: 1.4;
}

.result-content h1,
.message-content h1 { font-size: 1.25rem; }

.result-content h2,
.message-content h2 { font-size: 1.15rem; }

.result-content h3,
.message-content h3 {
    font-size: 1.05rem;
    border-left: 3px solid #2b7de9;
    padding-left: 8px;
}

.result-content h4,
.message-content h4 {
    font-size: 1rem;
}

/* 段落 */
.result-content p,
.message-content p {
    margin: 8px 0;
    line-height: 1.8;
    color: #2c3e50;
}
.result-content p + p,
.message-content p + p {
    margin-top: 0.4em;
}

/* 加粗、斜体、删除线 */
.result-content strong,
.message-content strong {
    font-weight: 700;
    color: #0d2b3e;
}
.result-content em,
.message-content em {
    color: #28a745;
    font-style: italic;
}
.result-content del,
.message-content del {
    color: #999;
}

/* 列表 —— 横向胶囊 */
.result-content ul,
.result-content ol,
.message-content ul,
.message-content ol {
    margin: 0.4em 0 0.6em 0;
    padding-left: 15px;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.result-content ol,
.message-content ol {
    counter-reset: item;
}

/* 短项（单字等） */
.result-content li[data-length="short"],
.message-content li[data-length="short"] {
    background-color: #e7f3ff;
    border: 1px solid #007bff;
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 1rem;
    color: #007bff;
    transition: all 0.2s;
    white-space: nowrap;
    line-height: 1.4;
}
.result-content li[data-length="short"]:hover,
.message-content li[data-length="short"]:hover {
    background-color: #007bff;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,123,255,0.3);
}

/* 长项（整行） */
.result-content li[data-length="long"],
.message-content li[data-length="long"] {
    width: 100%;
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
    color: #333;
    line-height: 1.5;
}
.result-content li[data-length="long"]:last-child,
.message-content li[data-length="long"]:last-child {
    border-bottom: none;
}

/* 有序列表的长项前置序号 */
.result-content ol li[data-length="long"],
.message-content ol li[data-length="long"] {
    counter-increment: item;
    position: relative;
    padding-left: 28px;
}
.result-content ol li[data-length="long"]::before,
.message-content ol li[data-length="long"]::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 6px;
    width: 20px;
    height: 20px;
    background-color: #007bff;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    font-size: 0.8rem;
}

/* 有序列表的短项前置序号 */
.result-content ol li[data-length="short"],
.message-content ol li[data-length="short"] {
    counter-increment: item;
    position: relative;
}
.result-content ol li[data-length="short"]::before,
.message-content ol li[data-length="short"]::before {
    content: counter(item);
    position: absolute;
    left: -20px;
    top: 4px;
    width: 18px;
    height: 18px;
    background-color: #007bff;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    font-size: 0.7rem;
}

/* 引用块 */
.result-content blockquote,
.message-content blockquote {
    margin: 0.8em 0;
    padding: 8px 12px;
    background-color: #f5f9ff;
    border-left: 4px solid #42a5f5;
    border-radius: 4px;
    color: #52627a;
    font-style: italic;
    line-height: 1.6;
}

/* 行内代码 */
.result-content code,
.message-content code {
    background-color: #f0f4f8;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d35400;
}

/* 代码块 */
.result-content pre,
.message-content pre {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.8em 0;
    font-size: 0.9rem;
    line-height: 1.4;
}
.result-content pre code,
.message-content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.9rem;
}

/* 表格 —— 移动端适配 */
.result-content table,
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 0.9rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.result-content th,
.message-content th {
    background-color: #007bff;
    color: white;
    padding: 8px 10px;
    font-weight: 500;
    white-space: nowrap;
}
.result-content td,
.message-content td {
    padding: 6px 8px;
    border: 1px solid #ddd;
    white-space: nowrap;
}
.result-content tr:nth-child(even),
.message-content tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* ========== 错误提示 ========== */
.error {
    color: #dc3545;
    font-weight: 500;
    padding: 12px;
    text-align: center;
}

/* =========================================================
   对话区域（AI 助手）
   ========================================================= */
.conversation-history {
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 10px;
}

/* 消息气泡 */
.message-bubble {
    margin-bottom: 20px;
    animation: fadeInUp 0.3s ease;
}
.message-user {
    text-align: right;
}
.message-ai {
    text-align: left;
}
.message-content {
    display: inline-block;
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    line-height: 1.6;
    word-wrap: break-word;
    text-align: left;
}
.message-user .message-content {
    background: linear-gradient(135deg, #007bff 0%, #008cb4 100%);
    color: white;
    border-bottom-right-radius: 4px;
}
.message-ai .message-content {
    background: #f8f4e9;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* 消息时间 */
.message-meta {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
    margin-bottom: 5px;
}
.message-user .message-meta {
    margin-right: 10px;
}
.message-ai .message-meta {
    margin-left: 10px;
}

/* 打字指示器 */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: #f0f0f0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
}
.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-10px); opacity: 1; }
}

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

/* ========== 追问建议 ========== */
.followup-suggestions {
    margin-top: 15px;
    margin-bottom: 15px;
    margin-left: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.suggestion-chip {
    background: #f0f0f0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: #667eea;
}
.suggestion-chip:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

/* =========================================================
   对话表单
   ========================================================= */
.chat-form-container {
    margin-top: 300px;
    border-top: 2px solid #6779e4;
    background: #f9f9f9;
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 0px;
    position: sticky;
    bottom: 0;
}
.chat-form-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-form-title i {
    font-size: 22px;
}
.chat-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s;
    min-width: 200px;
}
.chat-input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}
.chat-submit-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}
.chat-submit-btn:active {
    transform: translateY(0);
}
.chat-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.clear-history-btn {
    padding: 12px 20px;
    background: #d3f4d1b5;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.clear-history-btn:hover {
    background: #e0e0e0;
}

/* =========================================================
   通知 & 复制提示
   ========================================================= */
.copy-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 40px;
    font-size: 0.9rem;
    z-index: 10000;
    animation: fadeInOut 1.5s ease;
    white-space: nowrap;
}
@keyframes fadeInOut {
    0%   { opacity: 0; transform: translate(-50%, 60%); }
    15%  { opacity: 1; transform: translate(-50%, -50%); }
    85%  { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -140%); }
}

.notification {
    position: fixed;
    top: 16px;
    right: 16px;
    left: 16px;
    max-width: 300px;
    margin: 0 auto;
    background: #28a745;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 10001;
    animation: slideDown 0.3s ease;
    font-size: 0.9rem;
    text-align: center;
}
.notification.error {
    background: #dc3545;
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* =========================================================
   响应式 —— 移动端
   ========================================================= */
@media (max-width: 768px) {
    .chat-input-group {
        flex-direction: column;
    }
    .message-content {
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .question-title {
        font-size: 1rem;
        margin: 12px 12px 8px 12px;
    }
    .result-content {
        padding: 0 12px 12px 12px;
        font-size: 0.95rem;
    }
    .result-content h1,
    .message-content h1 { font-size: 1.2rem; }

    .result-content h2,
    .message-content h2 { font-size: 1.1rem; padding-left: 8px; }

    .result-content h3,
    .message-content h3 { font-size: 1rem; }

    .result-content li[data-length="short"],
    .message-content li[data-length="short"] {
        padding: 3px 12px;
        font-size: 0.95rem;
    }
    .tool-btn {
        padding: 5px 10px;
        font-size: 0.85rem;
    }
}