/**
 * AI Chat Page Styles
 * 类千问界面 - 里维埃拉蔚蓝主题
 *
 * @package NordicTimeline
 * @version 1.0.0
 */

/* CSS Variables */
:root {
    --ai-primary: #4A8DB7;
    --ai-primary-light: #6BAED6;
    --ai-primary-dark: #3A7A9E;
    --ai-bg: #F0F5FA;
    --ai-sidebar-bg: #1a2a3e;
    --ai-sidebar-hover: #253548;
    --ai-text: #1A2B3C;
    --ai-text-light: #6B7D8E;
    --ai-text-muted: #999999;
    --ai-border: #DCE5EE;
    --ai-ai-bubble: #F5F5F5;
    --ai-user-bubble: rgba(74, 141, 183, 0.12);
    --ai-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --ai-shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.12);
}

/* Reset for AI Chat Page */
.ai-chat-page {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--ai-bg);
    overflow: hidden;
}

.ai-chat-page #page,
.ai-chat-page .site {
    display: none;
}

/* Main Layout */
.ai-chat-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: var(--ai-bg);
}

/* Sidebar */
.ai-chat-sidebar {
    width: 240px;
    background: var(--ai-sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.ai-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.ai-new-chat-btn svg {
    stroke: var(--ai-primary);
}

.ai-sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.ai-history-empty {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
}

.ai-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-history-item:hover {
    background: var(--ai-sidebar-hover);
}

.ai-history-item.active {
    background: rgba(74, 141, 183, 0.2);
    color: var(--ai-primary-light);
}

.ai-history-item svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* 对话删除按钮 */
.ai-history-item {
    position: relative;
}

.ai-history-delete {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-history-item:hover .ai-history-delete {
    opacity: 1;
}

.ai-history-delete:hover {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
}

/* Main Chat Area */
.ai-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Mobile Header */
.ai-chat-mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--ai-bg);
    border-bottom: 1px solid var(--ai-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.ai-sidebar-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--ai-text);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.ai-sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.ai-chat-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--ai-text);
    margin: 0;
}

.ai-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-home-link {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ai-text);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s;
}

.ai-home-link:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Welcome Section */
.ai-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 40px;
    text-align: center;
}

.ai-welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-light));
    padding: 3px;
}

.ai-welcome-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #fff;
    object-fit: cover;
}

.ai-welcome-text {
    font-size: 28px;
    font-weight: 600;
    color: var(--ai-text);
    margin: 0 0 32px;
    font-family: 'Playfair Display', Georgia, serif;
}

/* 今日信息卡片区域 */
.ai-welcome-info {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 680px;
    margin: 0 auto 28px;
}

.ai-info-card {
    flex: 1;
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 14px;
    padding: 16px;
    text-align: left;
    transition: all 0.2s ease;
}

.ai-info-card:hover {
    box-shadow: var(--ai-shadow);
    transform: translateY(-2px);
}

.ai-info-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4eaf0;
}

.ai-info-icon {
    font-size: 20px;
}

.ai-info-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ai-text);
}

.ai-info-card-body {
    font-size: 13px;
    color: var(--ai-text-light);
    line-height: 1.7;
}

.ai-info-loading {
    color: var(--ai-text-muted);
    font-size: 12px;
}

/* 天气卡片 */
.ai-weather-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-weather-temp {
    font-size: 32px;
    font-weight: 700;
    color: var(--ai-primary-dark);
    line-height: 1;
}

.ai-weather-detail {
    font-size: 13px;
    color: var(--ai-text-light);
    line-height: 1.6;
}

.ai-weather-city {
    font-size: 12px;
    color: var(--ai-text-muted);
    margin-top: 8px;
}

/* 新闻卡片 */
.ai-news-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ai-news-item {
    padding: 6px 0;
    border-bottom: 1px solid #edf2f7;
    font-size: 13px;
    color: var(--ai-text);
    line-height: 1.5;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.ai-news-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ai-news-item:hover {
    color: var(--ai-primary-dark);
}

.ai-news-index {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--ai-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.ai-news-index.normal {
    background: #c0cdd8;
}

.ai-news-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Suggestion Cards (Mobile) */
.ai-suggestions-mobile {
    display: none;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.ai-suggestion-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 90px;
}

.ai-suggestion-card:hover {
    border-color: var(--ai-primary);
    box-shadow: var(--ai-shadow);
    transform: translateY(-2px);
}

.ai-suggestion-icon {
    font-size: 24px;
}

.ai-suggestion-text {
    font-size: 13px;
    color: var(--ai-text);
    font-weight: 500;
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.ai-chat-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageFadeIn 0.3s ease;
}

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

.ai-chat-message.ai,
.ai-chat-message.assistant {
    align-self: flex-start;
}

.ai-chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-light));
    padding: 2px;
}

.ai-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #fff;
    object-fit: cover;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-chat-message.ai .ai-message-content,
