/**
 * 流式思维链样式
 * 支持新的4阶段结构化显示格式
 */

/* 主容器样式 */
.streaming-thinking-chain-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 阶段容器样式 */
.streaming-stage {
    background: #ffffff;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.streaming-stage.stage-visible {
    opacity: 1;
    transform: translateY(0);
}

.streaming-stage.stage-completed {
    border-left: 4px solid #28a745;
}

/* 阶段头部样式 */
.stage-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
}

.stage-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 阶段完成状态指示器 */
.stage-completion-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 1.2em;
    margin-right: 8px;
}

.stage-completion-indicator i {
    color: #28a745;
    font-size: 1.1em;
    filter: drop-shadow(0 0 2px rgba(40, 167, 69, 0.3));
}

.stage-number {
    font-weight: 700;
    color: #ffd700;
}

.stage-name {
    flex: 1;
}

.stage-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.stage-status.starting {
    background: #fff3cd;
    color: #856404;
}

.stage-status.in_progress {
    background: #d1ecf1;
    color: #0c5460;
}

.stage-status.completed {
    background: #d4edda;
    color: #155724;
}

.stage-status.error {
    background: #f8d7da;
    color: #721c24;
}

/* 阶段内容样式 */
.stage-content {
    padding: 20px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin: 0 0 12px 0;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 4px;
}

/* 任务元数据样式 */
.task-metadata {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-left: 4px solid #007bff;
}

.task-info {
    margin: 0;
    font-size: 14px;
    color: #495057;
    font-family: 'Courier New', monospace;
}

/* 文件检查清单样式 */
.file-check-section {
    margin-bottom: 16px;
}

.file-check-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
    margin-left: 20px; /* 子步骤左边距 */
}

/* 嵌套文件检查项目 */
.file-check-item.nested {
    margin-left: 40px; /* 二级嵌套 */
}

.file-check-item.nested-deep {
    margin-left: 60px; /* 三级嵌套 */
}

.file-check-item:hover {
    background: #e9ecef;
}

.status-icon {
    font-size: 16px;
    min-width: 20px;
}

.file-info {
    flex: 1;
    font-size: 14px;
    color: #495057;
}

/* 系统初始化样式 */
.system-init-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.init-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 1px solid #ffc107;
}

.init-status.completed {
    background: #d4edda;
    color: #155724;
}

.init-icon {
    font-size: 16px;
}

.init-text {
    font-size: 14px;
    font-weight: 500;
}

/* 数据提取样式 */
.extraction-section {
    margin-bottom: 20px;
}

.extraction-item {
    background: #ffffff;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border: 1px solid #e9ecef;
    margin-left: 20px; /* 子步骤左边距 */
}

/* 嵌套数据提取项目 */
.extraction-item.nested {
    margin-left: 40px; /* 二级嵌套 */
}

.extraction-item.nested-deep {
    margin-left: 60px; /* 三级嵌套 */
}

.extraction-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.file-icon {
    font-size: 16px;
}

.file-name {
    font-weight: 500;
    color: #495057;
}

.page-info {
    color: #6c757d;
    font-size: 12px;
}

.arrow {
    color: #007bff;
    font-weight: bold;
}

.character-count {
    color: #28a745;
    font-weight: 500;
    padding: 2px 8px;
    background: #d4edda;
    border-radius: 4px;
    font-size: 12px;
}

.character-count.completed {
    background: #28a745;
    color: white;
}

.extraction-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.action-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.action-icon {
    font-size: 12px;
}

/* 提取完成状态样式 */
.extraction-complete-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.complete-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #d4edda;
    border-radius: 6px;
    color: #155724;
    font-weight: 500;
}

.complete-status.fade-in {
    animation: fadeIn 0.5s ease;
}

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

/* 规则校验样式 */
.rule-validation-section {
    margin-bottom: 16px;
}

.validation-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.validation-category {
    background: #ffffff;
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid #e9ecef;
    margin-left: 20px; /* 子步骤左边距 */
}

/* 嵌套规则校验分类 */
.validation-category.nested {
    margin-left: 40px; /* 二级嵌套 */
}

.validation-category.nested-deep {
    margin-left: 60px; /* 三级嵌套 */
}

.category-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.category-name {
    font-weight: 500;
    color: #495057;
}

.category-progress {
    font-size: 12px;
    color: #6c757d;
    font-family: 'Courier New', monospace;
}

.progress-bar {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #28a745);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-fill.completed {
    background: #28a745;
}

/* 问题摘要样式 */
.audit-summary-section {
    margin-bottom: 16px;
}

.issues-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.issue-item {
    border-radius: 10px;
    padding: 16px;
    border-left: 4px solid;
    background: #ffffff;
    border: 1px solid #e9ecef;
    margin-left: 20px; /* 子步骤左边距 */
}

/* 嵌套问题项目 */
.issue-item.nested {
    margin-left: 40px; /* 二级嵌套 */
}

.issue-item.nested-deep {
    margin-left: 60px; /* 三级嵌套 */
}

.issue-item.critical {
    background: #ffffff;
    border-left-color: #dc3545;
}

.issue-item.warning {
    background: #ffffff;
    border-left-color: #ffc107;
}

.issue-item.notice {
    background: #ffffff;
    border-left-color: #17a2b8;
}

