/* assistant.css */
.ai-assistant-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    width: 350px;
    max-width: 90vw;
    transition: all 0.3s ease;
    display: none;
}

.ai-assistant {
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    background: white;
    display: flex;
    flex-direction: column;
    height: 500px;
    overflow: hidden;
}

.ai-header {
    background: linear-gradient(to right, #0d3b66 0%, #1a508b 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-title {
    font-weight: 600;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-controls {
    display: flex;
    gap: 10px;
}

.ai-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-btn:hover {
    background: rgba(255,255,255,0.3);
}

.ai-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 85%;
    padding: 12px 15px;
    border-radius: 18px;
    animation: fadeIn 0.3s ease;
    position: relative;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    background: #0d3b66;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.ai-message {
    background: white;
    border: 1px solid #e0e0e0;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    position: relative;
    padding-right: 40px;
}

.ai-input-area {
    padding: 15px;
    border-top: 1px solid #eee;
    background: white;
    display: flex;
    gap: 10px;
}

.ai-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s;
}

.ai-input:focus {
    border-color: #ee964b;
    box-shadow: 0 0 0 3px rgba(238, 150, 75, 0.2);
}

.ai-send-btn {
    background: #0d3b66;
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-send-btn:hover {
    background: #0a2a4d;
}

.ai-typing-indicator {
    display: none;
    padding: 10px 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    align-self: flex-start;
    margin-bottom: 15px;
}

.ai-dot {
    width: 8px;
    height: 8px;
    background: #ccc;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: bounce 1.5s infinite;
}

.ai-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.ai-minimized {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d3b66 0%, #1a508b 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 10000;
}

.ai-minimized i {
    font-size: 24px;
}

.ai-watermark {
    position: absolute;
    bottom: 5px;
    right: 10px;
    font-size: 0.7rem;
    color: rgba(0,0,0,0.3);
}

.suggested-question {
    background: rgba(13, 59, 102, 0.05);
    border: 1px solid rgba(13, 59, 102, 0.1);
    border-radius: 18px;
    padding: 8px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.suggested-question:hover {
    background: rgba(13, 59, 102, 0.1);
    transform: translateY(-2px);
}

.ai-welcome {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    margin: 10px 0;
}

.ai-welcome h5 {
    color: #0d3b66;
    margin-bottom: 15px;
}

.book-cover {
    width: 80px;
    height: 100px;
    background: linear-gradient(135deg, #0d3b66 0%, #1a508b 100%);
    border-radius: 5px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
}

/* ====================== */
/* MARKDOWN渲染样式 */
/* ====================== */

/* 消息内容容器 */
.message-content {
    padding: 12px 15px;
}

/* 复制按钮样式 */
.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.7);
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.ai-message:hover .copy-btn {
    opacity: 1;
}

/* Markdown内容样式 */
.ai-message h1, 
.ai-message h2, 
.ai-message h3 {
    font-size: 1.2em;
    font-weight: bold;
    margin: 15px 0 10px;
    color: #0d3b66;
    line-height: 1.3;
}

.ai-message h1 {
    font-size: 1.3em;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

.ai-message h2 {
    font-size: 1.15em;
}

.ai-message h3 {
    font-size: 1.05em;
}

.ai-message p {
    margin: 10px 0;
    line-height: 1.6;
    color: #333;
}

.ai-message ul, 
.ai-message ol {
    margin: 10px 0 15px;
    padding-left: 25px;
}

.ai-message li {
    margin: 8px 0;
    line-height: 1.5;
}

.ai-message ul {
    list-style-type: disc;
}

.ai-message ol {
    list-style-type: decimal;
}

.ai-message strong {
    color: #ee964b;
    font-weight: bold;
}

.ai-message em {
    font-style: italic;
    color: #555;
}

.ai-message pre {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    overflow: auto;
    margin: 15px 0;
    border: 1px solid #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.4;
}

.ai-message code {
    font-family: 'Courier New', monospace;
    background: rgba(238, 150, 75, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #d6336c;
}

.ai-message blockquote {
    border-left: 3px solid #0d3b66;
    padding: 8px 15px;
    margin: 15px 0;
    background: rgba(13, 59, 102, 0.03);
    color: #555;
    font-style: italic;
}

.ai-message table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.9em;
}

.ai-message th {
    background: #f0f4f8;
    font-weight: bold;
    text-align: left;
}

.ai-message th, 
.ai-message td {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
}

.ai-message tr:nth-child(even) {
    background-color: #f9f9f9;
}

.ai-message a {
    color: #1a508b;
    text-decoration: none;
    border-bottom: 1px dotted #1a508b;
}

.ai-message a:hover {
    color: #0d3b66;
    border-bottom-style: solid;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .ai-message h1 { font-size: 1.25rem; }
    .ai-message h2 { font-size: 1.15rem; }
    .ai-message h3 { font-size: 1.05rem; }
    .ai-message pre { font-size: 0.85rem; padding: 10px; }
    .ai-message table { font-size: 0.85rem; }
    
    .ai-assistant-container {
        width: 90vw;
        height: 70vh;
        bottom: 10px;
        right: 10px;
    }
    
    .ai-assistant {
        height: 100%;
    }
    
    .copy-btn {
        opacity: 1;
        background: rgba(255,255,255,0.9);
    }
}