/* ==================== AI 工作台 - 全局样式 ==================== */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-body);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    min-height: 100vh;
}

/* ==================== 导航栏 ==================== */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.brand-icon {
    font-size: 1.8rem;
    line-height: 1;
}

/* ==================== 统计卡片 ==================== */
.stat-card {
    border-radius: var(--radius);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.stat-number {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-label {
    font-size: .82rem;
    color: var(--text-muted);
}

/* ==================== 工作流预览（仪表板） ==================== */
.workflow-preview {
    padding: .5rem 0;
}
.workflow-node-preview {
    background: #f8fafc;
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: .75rem 1.1rem;
    text-align: center;
    min-width: 110px;
    position: relative;
}
.workflow-node-preview .node-num {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.workflow-node-preview .node-icon { font-size: 1.5rem; }
.workflow-node-preview .node-name {
    font-weight: 600;
    font-size: .82rem;
    margin-top: .25rem;
}
.workflow-node-preview .node-tool {
    font-size: .72rem;
    color: var(--text-muted);
}
.workflow-arrow {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 700;
}

/* ==================== 项目卡片 ==================== */
.project-card {
    border-radius: var(--radius);
    transition: transform .2s, box-shadow .2s;
}
.project-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md) !important;
}
.project-card .progress {
    border-radius: 100px;
    background: #e2e8f0;
}
.project-card .progress-bar {
    background: linear-gradient(90deg, var(--primary), #818cf8);
    border-radius: 100px;
    transition: width .6s ease;
}

.empty-icon {
    font-size: 3.5rem;
}

/* ==================== 工作流管道 ==================== */
.pipeline {
    scrollbar-width: thin;
    gap: 0;
}
.pipeline-stage {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.pipeline-card {
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem;
    text-align: center;
    min-width: 130px;
    transition: all .25s;
    position: relative;
}
.pipeline-stage.completed .pipeline-card {
    border-color: #22c55e;
    background: #f0fdf4;
}
.pipeline-stage.in_progress .pipeline-card {
    border-color: var(--primary);
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}
.pipeline-stage.rejected .pipeline-card {
    border-color: #ef4444;
    background: #fef2f2;
}
.pipeline-stage.active-stage .pipeline-card {
    transform: scale(1.06);
    box-shadow: 0 4px 16px rgba(99,102,241,.22);
}
.pipeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .5rem;
}
.pipeline-num {
    background: var(--accent);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pipeline-status {
    font-size: 1.15rem;
}
.pipeline-icon { font-size: 1.8rem; }
.pipeline-name {
    font-weight: 700;
    font-size: .88rem;
    margin-top: .35rem;
}
.pipeline-tool {
    font-size: .72rem;
    color: var(--text-muted);
}
.pipeline-status-label {
    margin-top: .5rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .15rem .65rem;
    border-radius: 100px;
    display: inline-block;
}
.pipeline-stage.completed .pipeline-status-label {
    background: #dcfce7;
    color: #166534;
}
.pipeline-stage.in_progress .pipeline-status-label {
    background: #e0e7ff;
    color: #3730a3;
}
.pipeline-stage.pending .pipeline-status-label {
    background: #f1f5f9;
    color: #64748b;
}
.pipeline-stage.rejected .pipeline-status-label {
    background: #fee2e2;
    color: #991b1b;
}

.pipeline-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 .25rem;
    align-self: center;
}
.connector-line {
    width: 36px;
    height: 3px;
    background: var(--border-color);
    border-radius: 100px;
}
.connector-line.filled {
    background: #22c55e;
}
.connector-arrow {
    color: var(--text-muted);
    font-size: .75rem;
    margin-top: -.25rem;
}

/* ==================== 阶段详情卡片 ==================== */
.stage-detail-card {
    border-radius: var(--radius);
    overflow: hidden;
}
.stage-detail-card.completed {
    border-left: 4px solid #22c55e !important;
}
.stage-detail-card.in_progress {
    border-left: 4px solid var(--primary) !important;
}
.stage-detail-card.rejected {
    border-left: 4px solid #ef4444 !important;
}
.stage-badge.pending { background: #f1f5f9; color: #64748b; }
.stage-badge.in-progress { background: #e0e7ff; color: #3730a3; }
.stage-badge.completed { background: #dcfce7; color: #166534; }
.stage-badge.rejected { background: #fee2e2; color: #991b1b; }

.io-box {
    padding: .65rem .85rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    height: 100%;
}
.io-box.input { border-left: 3px solid #60a5fa; }
.io-box.output { border-left: 3px solid #34d399; }
.io-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .25rem;
}
.io-value {
    font-size: .82rem;
    font-weight: 500;
}

/* ==================== 产物列表 ==================== */
.artifact-item {
    background: #f8fafc;
    padding: .55rem .75rem;
    border-radius: 10px;
    margin-bottom: .5rem;
    border: 1px solid var(--border-color);
    transition: background .15s;
}
.artifact-item:hover {
    background: #eef2ff;
}

/* ==================== 新建项目 - 阶段预览 ==================== */
.stage-preview-list {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}
.stage-preview-item {
    display: flex;
    align-items: center;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}
.stage-preview-item:last-child { border-bottom: none; }
.stage-num-badge {
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: .75rem;
    flex-shrink: 0;
}

/* ==================== 表格 ==================== */
.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: .82rem;
    border-bottom-width: 1px;
}

/* ==================== 卡片通用 ==================== */
.card {
    border-radius: var(--radius);
}
.card-header {
    padding-bottom: .5rem !important;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .pipeline-card {
        min-width: 110px;
        padding: .75rem;
    }
    .pipeline-icon { font-size: 1.4rem; }
    .pipeline-name { font-size: .8rem; }
    .workflow-node-preview {
        min-width: 90px;
        padding: .5rem .75rem;
    }
}

/* ==================== 我提需求 ==================== */
.requirement-card {
    border-top: 4px solid var(--primary) !important;
}
.requirement-icon {
    font-size: 1.35rem;
}

/* Tab 样式 */
.nav-tabs .nav-link {
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-muted);
    border: none;
    padding: .55rem 1.15rem;
    border-radius: 8px 8px 0 0;
}
.nav-tabs .nav-link.active {
    color: var(--primary);
    background: #eef2ff;
    font-weight: 600;
}

/* 上传拖拽区 */
.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all .25s;
    background: #f8fafc;
}
.upload-dropzone:hover,
.upload-dropzone.drag-over {
    border-color: var(--primary);
    background: #eef2ff;
}
.upload-dropzone input[type="file"] {
    cursor: pointer;
}

/* ==================== 产物类型选择器 ==================== */
.type-selector {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}
.type-option {
    margin: 0 !important;
    flex: 1;
    min-width: 160px;
}
.type-option .form-check-label {
    display: block;
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: .85rem 1rem;
    cursor: pointer;
    transition: all .2s;
    width: 100%;
}
.type-option .form-check-input:checked + .form-check-label {
    border-color: var(--primary);
    background: #eef2ff;
}
.type-option .type-icon {
    font-size: 1.35rem;
    display: block;
    margin-bottom: .25rem;
}

/* 速查卡 */
.quick-ref-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: .85rem 1rem;
    height: 100%;
}
.quick-ref-box h6 {
    font-weight: 700;
    margin-bottom: .5rem;
    font-size: .88rem;
}
.quick-ref-box ul {
    padding-left: 1.15rem;
}
.quick-ref-box li {
    margin-bottom: .3rem;
    line-height: 1.55;
}
.quick-ref-box pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: .75rem;
    border-radius: 8px;
    overflow-x: auto;
    line-height: 1.6;
}

/* ==================== 各阶段提示词 ==================== */
.prompt-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    height: 100%;
}
.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1rem;
    background: #eef2ff;
    border-bottom: 1px solid var(--border-color);
}
.prompt-stage-num {
    background: var(--primary);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: .75rem;
    flex-shrink: 0;
}
.prompt-content {
    padding: 1rem;
    font-size: .82rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow-y: auto;
    color: var(--text-main);
}

