/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

/* 头部样式 */
.header {
    background-color: #007bff;
    color: white;
    padding: 15px;
    text-align: center;
    position: relative;
}

.header h1 {
    margin: 0;
    font-size: 1.5em;
}

/* 语言切换按钮 */
.language-switch {
    position: absolute;
    top: 15px;
    right: 15px;
}

.language-switch button {
    margin-left: 5px;
    padding: 5px 10px;
    background-color: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.language-switch button.active {
    background-color: white;
    color: #007bff;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
    height: calc(100vh - 120px);
}

/* 聊天历史记录 */
.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    max-width: 80%;
}

.user-message {
    background-color: #dcf8c6;
    margin-left: auto;
}

.ai-message {
    background-color: #e5e5ea;
    margin-right: auto;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.message-header strong {
    flex: 1;
}

.message-actions {
    display: flex;
    gap: 5px;
}

.edit-btn, .delete-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 3px 6px;
    font-size: 11px;
    cursor: pointer;
}

.edit-btn:hover, .delete-btn:hover {
    background-color: #5a6268;
}

.delete-btn {
    background-color: #dc3545;
}

.delete-btn:hover {
    background-color: #c82333;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

/* 输入区域 */
.input-container {
    display: flex;
    padding: 15px;
    background-color: #f0f0f0;
    border-top: 1px solid #ddd;
}

#message-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: none;
    height: 60px;
}

.input-controls {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    width: 180px;
}

#send-btn {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 5px;
}

#prompt-input {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

#update-prompt-btn {
    width: 100%;
    padding: 5px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 5px;
    font-size: 12px;
}

#update-prompt-btn:hover {
    background-color: #218838;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 10px;
    color: #777;
    font-size: 14px;
    background-color: white;
    border-top: 1px solid #eee;
}

/* 登录/注册页面样式 */
.login-container {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    margin-top: 50px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.error {
    color: red;
    margin-bottom: 15px;
    text-align: center;
}

.btn {
    width: 100%;
    padding: 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.btn:hover {
    background-color: #0056b3;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        flex-direction: column;
    }
    
    .chat-history {
        height: calc(100vh - 180px);
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-container {
        flex-direction: column;
    }
    
    .input-controls {
        width: 100%;
        margin-left: 0;
        margin-top: 10px;
    }
    
    #message-input {
        height: 80px;
    }
    
    .language-switch {
        position: static;
        margin-top: 10px;
    }
    
    .language-switch button {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* 管理员面板样式 */
.admin-container {
    max-width: 1000px;
    margin: 0 auto;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-top: 20px;
}

.nav {
    background-color: #343a40;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
}

.nav a {
    color: white;
    text-decoration: none;
    padding: 10px 15px;
    margin-right: 5px;
    border-radius: 3px;
    margin-bottom: 5px;
}

.nav a:hover, .nav a.active {
    background-color: #007bff;
}

.content {
    padding: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f8f9fa;
}

.logout {
    float: right;
    background-color: #dc3545;
}

.logout:hover {
    background-color: #c82333;
}

.message-success {
    color: green;
    margin-bottom: 15px;
}

/* 安装页面样式 */
.install-container {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    margin-top: 50px;
}

.custom-model-container {
    margin-top: 10px;
    display: none;
}

/* 移动端聊天样式优化 */
.mobile-chat-container {
    height: calc(100vh - 120px);
}

.mobile-message {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
}

.mobile-user-message {
    background-color: #007bff;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.mobile-ai-message {
    background-color: #e5e5ea;
    color: black;
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

.mobile-input-container {
    display: flex;
    padding: 10px;
    background-color: #f0f2f5;
    border-top: 1px solid #e0e0e0;
    align-items: flex-end;
}

#mobile-message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    height: 40px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 16px;
}

.mobile-input-controls {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
}

#mobile-send-btn {
    padding: 10px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

#mobile-prompt-input {
    width: 180px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 12px;
    margin-top: 5px;
}

#mobile-update-prompt-btn {
    width: 100%;
    padding: 5px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 5px;
    font-size: 12px;
}

#mobile-update-prompt-btn:hover {
    background-color: #218838;
}

/* 编辑输入框样式 */
.edit-input {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    margin-top: 5px;
    resize: vertical;
}

.save-edit-btn, .cancel-edit-btn {
    padding: 3px 8px;
    margin-top: 5px;
    margin-right: 5px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.save-edit-btn {
    background-color: #28a745;
    color: white;
}

.save-edit-btn:hover {
    background-color: #218838;
}

.cancel-edit-btn {
    background-color: #6c757d;
    color: white;
}

.cancel-edit-btn:hover {
    background-color: #5a6268;
}

/* 加载指示器样式 */
.loading-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 5px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ai-typing {
    display: flex;
    align-items: center;
    padding: 10px;
    margin: 10px 0;
    background-color: #e5e5ea;
    border-radius: 5px;
    color: #666;
}

.ai-typing-text {
    margin-left: 10px;
}
