@tailwind base;
@tailwind components;
@tailwind utilities;

/* 全局基础样式 */
html, body {
    height: 100%;
    font-family: "Microsoft Yahei", "PingFang SC", system-ui, sans-serif;
}

/* 侧边栏（手机端） */
#conv-sidebar {
    transition: left 0.3s ease;
}
@media (max-width: 768px) {
    #conv-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 999;
        width: 80%;
        max-width: 300px;
    }
    #conv-sidebar.expanded {
        left: 0;
    }
}

/* 对话项样式 */
.conv-item {
    cursor: pointer;
    transition: all 0.2s ease;
}
.conv-item.active {
    background-color: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}
.conv-item:hover:not(.active) {
    background-color: rgba(243, 244, 246, 1);
    transform: translateX(2px);
}
.dark .conv-item:hover:not(.active) {
    background-color: rgba(64, 64, 64, 0.5);
}

/* 消息组件样式 */
.message {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease forwards;
    opacity: 0;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user-message {
    align-items: flex-end;
}
.message.ai-message {
    align-items: flex-start;
}

.message-meta {
    margin: 0 8px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
}
.message.user-message .message-bubble {
    background-color: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
}
.message.ai-message .message-bubble {
    background-color: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}
.dark .message.ai-message .message-bubble {
    background-color: #374151;
    color: #f9fafb;
}

/* 聊天容器滚动样式 */
#chat-container {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}
#chat-container::-webkit-scrollbar {
    width: 6px;
}
#chat-container::-webkit-scrollbar-track {
    background: #f3f4f6;
}
#chat-container::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}
.dark #chat-container::-webkit-scrollbar-track {
    background: #1f2937;
}
.dark #chat-container::-webkit-scrollbar-thumb {
    background-color: #4b5563;
}

/* 输入框&模型选择器样式 */
#prompt-input {
    transition: all 0.2s ease;
}
#prompt-input:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
#model-select {
    transition: border-color 0.2s ease;
}
#model-select:focus {
    border-color: #3b82f6;
}

/* 设置面板动画 */
#settings-panel {
    position: fixed;
    right: -100%;
    top: 0;
    height: 100vh;
    z-index: 999;
    width: 80%;
    max-width: 300px;
    transition: right 0.3s ease;
}
#settings-panel.expanded {
    right: 0;
}

/* 消息状态样式（加载/失败） */
.message.loading .message-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
}
.loading-dots {
    display: flex;
    gap: 4px;
}
.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: bounce 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; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.message.error .message-bubble {
    background-color: #fee2e2;
    color: #dc2626;
}
.dark .message.error .message-bubble {
    background-color: #7f1d1d;
    color: #fecdd3;
}

/* 手机端适配细节 */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 85%;
    }
    .footer .btn {
        padding: 0 8px;
    }
    #prompt-input {
        min-height: 50px !important;
        padding: 10px !important;
    }
    .model-select-container {
        width: 100%;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 90%;
        padding: 10px 14px;
    }
    .message-meta {
        font-size: 10px;
    }
}
