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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 15px 15px 0 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    text-align: left;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.user-welcome {
    font-size: 0.9rem;
    opacity: 0.9;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.login-link {
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.login-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    text-decoration: none;
    color: white;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-left {
        text-align: center;
    }
}

.header h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1rem;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* 控制面板 */
.control-panel {
    background: white;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    height: fit-content;
}

.panel-section {
    margin-bottom: 18px;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.panel-section h3 {
    color: #4a5568;
    margin-bottom: 12px;
    font-size: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 6px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #4a5568;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 模型选择 */
.model-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.model-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.model-item:hover {
    border-color: #4285f4;
    background: #f8f9ff;
}

.model-item.selected {
    border-color: #4285f4;
    background: #e8f0fe;
}

.model-item input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.model-item label {
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

/* 按钮样式 */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e53e3e;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #c53030;
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover:not(:disabled) {
    background: #667eea;
    color: white;
}

/* 对话区域 */
.conversation-area {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 700px;
}

.conversation-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.conversation-header h3 {
    color: #4a5568;
    font-size: 1.1rem;
    margin: 0;
}

.status-info {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: #718096;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
    scroll-behavior: smooth;
}

/* 未读消息提示 */
.unread-indicator {
    position: relative;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 10px 20px;
    margin: 0 25px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(240, 147, 251, 0.3);
}

.unread-indicator button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.unread-indicator button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* 消息样式 */
.message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message.ai {
    flex-direction: row;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.message.user .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message.ai .avatar {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.message-bubble {
    max-width: 70%;
    padding: 15px 18px;
    border-radius: 18px;
    position: relative;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.ai .message-bubble {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #2d3748;
    border-bottom-left-radius: 6px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    opacity: 0.8;
}

.message-content {
    line-height: 1.5;
    word-wrap: break-word;
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.welcome-message p {
    margin-bottom: 10px;
    font-size: 16px;
}

/* 加载指示器 */
.loading-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #f7fafc;
    border-radius: 0 0 15px 15px;
}

.loading-indicator.show {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 统计信息 */
.statistics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

.stat-item {
    text-align: center;
    padding: 15px;
    border-radius: 10px;
    background: #f7fafc;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: #718096;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #4a5568;
}

/* 错误和警告消息 */
.error-message,
.warning-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 14px;
    animation: slideIn 0.3s ease;
}

.error-message {
    background: #fed7d7;
    color: #c53030;
    border-left: 4px solid #e53e3e;
}

.warning-message {
    background: #fefcbf;
    color: #d69e2e;
    border-left: 4px solid #ecc94b;
}

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

/* 打字指示器 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: #f7fafc;
    border-radius: 18px;
    margin: 10px 0;
    font-size: 14px;
    color: #718096;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .control-panel {
        order: 2;
    }
    
    .conversation-area {
        order: 1;
        height: 500px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .statistics {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .statistics {
        grid-template-columns: 1fr;
    }
    
    .status-info {
        flex-direction: column;
        gap: 5px;
    }
}