/* 标准化需求文档预览 */
.standard-doc-preview {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: .88rem;
    line-height: 1.8;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.standard-doc-preview h1,
.standard-doc-preview h2,
.standard-doc-preview h3 {
    margin-top: 1rem;
    margin-bottom: .5rem;
}
.standard-doc-preview code {
    background: #e2e8f0;
    padding: .15rem .45rem;
    border-radius: 4px;
    font-size: .82em;
}

/* 需求列表 */
.requirement-item {
    background: #f8fafc;
    padding: .65rem .85rem;
    border-radius: 10px;
    margin-bottom: .5rem;
    border: 1px solid var(--border-color);
}
.req-badge {
    font-size: .72rem;
    padding: .22rem .65rem;
    border-radius: 100px;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}
.badge-manual { background: #e0e7ff; color: #3730a3; }
.badge-upload { background: #fef3c7; color: #92400e; }
.req-preview {
    font-size: .82rem;
    color: var(--text-main);
    line-height: 1.55;
}

/* 需求全文 */
.requirement-full-content {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    font-size: .88rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 60vh;
    overflow-y: auto;
    margin: 0;
    font-family: inherit;
}

/* ==================== 上线检查清单 ==================== */
.checklist-group {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: .85rem 1rem;
    height: 100%;
}
.checklist-group h6 {
    font-weight: 700;
    margin-bottom: .6rem;
    font-size: .88rem;
    padding-bottom: .4rem;
    border-bottom: 1px dashed var(--border-color);
}
.launch-check {
    display: block;
    font-size: .83rem;
    line-height: 1.7;
    cursor: pointer;
    padding: .15rem 0;
    color: var(--text-main);
    transition: color .15s;
}
.launch-check:hover {
    color: var(--primary);
}
.launch-check input[type="checkbox"] {
    margin-right: .5rem;
    cursor: pointer;
}
.launch-check input[type="checkbox"]:checked + * {
    /* placeholder */
}
.launch-check:has(input:checked) {
    color: #16a34a;
    text-decoration: line-through;
    text-decoration-color: #86efac;
}

/* ==================== 插件基础包规范 ==================== */
.plugin-tree {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: .75rem 1rem;
    font-family: "Consolas", "Monaco", monospace;
}
.tree-item {
    padding: .25rem 0;
    font-size: .82rem;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
}
.tree-file {
    font-weight: 600;
    color: var(--primary-dark);
    min-width: 160px;
}
.tree-desc {
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
    flex: 1;
}

/* ==================== 插件行为约束 ==================== */
.constraint-item {
    display: flex;
    align-items: flex-start;
    padding: .2rem 0;
    line-height: 1.6;
}
.constraint-item i {
    margin-right: .25rem;
    margin-top: .15rem;
    flex-shrink: 0;
}
.constraint-item span {
    color: var(--text-main);
}

/* ==================== 流程模式选择器 ==================== */
.type-option {
    cursor: pointer;
}
.type-option .form-check-input:checked + .form-check-label {
    /* placeholder */
}
.type-option:has(input:checked) .form-check-label {
    color: var(--primary);
}

/* ==================== 手机版（移动端适配） ==================== */
/* 底部 App 式导航：桌面隐藏，lg 以下显示 */
.mobile-tabbar { display: none; }

@media (max-width: 991.98px) {
    /* 主内容与页脚为底部导航留出空间 */
    .app-main { padding-bottom: 1rem; }
    .app-footer { margin-bottom: 76px; }

    .mobile-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        background: rgba(255, 255, 255, .97);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .mobile-tabbar a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: .55rem 0 .4rem;
        color: var(--text-muted);
        text-decoration: none;
        font-size: .7rem;
        line-height: 1;
    }
    .mobile-tabbar a i { font-size: 1.3rem; }
    .mobile-tabbar a.active { color: var(--primary); font-weight: 700; }
    .mobile-tabbar a:active { background: #eef2ff; }
}

@media (max-width: 768px) {
    /* 顶部导航紧凑 */
    .brand-icon { font-size: 1.5rem; }
    .app-navbar .navbar-brand small { display: none; }

    h3 { font-size: 1.3rem; }
    h5 { font-size: 1.05rem; }
    .lead { font-size: 1rem; }

    .card-body { padding: .9rem; }
    .card-header { padding-left: .9rem !important; padding-right: .9rem !important; }

    /* 统计卡片更紧凑 */
    .stat-icon { width: 44px; height: 44px; border-radius: 12px; font-size: 1.25rem; }
    .stat-number { font-size: 1.35rem; }
    .stat-label { font-size: .75rem; }

    /* 工作流节点：窄屏换行更整齐 */
    .workflow-node-preview { min-width: 84px; padding: .55rem .6rem; }
    .workflow-node-preview .node-icon { font-size: 1.25rem; }
    .workflow-node-preview .node-name { font-size: .74rem; }
    .workflow-node-preview .node-tool { font-size: .66rem; }

    /* 长内容区降低最大高度，避免一屏塞满 */
    .prompt-content { max-height: 220px; }
    .standard-doc-preview { max-height: 55vh; padding: 1rem; }
    .requirement-full-content { max-height: 55vh; padding: 1rem; }

    /* 输入框保持 16px，避免 iOS 聚焦自动放大 */
    input.form-control,
    textarea.form-control,
    select.form-select { font-size: 16px; }

    /* 表格横向滑动更顺滑 */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* 按钮触摸目标加大 */
    .btn { padding-top: .45rem; padding-bottom: .45rem; }
    .btn-sm { padding-top: .3rem; padding-bottom: .3rem; }

    /* 项目卡底部按钮换行不挤压 */
    .project-card .card-footer { flex-wrap: wrap; gap: .5rem; }

    /* 项目详情头部操作按钮在手机上占满一行 */
    .project-actions { width: 100%; }
    .project-actions .btn { flex: 1; }

    /* 弹窗留白收窄 */
    .modal-dialog { margin: .6rem; }

    /* 文件树说明：小屏改为上下排列 */
    .tree-item { flex-direction: column; }
    .tree-file { min-width: 0; width: 100%; }
    .tree-desc { width: 100%; }

    /* 代码块避免撑破屏幕 */
    pre { white-space: pre; }
}

@media (max-width: 400px) {
    /* 极窄屏：隐藏箭头，节点两列排布 */
    .workflow-arrow { display: none; }
    .workflow-node-preview { flex: 1 1 46%; min-width: 0; }
    .stat-label { font-size: .7rem; }
}

/* ==================== PWA 安装到桌面 ==================== */
.pwa-install-bar {
    position: fixed;
    left: .75rem;
    right: .75rem;
    bottom: 76px;
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 8px 24px rgba(79, 70, 229, .35);
    font-size: .85rem;
}
.pwa-install-bar[hidden] { display: none !important; }
.pwa-install-text { line-height: 1.3; }

@media (min-width: 992px) {
    .pwa-install-bar { display: none !important; }
}


