/* 首页 AI 助手样式 */
/* 使用首页主题的颜色变量，如果未定义则使用默认值 */
:root {
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s;
    z-index: 90;
    border: none;
}

.chat-button:hover {
    transform: scale(1.1);
    background-color: var(--primary-hover);
}

.chat-button.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.chat-modal {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 48px);
    background-color: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 95;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border-color);
}

.chat-modal.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-header {
    padding: 16px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-close:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f8fafc;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    overflow-x: auto;
}

.user-message .message-content {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* Markdown 样式支持 */
.message-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.message-text p {
    margin: 8px 0;
}

.message-text p:first-child {
    margin-top: 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul,
.message-text ol {
    padding-left: 20px;
    margin: 10px 0;
}

.message-text li {
    margin: 4px 0;
}

.message-text code {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    word-break: break-all;
    overflow-wrap: break-word;
}

.message-text pre {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    max-width: 100%;
}

.message-text pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    word-break: normal;
    overflow-wrap: normal;
}

.message-text a {
    color: var(--primary-color);
    text-decoration: underline;
    word-break: break-all;
    overflow-wrap: break-word;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    display: block;
    overflow-x: auto;
    max-width: 100%;
}

.message-text table th,
.message-text table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
}

.message-text blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-text h1 { font-size: 1.5rem; }
.message-text h2 { font-size: 1.3rem; }
.message-text h3 { font-size: 1.1rem; }
.message-text h4 { font-size: 1rem; }

.chat-input-container {
    padding: 16px;
    background-color: white;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 16px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input-container textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-container textarea:focus {
    border-color: var(--primary-color);
}

.chat-input-container button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.chat-input-container button:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
}

.chat-input-container button:not(:disabled):hover {
    background-color: var(--primary-hover);
}

/* Audio Controls */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.audio-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
}

.audio-btn:hover {
    background-color: #eff6ff;
}

.audio-visualizer {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 16px;
}

.audio-visualizer .bar {
    width: 3px;
    height: 4px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: height 0.1s;
}

.audio-visualizer.playing .bar {
    animation: visualize 0.5s infinite ease-in-out alternate;
}

.audio-visualizer.playing .bar:nth-child(1) { animation-delay: 0s; }
.audio-visualizer.playing .bar:nth-child(2) { animation-delay: 0.1s; }
.audio-visualizer.playing .bar:nth-child(3) { animation-delay: 0.2s; }
.audio-visualizer.playing .bar:nth-child(4) { animation-delay: 0.3s; }
.audio-visualizer.playing .bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes visualize {
    0% { height: 4px; }
    100% { height: 16px; }
}

.audio-progress {
    flex: 1;
    height: 4px;
    background-color: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.audio-progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0;
    transition: width 0.1s;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-modal {
        width: calc(100vw - 48px);
        height: calc(100vh - 48px);
        max-height: calc(100vh - 48px);
    }
}