.ai-chat-message.assistant .ai-message-content {
    background: var(--ai-ai-bubble);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

.ai-chat-message.user .ai-message-content {
    background: var(--ai-user-bubble);
    color: var(--ai-text);
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px;
}

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

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

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.ai-chat-input-area {
    padding: 16px 40px 24px;
    background: var(--ai-bg);
    border-top: 1px solid var(--ai-border);
}

.ai-chat-quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.ai-quick-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--ai-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-quick-btn:hover {
    border-color: var(--ai-primary);
    color: var(--ai-primary);
}

.ai-quick-btn svg {
    fill: var(--ai-primary);
}

.ai-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    box-shadow: var(--ai-shadow);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-input-wrapper:focus-within {
    border-color: var(--ai-primary);
    box-shadow: 0 2px 16px rgba(74, 141, 183, 0.15);
}

.ai-chat-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ai-text);
    resize: none;
    max-height: 120px;
    min-height: 24px;
    padding: 8px 0;
    outline: none;
    font-family: inherit;
}

.ai-chat-input::placeholder {
    color: var(--ai-text-muted);
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ai-primary);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    background: var(--ai-primary-dark);
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    background: var(--ai-border);
    cursor: not-allowed;
    transform: none;
}

.ai-input-hint {
    text-align: center;
    font-size: 12px;
    color: var(--ai-text-muted);
    margin-top: 8px;
}

/* Sidebar Overlay (Mobile) */
.ai-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Music List in Messages */
.ai-music-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.ai-music-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-music-item:hover {
    border-color: var(--ai-primary);
    box-shadow: var(--ai-shadow);
}

