/* =============================================================================
   改进的结果展示区域样式 - results.css
   解决重叠问题，改善响应式体验
   ============================================================================= */

/* 🎯 基础结果容器样式 */
.results-container {
    margin-top: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.results-header h3 {
    font-size: 1.5rem;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 🎯 改进的面板样式 */
.result-panel {
    background: white;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.panel-header {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease;
}

.panel-header:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.panel-header h4 {
    margin: 0;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.toggle-icon {
    transition: transform 0.3s ease;
    color: #6b7280;
}

.collapsible-content {
    padding: 1.5rem;
    display: none;
    border-top: 1px solid #f3f4f6;
}

/* 🎯 新增：关键指标卡片 */
.key-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.metric-label {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.metric-value.positive {
    color: #16a34a;
}

.metric-value.negative {
    color: #dc2626;
}

.metric-value.warning {
    color: #f59e0b;
}

/* 🎯 改进的分配显示容器 */
.allocation-display {
    padding: 1rem;
}

.chart-section {
    margin-bottom: 2rem;
}

.section-subtitle {
    margin-bottom: 1rem;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.pie-chart-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pie-chart-placeholder {
    height: 200px;
    background: #f9fafb;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-icon {
    text-align: center;
    color: #6b7280;
}

.chart-icon i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.chart-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-label {
    flex: 1;
    font-weight: 500;
    color: #374151;
}

.legend-value {
    font-weight: 600;
    color: #1e293b;
}

/* 🎯 改进的表格容器 */
.allocation-table {
    margin-bottom: 2rem;
}

.table-container {
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

/* 桌面版表格 */
.desktop-table {
    display: block;
    overflow-x: auto;
    background: white;
}

.allocation-data-table {
    width: 100%;
    min-width: 800px; /* 确保表格有足够宽度 */
    border-collapse: collapse;
    font-size: 0.9rem;
}

.allocation-data-table th {
    background: #f8fafc;
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.allocation-data-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #6b7280;
    vertical-align: top;
}

.allocation-data-table tbody tr:hover {
    background: #f9fafb;
}

.allocation-data-table tbody tr:last-child td {
    border-bottom: none;
}

/* 表格列样式 */
.jurisdiction-name {
    font-weight: 600;
    color: #1e293b;
    min-width: 120px;
}

.percentage {
    text-align: right;
    font-weight: 600;
    color: #3b82f6;
}

.amount {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.regular-tax, .topup-tax, .total-tax {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.effective-rate {
    text-align: right;
    font-weight: 600;
}

.topup-breakdown {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
    line-height: 1.2;
}

/* 🎯 移动端卡片布局 */
.mobile-cards {
    display: none;
    gap: 1rem;
}

.jurisdiction-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.card-header {
    background: #f8fafc;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.card-header h6 {
    margin: 0;
    font-weight: 600;
    color: #1e293b;
}

.allocation-badge {
    background: #3b82f6;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}

.card-row:last-child {
    margin-bottom: 0;
    border-bottom: none;
}

.card-row.total {
    background: #f8fafc;
    margin: 0.75rem -1rem 0;
    padding: 0.75rem 1rem;
    border-bottom: none;
    font-weight: 600;
}

.card-row .label {
    color: #64748b;
    font-weight: 500;
}

.card-row .value {
    color: #1e293b;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* 🎯 税负构成分析 */
.tax-breakdown {
    margin-bottom: 2rem;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.breakdown-item {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.breakdown-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.breakdown-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.breakdown-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    margin-right: 1rem;
    font-size: 1.2rem;
}

.breakdown-label {
    font-weight: 600;
    color: #374151;
    flex: 1;
}

.breakdown-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
}

.breakdown-percentage {
    color: #64748b;
    margin-bottom: 1rem;
    font-weight: 500;
}

.breakdown-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.breakdown-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* 🎯 其他组件样式 */
.sensitivity-controls, .scenario-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.sensitivity-controls label, .scenario-controls label {
    font-weight: 600;
    color: #374151;
    min-width: 80px;
}

.sensitivity-controls select, .scenario-controls select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    min-width: 180px;
}

#basic-results-content {
    padding: 1.5rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.result-card {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.result-card h5 {
    margin: 0 0 0.5rem 0;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

.result-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
}

.chart-placeholder {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-style: italic;
    margin: 1rem 0;
}

.empty-state {
    padding: 3rem;
    text-align: center;
    color: #6b7280;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* =============================================================================
   响应式设计 - 解决重叠问题
   ============================================================================= */

@media (max-width: 1200px) {
    .breakdown-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .key-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .results-container {
        padding: 1rem;
        margin-top: 1rem;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .sensitivity-controls, .scenario-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }
    
    .key-metrics {
        grid-template-columns: 1fr;
    }
    
    .breakdown-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-legend {
        grid-template-columns: 1fr;
    }
    
    /* 在平板和手机上隐藏桌面表格，显示卡片 */
    .desktop-table {
        display: none;
    }
    
    .mobile-cards {
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .results-container {
        padding: 0.75rem;
    }
    
    .allocation-display {
        padding: 0.5rem;
    }
    
    .metric-card {
        padding: 1rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
    
    .breakdown-item {
        padding: 1rem;
    }
    
    .breakdown-amount {
        font-size: 1.25rem;
    }
    
    .card-header {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
}

/* 强制在大屏幕上显示桌面表格 */
@media (min-width: 769px) {
    .mobile-cards {
        display: none !important;
    }
    
    .desktop-table {
        display: block !important;
    }
}

/* =============================================================================
   动画效果
   ============================================================================= */

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.metric-card, .breakdown-item, .jurisdiction-card {
    animation: slideIn 0.3s ease-out;
}

.metric-card:hover .metric-value {
    animation: pulse 0.6s ease-in-out;
}

/* =============================================================================
   加载状态样式
   ============================================================================= */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============================================================================
   Pillar 2 工作流程图样式
   ============================================================================= */

.workflow-section {
    margin-bottom: 3rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    border: 1px solid #e2e8f0;
}

.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.section-subtitle {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

.workflow-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
}

.workflow-steps {
    display: grid;
    gap: 1rem;
}

.workflow-step {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.workflow-step:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.workflow-step.step-active {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.15);
}

.step-number {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.step-icon {
    font-size: 2rem;
    color: #3b82f6;
    margin-bottom: 1rem;
}

.step-title {
    font-size: 1.2rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.step-description {
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.step-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.step-details.show {
    display: block;
    opacity: 1;
}

.step-formula {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.decision-flow {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.flow-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.flow-node {
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    min-width: 200px;
    font-weight: 500;
}

.flow-node.decision {
    background: #fef3c7;
    border-color: #f59e0b;
}

.flow-node.action {
    background: #dcfce7;
    border-color: #16a34a;
}

.flow-arrow {
    font-size: 1.2rem;
    color: #3b82f6;
    font-weight: 600;
}

/* =============================================================================
   统计数据展示样式
   ============================================================================= */

.stats-section {
    margin-bottom: 3rem;
    padding: 2rem;
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stats-title {
    font-size: 1.2rem;
    color: #1e293b;
    margin-bottom: 1.5rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: #3b82f6;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
}

.stat-label {
    color: #64748b;
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* 响应式工作流程 */
@media (max-width: 1024px) {
    .workflow-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .decision-flow {
        order: -1;
    }
}