.issue-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.severity-label {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.issue-item.critical .severity-label {
    color: #721c24;
}

.issue-item.warning .severity-label {
    color: #856404;
}

.issue-item.notice .severity-label {
    color: #0c5460;
}

.issue-title {
    font-weight: 500;
    color: #495057;
    flex: 1;
}

.issue-location {
    font-size: 12px;
    color: #6c757d;
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.issue-description {
    color: #495057;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.issue-suggestions {
    font-size: 13px;
    color: #495057;
}

.issue-suggestions ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.issue-suggestions li {
    margin-bottom: 2px;
}

/* 无问题状态样式 */
.no-issues {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    background: #d4edda;
    border-radius: 6px;
    color: #155724;
    font-weight: 500;
}

.success-icon {
    font-size: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .streaming-thinking-chain-container {
        padding: 12px;
        margin: 0 12px;
    }

    .stage-content {
        padding: 16px;
    }

    .extraction-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .extraction-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .issue-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* 任务完成样式 */
.task-completed {
    position: relative;
}

.task-completed::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #28a745, #20c997, #17a2b8);
    border-radius: 2px;
}

.completion-banner {
    border: none !important;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    border-left: 4px solid #28a745 !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.completion-banner .alert-heading {
    color: #155724;
    font-weight: 600;
}

.analysis-summary-final {
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.analysis-summary-final .card-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    border: none;
}

.analysis-summary-final .card-body {
    padding: 2rem;
}

/* 完成状态动画 */
@keyframes completionPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.task-completed .thinking-chain-title i {
    animation: completionPulse 2s ease-in-out infinite;
}

/* 阶段完成状态增强 */
.stage-completed .stage-header {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    /* border-left: 4px solid #28a745; */
}

.stage-completed .stage-number {
    /* background: #28a745; */
    color: #28a745;
}

.stage-completed .stage-name {
    color: #28a745;
}

/* 任务完成响应式调整 */
@media (max-width: 768px) {
    .completion-banner {
        text-align: center;
    }

    .analysis-summary-final .row > div {
        margin-bottom: 1rem;
    }

    /* 移动端子步骤左边距调整 */
    .file-check-item {
        margin-left: 15px; /* 减少移动端左边距 */
    }

    .file-check-item.nested {
        margin-left: 30px;
    }

    .file-check-item.nested-deep {
        margin-left: 45px;
    }

    .extraction-item {
        margin-left: 15px;
    }

    .extraction-item.nested {
        margin-left: 30px;
    }

    .extraction-item.nested-deep {
        margin-left: 45px;
    }

    .validation-category {
        margin-left: 15px;
    }

    .validation-category.nested {
        margin-left: 30px;
    }

    .validation-category.nested-deep {
        margin-left: 45px;
    }

    .issue-item {
        margin-left: 15px;
    }

    .issue-item.nested {
        margin-left: 30px;
    }

    .issue-item.nested-deep {
        margin-left: 45px;
    }
}

@media (max-width: 576px) {
    /* 小屏幕设备进一步减少左边距 */
    .file-check-item {
        margin-left: 10px;
    }

    .file-check-item.nested {
        margin-left: 20px;
    }

    .file-check-item.nested-deep {
        margin-left: 30px;
    }

    .extraction-item {
        margin-left: 10px;
    }

    .extraction-item.nested {
        margin-left: 20px;
    }

    .extraction-item.nested-deep {
        margin-left: 30px;
    }

    .validation-category {
        margin-left: 10px;
    }

    .validation-category.nested {
        margin-left: 20px;
    }

    .validation-category.nested-deep {
        margin-left: 30px;
    }

    .issue-item {
        margin-left: 10px;
    }

    .issue-item.nested {
        margin-left: 20px;
    }

    .issue-item.nested-deep {
        margin-left: 30px;
    }

    /* 小屏幕设备完成状态指示器调整 */
    .stage-completion-indicator {
        font-size: 1em;
        margin-right: 6px;
    }

    .stage-completion-indicator i {
        font-size: 1em;
    }

    .stage-title {
        font-size: 16px;
        gap: 6px;
    }
}

/* 自动滚动相关样式 */
.streaming-stage {
    scroll-margin-top: 20px; /* 滚动时的顶部边距 */
    transition: all 0.3s ease; /* 平滑过渡效果 */
}

/* 阶段高亮效果 */
.streaming-stage.stage-highlighted {
    box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
    transform: scale(1.02);
    border-left: 4px solid #007bff;
}

/* 滚动指示器 - 🚫 已隐藏，简化界面显示 */
.scroll-indicator {
    display: none !important; /* 完全隐藏滚动指示器 */
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 123, 255, 0.1);
    border-radius: 20px;
    padding: 10px 5px;
    backdrop-filter: blur(10px);
    z-index: 1000;
    transition: opacity 0.3s ease;
}

/* 第四阶段流式内容容器 - 🚫 已隐藏，简化界面显示 */
#streaming-stage-content-stage-4 {
    display: none !important; /* 完全隐藏第四阶段容器 */
}

.scroll-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.scroll-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.3);
    margin: 5px 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.scroll-indicator-dot.active {
    background: #007bff;
    transform: scale(1.5);
}

.scroll-indicator-dot.completed {
    background: #28a745;
}

/* 平滑滚动行为 */
html {
    scroll-behavior: smooth;
}

/* 阶段容器滚动优化 */
.streaming-thinking-chain-container {
    scroll-padding-top: 80px; /* 为固定头部留出空间 */
}

/* 阶段标题滚动锚点 */
.stage-header {
    scroll-margin-top: 100px;
    position: relative;
}

/* 滚动到视图时的动画 */
@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.streaming-stage.scroll-target {
    animation: slideInFromTop 0.6s ease-out;
}

/* 移动端滚动优化 */
@media (max-width: 768px) {
    .streaming-stage {
        scroll-margin-top: 10px;
    }

    .stage-header {
        scroll-margin-top: 60px;
    }

    .scroll-indicator {
        right: 10px;
        padding: 8px 3px;
    }

    .scroll-indicator-dot {
        width: 6px;
        height: 6px;
        margin: 3px 0;
    }
}
