/* 
 * 小约打车助手 - 样式表
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* 主布局 */
.main-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    max-width: 1200px;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s;
}

.new-chat-btn:hover {
    opacity: 0.9;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.session-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 5px;
    transition: background 0.2s;
}

.session-item:hover {
    background: #e9ecef;
}

.session-item.active {
    background: #e7f5ff;
    border-left: 3px solid #667eea;
}

.session-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.session-time {
    font-size: 11px;
    color: #868e96;
}

/* 主内容区 */
.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* 头部 */
.header {
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #495057;
}

.header h1 {
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

.status-bar {
    display: flex;
    gap: 20px;
    font-size: 14px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-label {
    color: #868e96;
}

.status-value {
    color: #667eea;
    font-weight: 600;
    background: #edf2ff;
    padding: 2px 8px;
    border-radius: 12px;
}

/* 对话区域 */
.chat-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.chat-messages {
    max-width: 800px;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 15px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.message-content {
    /* flex: 1; */
    max-width: 80%;
    width: fit-content;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    line-height: 1.6;
    font-size: 15px;
    color: #333;
    position: relative;
    overflow-wrap: break-word;
}

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

.user-message .message-content {
    background: #667eea;
    color: #fff;
}

.bot-message .message-content {
    background: #fff;
    border-top-left-radius: 2px;
}

.user-message .message-content {
    border-top-right-radius: 2px;
}

/* 底部输入区 */
.input-area {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #e9ecef;
}

.quick-inputs {
    max-width: 800px;
    margin: 0 auto 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-btn {
    padding: 6px 15px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    color: #495057;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: #f1f3f5;
    border-color: #ced4da;
    transform: translateY(-1px);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 12px 20px;
    border: 1px solid #ced4da;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

#user-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    padding: 0 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.send-btn:active {
    transform: translateY(0);
}

.stop-btn {
    background: #e03131 !important;
    box-shadow: 0 2px 5px rgba(224, 49, 49, 0.3) !important;
}

.stop-btn:hover {
    background: #c92a2a !important;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

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

/* Paragraphs */
.message-content p {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Lists */
.message-content ul, .message-content ol {
    padding-left: 24px;
    margin-bottom: 10px;
}
.message-content li {
    margin-top: 4px;
}

/* Code Blocks */
.message-content pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    padding: 12px;
    overflow: auto;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 85%;
    line-height: 1.45;
    margin-bottom: 10px;
}
.message-content code {
    background-color: rgba(175, 184, 193, 0.2);
    border-radius: 4px;
    padding: 0.2em 0.4em;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 85%;
}
.message-content pre code {
    background-color: transparent;
    padding: 0;
}

/* Tables (Obsidian style) */
.message-content table {
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
    display: block;
    overflow-x: auto;
}
.message-content th, .message-content td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
}
.message-content th {
    background-color: #f6f8fa;
    font-weight: 600;
}
.message-content tr:nth-child(2n) {
    background-color: #f6f8fa;
}

/* Blockquotes */
.message-content blockquote {
    border-left: 4px solid #dfe2e5;
    color: #6a737d;
    padding: 0 1em;
    margin: 0 0 16px 0;
}

/* 思考过程（CoT）样式 */
.thought-container {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.thought-header {
    padding: 8px 12px;
    font-size: 12px;
    color: #868e96;
    background: #f1f3f5;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
}

.thought-header:hover {
    background: #e9ecef;
}

.thought-details {
    padding: 12px;
    font-size: 13px;
    color: #495057;
    background: #fff;
    border-top: 1px solid #e9ecef;
    display: none;
}

.thought-container.expanded .thought-details {
    display: block;
}

.toggle-icon {
    font-size: 10px;
    transition: transform 0.2s;
}

.thought-container.expanded .toggle-icon {
    transform: rotate(180deg);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.active {
        left: 0;
        transform: none;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .quick-inputs {
        overflow-x: auto;
        padding-bottom: 5px;
    }
    
    .quick-btn {
        white-space: nowrap;
    }
}