.ai-music-cover {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.ai-music-cover img {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    object-fit: cover;
}

.ai-music-info {
    flex: 1;
    min-width: 0;
}

.ai-music-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ai-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-music-artist {
    font-size: 12px;
    color: var(--ai-text-light);
    margin-top: 2px;
}

.ai-music-play {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ai-primary);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.ai-music-play:hover {
    transform: scale(1.1);
}

/* Video Embed in Messages */
.ai-video-embed {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.ai-video-embed iframe {
    width: 100%;
    height: 200px;
    border: none;
    display: block;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .ai-chat-sidebar {
        width: 220px;
    }
    
    .ai-chat-messages {
        padding: 16px 24px;
    }
    
    .ai-chat-input-area {
        padding: 12px 24px 20px;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .ai-chat-layout {
        flex-direction: column;
    }
    
    .ai-chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 999;
        transform: translateX(-100%);
        width: 280px;
    }
    
    .ai-chat-sidebar.sidebar-open {
        transform: translateX(0);
    }
    
    .ai-chat-mobile-header {
        display: flex;
    }
    
    .ai-chat-welcome {
        padding: 40px 16px 24px;
    }
    
    .ai-welcome-text {
        font-size: 22px;
        margin-bottom: 24px;
    }
    
    .ai-welcome-info {
        flex-direction: column;
        gap: 12px;
        padding: 0 4px;
    }
    
    .ai-suggestions-mobile {
        display: flex;
    }
    
    .ai-chat-messages {
        padding: 12px 16px;
        padding-bottom: 100px;
    }
    
    .ai-chat-message {
        max-width: 92%;
    }
    
    .ai-message-content {
        font-size: 15px;
        padding: 10px 14px;
    }
    
    .ai-chat-input-area {
        position: fixed;
        bottom: calc(49px + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        padding: 12px 16px 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid var(--ai-border);
        z-index: 100;
    }
    
    .ai-chat-quick-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin-bottom: 8px;
    }
    
    .ai-chat-quick-actions::-webkit-scrollbar {
        display: none;
    }
    
    .ai-quick-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .ai-input-wrapper {
        padding: 6px 6px 6px 16px;
    }
    
    .ai-chat-input {
        font-size: 16px;
    }
    
    .ai-input-hint {
        display: none;
    }
    
    .ai-sidebar-overlay.active {
        display: block;
    }
    
    /* Hide welcome when has messages */
    .ai-chat-messages:not(:empty) ~ .ai-chat-welcome {
        display: none;
    }
    
    /* Video embed mobile */
    .ai-video-embed iframe {
        height: 180px;
    }
}

/* Small Mobile */
@media (max-width: 375px) {
    .ai-welcome-text {
        font-size: 20px;
    }
    
    .ai-info-card {
        padding: 12px;
    }
    
    .ai-suggestion-card {
        padding: 12px 16px;
        min-width: 80px;
    }
    
    .ai-suggestion-icon {
        font-size: 20px;
    }
    
    .ai-suggestion-text {
        font-size: 12px;
    }
}

/* Scrollbar Styling */
.ai-chat-messages::-webkit-scrollbar,
.ai-sidebar-history::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track,
.ai-sidebar-history::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb,
.ai-sidebar-history::-webkit-scrollbar-thumb {
    background: var(--ai-border);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover,
.ai-sidebar-history::-webkit-scrollbar-thumb:hover {
    background: var(--ai-primary-light);
}

/* Hide elements when not on AI chat page */
body:not(.ai-chat-page) .ai-chat-layout {
    display: none;
}

/* ===== Mode Selector ===== */
.ai-mode-selector {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.ai-mode-selector::-webkit-scrollbar {
    display: none;
}
.ai-mode-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 1px solid rgba(74, 141, 183, 0.3);
    border-radius: 20px;
    background: rgba(74, 141, 183, 0.08);
    color: #2E6E8F;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}
.ai-mode-btn:hover {
    background: rgba(74, 141, 183, 0.15);
    border-color: rgba(74, 141, 183, 0.5);
}
.ai-mode-btn.active {
    background: linear-gradient(135deg, #4A8DB7, #3A7A9E);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(74, 141, 183, 0.3);
}
.ai-mode-btn .mode-icon {
    font-size: 14px;
    line-height: 1;
}

/* 深度思考过程折叠区 */
.ai-thinking-process {
    margin-bottom: 12px;
    border: 1px solid rgba(74, 141, 183, 0.2);
    border-radius: 8px;
    overflow: hidden;
}
.thinking-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(74, 141, 183, 0.06);
    color: #2E6E8F;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.thinking-toggle:hover {
    background: rgba(74, 141, 183, 0.12);
}
.thinking-toggle .toggle-arrow {
    transition: transform 0.3s;
    font-size: 10px;
}
.thinking-toggle.expanded .toggle-arrow {
    transform: rotate(180deg);
}
.thinking-content {
    padding: 12px;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    border-top: 1px solid rgba(74, 141, 183, 0.15);
    background: rgba(74, 141, 183, 0.03);
    white-space: pre-wrap;
    display: none;
}

/* 移动端模式选择器调整 */
@media (max-width: 768px) {
    .ai-mode-selector {
        padding: 6px 12px;
    }
    .ai-mode-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* ===== Markdown Content Styles ===== */
.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4,
.ai-message-content h5,
.ai-message-content h6 {
    margin: 16px 0 8px;
    font-weight: 600;
    line-height: 1.4;
    color: #333;
}
.ai-message-content h1 { font-size: 20px; }
.ai-message-content h2 { font-size: 18px; }
.ai-message-content h3 { font-size: 16px; }
.ai-message-content h4 { font-size: 15px; }

.ai-message-content p {
    margin: 0 0 8px;
    line-height: 1.7;
}
.ai-message-content p:last-child {
    margin-bottom: 0;
}

.ai-message-content ul,
.ai-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}
.ai-message-content li {
    margin: 4px 0;
    line-height: 1.6;
}

.ai-message-content blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 3px solid var(--ai-primary, #4A8DB7);
    background: rgba(74, 141, 183, 0.06);
    border-radius: 0 6px 6px 0;
    color: #666;
}

.ai-message-content hr {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.1);
    margin: 12px 0;
}

/* 行内代码 */
.ai-message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    color: #c7254e;
}

/* 代码块容器 */
.code-block-wrapper {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #21252b;
    font-size: 12px;
}
.code-lang {
    color: #abb2bf;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.code-copy-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #abb2bf;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.code-copy-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* 代码块 */
.ai-message-content pre {
    margin: 0;
    padding: 12px 16px;
    background: #282c34;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ai-message-content pre code {
    background: none;
    color: #abb2bf;
    padding: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre;
}

/* 表格 */
.ai-message-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
    font-size: 14px;
    overflow-x: auto;
    display: block;
}
.ai-message-content thead {
    background: rgba(74, 141, 183, 0.1);
}
.ai-message-content th,
.ai-message-content td {
    border: 1px solid rgba(0,0,0,0.1);
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
}
.ai-message-content th {
    font-weight: 600;
    color: #333;
}

/* 链接 */
.ai-message-content a {
    color: var(--ai-primary, #4A8DB7);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}
.ai-message-content a:hover {
    border-bottom-color: var(--ai-primary, #4A8DB7);
}

/* 强调文本 */
.ai-message-content strong {
    font-weight: 600;
    color: #333;
}
.ai-message-content em {
    font-style: italic;
}
.ai-message-content del {
    text-decoration: line-through;
    color: #999;
}

/* highlight.js主题适配 */
.hljs {
    background: #282c34 !important;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .ai-message-content pre {
        font-size: 12px;
        padding: 10px 12px;
    }
    .ai-message-content table {
        font-size: 12px;
    }
    .ai-message-content th,
    .ai-message-content td {
        padding: 6px 8px;
    }
    .code-block-wrapper {
        margin: 8px -8px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* 流式输出光标动画 */
.stream-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: var(--ai-primary, #4A8DB7);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.8s ease-in-out infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.ai-chat-message.streaming .ai-message-content {
    min-height: 24px;
}

/* 流式期间禁用输入的样式 */
.ai-chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.ai-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
