/* Chatbot Stylesheet for Chi Zhang's Personal Website */

/* Chatbot Description */
.chatbot-description {
    margin-bottom: 1.5rem;
    color: #555;
    line-height: 1.6;
}

.model-info-text {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Model Selection */
.model-selection-container {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.model-selection-container label {
    font-weight: bold;
    color: #333;
    margin-right: 0.5rem;
}

.model-select {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s ease;
    min-width: 200px;
}

.model-select:focus {
    border-color: #3498db;
}

.apply-model-button {
    padding: 0.6rem 1.2rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    margin-left: 0.8rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 0.9rem;
    /* Improve touch target size for mobile */
    min-height: 44px;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    /* Prevent text selection */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.apply-model-button:hover {
    background-color: #2980b9;
}

.apply-model-button:active,
.apply-model-button.active {
    background-color: #1f6aa5;
    transform: translateY(1px);
}

/* 主题切换按钮 */
.theme-toggle-button {
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle-button:hover {
    background-color: #e9ecef;
}

@media (max-width: 768px) {
    .model-selection-container {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .model-select {
        width: 100%;
    }
    
    .apply-model-button {
        margin-left: 0;
        margin-top: 0.8rem;
        width: 100%;
    }
}

/* Chatbot Container */
.chatbot-container {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    margin-bottom: 2rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 550px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid #e3e3e3;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Message Styling */
.message {
    display: flex;
    margin-bottom: 1rem;
    max-width: 80%;
}

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

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

.message-content {
    padding: 0.8rem 1.2rem;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-message .message-content {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
    background-color: #f5f7f9;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e8ec;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
}

/* Markdown Styling */
.message-content h1, 
.message-content h2, 
.message-content h3, 
.message-content h4, 
.message-content h5, 
.message-content h6 {
    margin-top: 0.8rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
    line-height: 1.2;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.2rem; }
.message-content h4 { font-size: 1.1rem; }
.message-content h5, .message-content h6 { font-size: 1rem; }

.message-content ul, 
.message-content ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content code {
    font-family: monospace;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.9em;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
}

.message-content blockquote {
    border-left: 3px solid #ccc;
    margin: 0.5rem 0;
    padding-left: 1rem;
    color: #666;
}

.message-content table {
    border-collapse: collapse;
    margin: 0.5rem 0;
    width: 100%;
}

.message-content th, 
.message-content td {
    border: 1px solid #ddd;
    padding: 0.4rem;
    text-align: left;
}

.message-content th {
    background-color: rgba(0, 0, 0, 0.05);
}

.message-content a {
    color: #3498db;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0.5rem 0;
}

/* Adjust colors for user messages */
.user-message .message-content code,
.user-message .message-content pre {
    background-color: rgba(255, 255, 255, 0.2);
}

.user-message .message-content a {
    color: #fff;
    text-decoration: underline;
}

.user-message .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

/* Chat Input */
.chat-input-container {
    display: flex;
    padding: 1rem;
    border-top: 1px solid #eaeaea;
    background-color: #f8f9fa;
    position: relative;
}

.chat-input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #3498db;
}

.input-buttons {
    display: flex;
    align-items: center;
    margin-left: 0.8rem;
}

.send-button {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.send-button:hover {
    background-color: #2980b9;
}

.send-button svg {
    width: 20px;
    height: 20px;
}

/* Chat Controls */
.chat-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0 1rem 1rem;
    background-color: #f8f9fa;
}

/* Clear Chat Button */
.clear-chat-button {
    padding: 0.6rem 1.2rem;
    background-color: #f8f9fa;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.clear-chat-button:hover {
    background-color: #e9ecef;
    color: #333;
}

/* Export Chat Button */
.export-chat-button {
    padding: 0.6rem 1.2rem;
    background-color: #f8f9fa;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.export-chat-button:hover {
    background-color: #e9ecef;
    color: #333;
}

/* API Key Container */
.api-key-container {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.api-key-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #333;
}

.api-key-input-container {
    display: flex;
    margin-bottom: 0.8rem;
}

.api-key-input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.api-key-input:focus {
    border-color: #3498db;
}

.save-api-key-button {
    padding: 0.8rem 1.2rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    margin-left: 0.8rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.save-api-key-button:hover {
    background-color: #2980b9;
}

.api-key-help {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

.api-key-help a {
    color: #3498db;
    text-decoration: none;
}

.api-key-help a:hover {
    text-decoration: underline;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.loading-dots {
    display: flex;
    gap: 0.4rem;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background-color: #3498db;
    border-radius: 50%;
    animation: pulse 1.5s infinite ease-in-out;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Error Message */
.error-message {
    color: #e74c3c;
    background-color: #fadbd8;
    padding: 0.8rem 1.2rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: none;
}

.error-message.visible {
    display: block;
}

/* 深色模式样式 */
body.dark-theme {
    background-color: #1a1a1a;
    color: #f0f0f0;
}

body.dark-theme .container {
    background-color: #1a1a1a;
    color: #f0f0f0;
}

body.dark-theme main {
    background-color: #1a1a1a;
}

body.dark-theme .header h1 {
    color: #f0f0f0;
}

body.dark-theme .chatbot-description {
    color: #aaa;
}

body.dark-theme .chatbot-container {
    background-color: #2d2d2d;
    border-color: #3d3d3d;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

body.dark-theme .chat-input-container {
    background-color: #252525;
    border-top-color: #3d3d3d;
}

body.dark-theme .chat-input {
    background-color: #333;
    color: #f0f0f0;
    border-color: #444;
}

body.dark-theme .bot-message .message-content {
    background-color: #3d3d3d;
    color: #f0f0f0;
    border-color: #4d4d4d;
}

body.dark-theme .user-message .message-content {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

body.dark-theme .model-selection-container {
    background-color: #2d2d2d;
}

body.dark-theme .model-select {
    background-color: #333;
    color: #f0f0f0;
    border-color: #444;
}

body.dark-theme .chat-controls {
    background-color: #252525;
}

body.dark-theme .clear-chat-button,
body.dark-theme .export-chat-button {
    background-color: #333;
    color: #f0f0f0;
    border-color: #444;
}

body.dark-theme .model-info-text {
    color: #aaa;
}

body.dark-theme .theme-toggle-button {
    border-color: #444;
    color: #f0f0f0;
}

body.dark-theme .theme-toggle-button:hover {
    background-color: #3d3d3d;
}

body.dark-theme .footer {
    background-color: #1a1a1a;
    color: #ccc;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .chatbot-container {
        height: 70vh; /* 使用视窗高度更合理 */
        border-radius: 8px;
    }
    
    .message {
        max-width: 95%; /* 增加小屏幕上的最大宽度 */
    }
    
    .chat-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .clear-chat-button,
    .export-chat-button {
        width: 100%;
    }
    
    .message-content pre {
        max-width: 100%;
        overflow-x: auto;
    }
}
