/**
 * 微单·IT项目价格评估 - 聊天页专用样式
 * @createtime 2025/12/13
 * @update 2026/01/09
 */

/* ========== 微单侧边栏 ========== */
.microproj-sidebar {
    width: 260px;
    min-width: 260px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.microproj-sidebar .sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.microproj-sidebar .sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.microproj-sidebar .sidebar-title svg {
    width: 22px;
    height: 22px;
    color: #6366f1;
}

.microproj-sidebar .sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.microproj-sidebar .sidebar-section {
    margin-bottom: 24px;
}

.microproj-sidebar .sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 8px;
}

.btn-new-chat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-new-chat:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-new-chat svg {
    width: 18px;
    height: 18px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #4b5563;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.15s ease;
}

.sidebar-menu-item:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.sidebar-menu-item.active {
    background: #eef2ff;
    color: #6366f1;
}

.sidebar-menu-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-menu-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-empty {
    padding: 12px;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

/* ========== 主内容区域 ========== */
.projpricing-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    min-height: auto !important;
}

/* ========== 聊天主体容器 ========== */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

/* ========== 聊天消息区域 ========== */
#chat-container {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 0;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    scroll-behavior: smooth;
}

/* ========== 消息样式（新版本） ========== */
.message {
    display: flex;
    gap: 12px;
    max-width: 100%;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 60px);
}

.message-text {
    padding: 14px 18px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-text {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

.message.assistant .message-text {
    background: #fff;
    color: #1f2937;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
}

/* 加载动画 */
.loading-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    animation: loading-bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* 错误消息 */
.error-msg {
    color: #ef4444;
}

.stopped-hint {
    color: #9ca3af;
    font-size: 13px;
}

/* ========== Markdown内容样式 ========== */
.message-text h1,
.message-text h2,
.message-text h3 {
    margin: 16px 0 10px 0;
    line-height: 1.4;
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
    margin-top: 0;
}

.message-text h1 { font-size: 20px; font-weight: 600; }
.message-text h2 { font-size: 18px; font-weight: 600; }
.message-text h3 { font-size: 16px; font-weight: 600; }

.message-text p {
    margin: 10px 0;
}

.message-text ul {
    margin: 10px 0;
    padding-left: 24px;
    list-style-type: disc;
}

.message-text ol {
    margin: 10px 0;
    padding-left: 24px;
    list-style-type: decimal;
}

.message-text li {
    margin: 5px 0;
    padding-left: 4px;
}

.message-text ul ul {
    list-style-type: circle;
    margin: 4px 0;
}

.message-text ul ul ul {
    list-style-type: square;
}

.message-text code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message-text pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 15px 0;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
}

.message-text th,
.message-text td {
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    text-align: left;
}

.message-text th {
    background: #f9fafb;
    font-weight: 600;
}

.message-text tr:nth-child(even) {
    background: #f9fafb;
}

.message-text blockquote {
    border-left: 4px solid #6366f1;
    padding-left: 15px;
    margin: 15px 0;
    color: #6b7280;
}

.message-text hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 20px 0;
}

.message-text a {
    color: #6366f1;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

.message-text strong {
    font-weight: 600;
}

/* ========== 输入容器 - 固定在底部 ========== */
#input-container {
    background: #fff;
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    max-width: 900px;
    margin: 0 auto 10px;
    width: calc(100% - 40px);
    flex-shrink: 0;
}

/* ========== 工具栏 ========== */
#toolbar-area {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

/* ========== 工具栏按钮 ========== */
.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
    color: #4b5563;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: #e5e7eb;
    border-color: #6366f1;
    color: #6366f1;
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

/* ========== 文件预览 ========== */
#file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.file-item {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid #e5e7eb;
}

.file-item .file-name {
    margin-right: 8px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4b5563;
}

.file-item .file-remove {
    cursor: pointer;
    color: #9ca3af;
    font-size: 16px;
    line-height: 1;
    font-weight: bold;
}

.file-item .file-remove:hover {
    color: #ef4444;
}

.file-item img.file-thumbnail {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 6px;
    margin-right: 8px;
}

/* ========== 输入行 ========== */
#input-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    line-height: 24px;
    padding: 10px 0;
    max-height: 150px;
    font-family: inherit;
    color: #1f2937;
}

#user-input::placeholder {
    color: #9ca3af;
}

/* ========== 发送按钮 ========== */
.chat-send-btn {
    position: static !important;
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: none;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* ========== 停止按钮 ========== */
.chat-stop-btn {
    width: 44px;
    height: 44px;
    background: #ef4444;
    border: none;
    cursor: pointer;
    border-radius: 12px;
    color: #fff;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-stop-btn:hover {
    background: #dc2626;
}

.chat-stop-btn svg {
    width: 20px;
    height: 20px;
}

/* ========== AI提示样式 ========== */
#ai-use-tip {
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
    padding: 8px 20px 12px;
    flex-shrink: 0;
}

/* ========== 消息内下载按钮 ========== */
.msg-download-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #e5e7eb;
}

.msg-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(99, 102, 241, 0.4);
}


/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .microproj-sidebar {
        display: none;
    }
    
    .projpricing-main {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .projpricing-main {
        height: calc(100vh - 44px);
        max-height: calc(100vh - 44px);
    }
    
    .chat-wrapper {
        padding: 0;
    }
    
    #chat-container {
        padding: 12px;
        gap: 16px;
    }
    
    .message-text {
        padding: 12px 14px;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
    }
    
    #input-container {
        padding: 12px 14px;
    }
    
    #toolbar-area {
        gap: 8px;
    }
    
    .message-text table {
        font-size: 12px;
    }
    
    .message-text th,
    .message-text td {
        padding: 6px 8px;
    }
}
