/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #10a37f;
    --primary-hover: #0d8c6d;
    --background: #ffffff;
    --surface: #f7f7f8;
    --sidebar-bg: #202123;
    --sidebar-hover: #2a2b32;
    --border-color: #e5e5e5;
    --text-primary: #212121;
    --text-secondary: #6e6e80;
    --text-light: #ffffff;
    --input-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--background);
    color: var(--text-primary);
    overflow: hidden;
}

/* 主容器 */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 顶部导航栏 */
.top-bar {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--background);
    position: relative;
}

.ai-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.clear-history-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.clear-history-btn:hover {
    background-color: #fee;
    color: #dc2626;
}

.spacer {
    flex: 1;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    background-color: var(--background);
}

.messages {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 欢迎界面 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: 60vh;
}

.welcome-icon {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-title span {
    color: var(--primary-color);
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    max-width: 500px;
}

.example-questions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 700px;
}

.example-card {
    padding: 16px;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    text-align: left;
}

.example-card:hover {
    background-color: var(--border-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.example-card svg {
    color: var(--primary-color);
    flex-shrink: 0;
}

.example-card span {
    font-size: 14px;
    color: var(--text-primary);
}

/* 消息样式 */
.message {
    display: flex;
    gap: 16px;
    padding: 24px 0;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background-color: var(--surface);
    margin: 0 -20px;
    padding: 24px 20px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 14px;
}

.message.user .message-avatar {
    background-color: var(--primary-color);
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-content {
    flex: 1;
    line-height: 1.6;
    font-size: 15px;
    color: var(--text-primary);
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background-color: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message-content pre {
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: var(--text-light);
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 输入区域 */
.input-area {
    padding: 20px;
    background-color: var(--background);
    border-top: 1px solid var(--border-color);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background-color: transparent;
    max-height: 200px;
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--background);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.close-btn:hover {
    background-color: var(--surface);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.settings-section {
    margin-bottom: 24px;
}

.setting-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.setting-input,
.setting-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--input-bg);
    transition: border-color 0.2s;
}

.setting-input:focus,
.setting-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.setting-textarea {
    resize: vertical;
    min-height: 100px;
}

.setting-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.endpoint-item {
    background-color: var(--surface);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.endpoint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.endpoint-name {
    font-weight: 600;
    font-size: 14px;
}

.endpoint-actions {
    display: flex;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.endpoint-field {
    margin-bottom: 8px;
}

.endpoint-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.endpoint-field input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
}

.add-endpoint-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--surface);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.add-endpoint-btn:hover {
    background-color: var(--border-color);
}

.settings-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    .top-bar {
        height: 56px;
        padding: 0 16px;
    }

    .ai-name {
        font-size: 16px;
    }

    .messages {
        padding: 16px;
    }

    .message {
        padding: 16px 0;
    }

    .message.user {
        margin: 0 -16px;
        padding: 16px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .message-content {
        font-size: 14px;
    }

    .welcome-screen {
        padding: 20px;
        min-height: 50vh;
    }

    .welcome-title {
        font-size: 24px;
    }

    .welcome-subtitle {
        font-size: 14px;
    }

    .example-questions {
        grid-template-columns: 1fr;
    }

    .input-area {
        padding: 12px;
    }

    .input-container {
        padding: 8px;
    }

    .message-input {
        font-size: 14px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }

    .modal-content {
        max-height: 85vh;
    }

    .modal-header,
    .modal-body {
        padding: 16px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}


