/**
 * 计算模块通用样式
 * 用于所有建筑功能模块（楼梯设计、户型设计等）
 */

/* ==================== 计算过程详情样式 ==================== */

/* 计算过程详情容器：仅对 #processDetailContent 启用多列布局 */
#processDetailContent.detail-panel-content.active {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 16px;
    align-items: flex-start;
    padding: 10px;
}

/* 宽屏时最多3列 */
@media (min-width: 1400px) {
    #processDetailContent.detail-panel-content.active {
        grid-template-columns: repeat(3, 1fr);
    }
}

.calculation-section {
    margin-bottom: 24px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: visible;
    width: 100%;      /* 在grid列中占满列宽 */
}

.calculation-section .section-title {
    font-size: 16px;
    color: #1a1f2e;
    margin: 0;
    padding: 12px 20px;
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

/* 计算项网格 - 在多列布局中使用单列，确保内容完整显示 */
.calculation-items-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
}

/* 确保卡片根据内容自动调整宽度 */
.calculation-item {
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

/* 列表模式样式 */
.calculation-items-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.calculation-items-list .calculation-item {
    padding: 20px;
    background: transparent;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
    margin-bottom: 0;
}

.calculation-items-list .calculation-item:last-child {
    border-bottom: none;
}

.calculation-items-list .calculation-item:hover {
    box-shadow: none;
    background-color: #fcfcfc;
}

.calculation-items-list .calculation-item.highlight {
    background: #fff8e1;
    border: none;
    border-bottom: 1px solid #eee;
    border-left: 4px solid #ffa726;
}

/* 计算项卡片样式 - 动态适应文字内容 */
.calculation-item {
    padding: 12px;
    background: #f9f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
    min-height: auto;
    height: fit-content;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

/* 确保卡片内容能动态适应 */
.calc-label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a1f2e;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.calc-formula {
    font-size: 13px;
    color: #666;
    line-height: 1.8;
    word-wrap: break-word;
    white-space: normal;
}

.calculation-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calculation-item.highlight {
    background: #fff8e1;
    border-color: #ffa726;
}

.calc-result {
    color: #667eea;
    font-weight: 600;
}

/* ==================== 规范依据卡片样式 ==================== */

.regulation-card {
    margin-bottom: 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

/* 规范卡片栅格容器：一行多列，自适应换行 */
.regulation-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    align-items: start;
}

/* 栅格下的规范卡片：由gap控制间距，去掉额外外边距 */
.regulation-cards-grid .regulation-card {
    margin-bottom: 0;
}

.regulation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #E0F2F1;
    cursor: pointer;
    min-height: auto;
}

.regulation-header-static {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #E0F2F1;
    border-bottom: 1px solid rgba(0, 105, 92, 0.1);
}

.regulation-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.regulation-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;     /* 一行显示，不在中间断行 */
}

.regulation-code {
    font-size: 12px;
    color: #667eea;
    background: rgba(102, 126, 234, 0.08);
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid rgba(102, 126, 234, 0.35);
    white-space: nowrap;     /* 一行显示，不在中间断行 */
}

.toggle-icon {
    font-size: 16px;
    color: #00695C;
    transition: transform 0.3s;
    margin-left: 8px;
}

.regulation-content {
    display: none;
    padding: 16px;
    background: #f9f9f9;
}

.regulation-content-static {
    display: block;
    padding: 0;
    background: #f9f9f9;
}

/* ==================== 规范条文样式 ==================== */

.article-item {
    margin-bottom: 12px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.article-header-simple {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #E0F2F1;
    border-bottom: 1px solid rgba(0, 105, 92, 0.1);
}

.regulation-header-unified {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: linear-gradient(135deg, #f5f7fb 0%, #e8f0fe 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.18);
    gap: 16px;
}

.regulation-header-left {
    display: flex;
    flex-wrap: wrap;          /* 名称和规范号在同一行放不下时自动折到下一行 */
    align-items: center;
    gap: 4px 8px;
}

.article-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.regulation-articles-nums {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* 头部左侧中的条例号：固定占据下一整行 */
.regulation-header-left .regulation-articles-nums {
    flex-basis: 100%;
    margin-top: 4px;
}

.regulation-articles-container {
    background: white;
}

.article-num-clickable {
    font-weight: 600;
    color: #667eea;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px dashed rgba(102, 126, 234, 0.4);
    background: rgba(102, 126, 234, 0.02);
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
}

.article-num-clickable:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #5568d3;
}

.article-num-clickable:active {
    transform: scale(0.95);
}

.article-num-clickable.active {
    background: #667eea;
    color: #ffffff;
    border-style: solid;
    border-color: #667eea;
}

.article-num-inline {
    font-weight: 600;
    color: #667eea;
    font-size: 13px;
    margin-right: 8px;
}

.article-content-inner {
    padding: 12px 16px;
    background: white;
}

.article-title {
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.spec-item-icon {
    color: #667eea;
    font-weight: bold;
    margin-right: 8px;
}

.article-item:last-child {
    margin-bottom: 0;
}

.article-header {
    padding: 12px 16px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.article-toggle-icon {
    font-size: 14px;
    color: #667eea;
    transition: transform 0.3s;
}

.article-content {
    display: none;
    padding: 16px;
}

.spec-items {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.spec-items li {
    padding: 8px 14px;
    background: #f9fafc;
    border-left: 3px solid rgba(102, 126, 234, 0.5);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.6;
    transition: all 0.2s;
    box-shadow: none;
}

.spec-items li:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateX(2px);
    background: #ffffff;
}

/* ==================== 规范检查表格样式 ==================== */

.compliance-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.compliance-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    min-width: 360px;
    font-size: 12.5px;
    table-layout: auto;
}

.compliance-table thead {
    background: var(--bg-secondary);
}

.compliance-table th,
.compliance-table td {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    text-align: left;
    word-break: break-word;
}

.compliance-table th {
    font-weight: 600;
}

.compliance-table .pass {
    color: #10b981;
    font-weight: 500;
}

.compliance-table .fail {
    color: #ef4444;
    font-weight: 500;
}

/* ==================== 建议卡片样式 ==================== */

.suggestion-card {
    padding: 14px;
    margin-bottom: 10px;
    border-left: 4px solid;
    border-radius: 6px;
}

.suggestion-card.warning {
    background: #fff8e1;
    border-color: #ffa726;
}

.suggestion-card.success {
    background: #e8f5e9;
    border-color: #66bb6a;
}

.suggestion-card.info {
    background: #e3f2fd;
    border-color: #42a5f5;
}

.suggestion-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}

.suggestion-card.warning .suggestion-title {
    color: #e65100;
}

.suggestion-card.success .suggestion-title {
    color: #2e7d32;
}

.suggestion-card.info .suggestion-title {
    color: #1565c0;
}

.suggestion-content {
    font-size: 13px;
    line-height: 1.6;
}

.suggestion-card.warning .suggestion-content {
    color: #e65100;
}

.suggestion-card.success .suggestion-content {
    color: #2e7d32;
}

.suggestion-card.info .suggestion-content {
    color: #1565c0;
}

/* ==================== 响应式设计 ==================== */

@media (max-width: 768px) {
    .calculation-items-grid {
        grid-template-columns: 1fr;
    }
    
    .spec-items {
        grid-template-columns: 1fr;
    }
    
    /* 窄屏下计算过程详情改为单列，避免卡片过窄 */
    #processDetailContent.detail-panel-content.active {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .spec-items {
        grid-template-columns: 1fr;
    }
}

/* ==================== 打印样式 ==================== */

@media print {
    .calculation-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .regulation-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .article-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
