/* ============================================
   搭建图纸样式
   ============================================ */

.layout-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    height: calc(100vh - 100px);
    overflow: hidden;
}

/* 左侧工具区 */
.layout-toolbar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.layout-toolbar .card {
    flex: 1;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: none;
}

.tool-group {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
}

.tool-group:last-child {
    border-bottom: none;
}

.tool-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.tool-group input,
.tool-group select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
}

.tool-group input:focus,
.tool-group select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tool-buttons .btn {
    text-align: left;
    font-size: 12px;
    padding: 8px 12px;
}

/* 右侧画布区 */
.layout-canvas-wrapper {
    background: #f5f7fa;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.layout-canvas-wrapper .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 15px;
}

#layoutCanvas {
    flex: 1;
    width: 100%;
    border: 1px solid #ddd;
    background: #fafafa;
    cursor: crosshair;
    border-radius: 4px;
}

#layoutCanvas:hover {
    border-color: var(--accent-color);
}

/* 元素控制 */
#selected-info {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
}

#element-controls {
    display: none;
    gap: 8px;
}

#element-controls.show {
    display: flex;
}

/* 图例 */
.legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

.legend-color.stage { background: #e74c3c; }
.legend-color.truss { background: #95a5a6; }
.legend-color.light { background: #f39c12; }
.legend-color.speaker { background: #9b59b6; }
.legend-color.table { background: #27ae60; }
.legend-color.text { background: #3498db; }

/* 数据状态 */
.data-status {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 12px;
}

.data-status.has-data {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.data-status.no-data {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

/* 打印样式 */
@media print {
    header,
    .layout-toolbar,
    .toolbar,
    .inventory-panel,
    .params-panel,
    .draw-toolbar {
        display: none !important;
    }
    
    .layout-container {
        display: block;
        height: auto;
        overflow: visible;
    }
    
    .layout-layout {
        display: block;
        height: auto;
        overflow: visible;
    }
    
    .layout-canvas-wrapper {
        padding: 0;
        background: #fff;
        overflow: visible;
    }
    
    #layoutCanvas {
        border: none;
        box-shadow: none;
    }
    
    .draw-area {
        background: #fff;
    }
    
    .draw-content {
        padding: 0;
        overflow: visible;
    }
    
    .draw-page {
        box-shadow: none;
        width: 100%;
        height: auto;
        page-break-after: always;
    }
    
    .draw-page.active {
        display: block;
    }
    
    body {
        background: #fff;
    }
}

/* 响应式 */
@media (max-width: 1024px) {
    .layout-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    
    .layout-toolbar {
        overflow: visible;
    }
    
    .tool-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   库存管理界面样式 (原 layout.html 内联样式)
   ============================================ */

* { box-sizing: border-box; }

.layout-container {
    display: flex;
    height: calc(100vh - 50px);
    overflow: hidden;
}

/* 左侧库存区 */
.inventory-panel {
    width: 340px;
    min-width: 340px;
    background: #f8f8f8;
    border-right: 1px solid #d0d0d0;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 10px 12px;
    background: #fff;
    border-bottom: 1px solid #d0d0d0;
}

.panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.inventory-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* 桁架类型卡片 */
.truss-card {
    background: #fff;
    border: 1px solid #d0d0d0;
    margin-bottom: 8px;
}

.truss-header {
    background: #f0f0f0;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #d0d0d0;
}

.truss-header span {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.truss-actions {
    display: flex;
    gap: 6px;
}

.truss-actions button {
    padding: 3px 10px;
    border: 1px solid #bbb;
    background: #fff;
    font-size: 11px;
    cursor: pointer;
    color: #555;
}

.truss-actions button:hover {
    background: #f0f0f0;
}

/* 尺寸网格 - 3列 */
.size-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
}

.size-item {
    padding: 5px 4px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
}

.size-item:hover {
    background: #f0f0f0;
}

.size-item.selected {
    background: #e3f2fd;
    border-color: #1976d2;
}

/* 添加行 */
.add-row {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: #f5f5f5;
    border-top: 1px solid #d0d0d0;
    align-items: center;
}

.add-row input[type="text"],
.add-row input[type="number"] {
    padding: 4px 6px;
    border: 1px solid #ccc;
    font-size: 11px;
    height: 26px;
}

.add-row input[type="text"] {
    width: 80px;
}

.add-row input[type="number"] {
    width: 50px;
}

.add-row select {
    padding: 4px 4px;
    border: 1px solid #ccc;
    font-size: 11px;
    height: 26px;
    width: 55px;
    background: #fff;
}

.add-row button {
    padding: 4px 8px;
    border: 1px solid #4caf50;
    background: #4caf50;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    height: 26px;
}

.add-row button.delete {
    border-color: #f44336;
    background: #f44336;
}

.add-row button.delete:disabled {
    border-color: #ccc;
    background: #ccc;
    cursor: not-allowed;
}

/* 公共设置 - 紧凑布局 */
.global-section {
    background: #fff;
    border: 1px solid #d0d0d0;
    margin-top: 6px;
}

.global-header {
    background: #e8e8e8;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #d0d0d0;
}

.global-body {
    padding: 8px;
}

/* 基础行样式 */
.setting-row {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    min-height: 26px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

/* 标签统一宽度 */
.setting-row > label:first-child {
    width: 65px;
    font-size: 11px;
    color: #444;
    flex-shrink: 0;
    font-weight: 500;
}

/* 下拉控件 - 紧凑 */
.setting-row select {
    width: 32%;
    flex: none;
    padding: 3px 5px;
    border: 1px solid #bbb;
    border-radius: 3px;
    font-size: 11px;
    height: 24px;
    line-height: 1;
}

/* 公式输入框 - 紧凑 */
.setting-row .formula-input {
    width: 32%;
    flex: none;
    padding: 3px 5px;
    border: 1px solid #fa8c16;
    border-radius: 3px;
    font-size: 11px;
    margin-left: 4px;
    background: #fffbe6;
    color: #d46b08;
    height: 24px;
}

.setting-row .formula-input:focus {
    border-color: #fa8c16;
    box-shadow: 0 0 0 2px rgba(250, 140, 22, 0.2);
    outline: none;
}

.setting-row .formula-input::placeholder {
    color: #aaa;
    font-size: 10px;
}

.setting-row input:not(.formula-input):not([type="checkbox"]):not([type="radio"]) {
    flex: 1;
    padding: 3px 5px;
    border: 1px solid #bbb;
    border-radius: 3px;
    font-size: 11px;
    height: 24px;
}

/* 数量输入框宽度减半 */
.setting-row input[type="number"]#block-count,
.setting-row input[type="number"]#bucket-count {
    width: 32%;
    flex: none;
}

/* 垫底桁架下拉框与上面同宽 */
.setting-row select#bucket-truss-length {
    width: 32%;
}

/* 对齐行 - 配重组 */
.setting-row.align-row {
    display: flex;
    align-items: center;
}

.setting-row.align-row > label:first-child {
    width: 65px;
    font-size: 11px;
}

.setting-row.align-row input,
.setting-row.align-row select {
    width: 32%;
    flex: none;
}

/* 复选框行 - 紧凑 */
.setting-row.checkbox-row {
    margin-bottom: 4px;
}

.setting-row.checkbox-row label {
    width: auto;
    font-weight: 500;
}

/* 子设置项缩进 */
.setting-row.sub-setting {
    padding-left: 18px;
    margin-bottom: 4px;
}

.setting-row.sub-setting > label:first-child {
    width: 62px;
    color: #666;
    font-size: 10px;
}

/* 单选按钮组 */
.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #444;
    cursor: pointer;
    white-space: nowrap;
}

.radio-label input[type="radio"] {
    width: auto;
    flex: none;
    margin: 0;
}

/* 复选框标签 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #333;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    flex: none;
}

.checkbox-label span {
    user-select: none;
}

/* 分隔线 */
.setting-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 6px 0;
}

/* 配重调整按钮 */
.weight-adjust-btns {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 6px;
}

.weight-adjust-btns .adj-btn {
    width: 22px;
    height: 20px;
    border: 1px solid #bbb;
    border-radius: 3px;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.weight-adjust-btns .adj-btn:hover {
    background: #e0e0e0;
    border-color: #999;
}

.weight-adjust-btns .adj-val {
    font-size: 11px;
    font-weight: bold;
    color: #1565c0;
    min-width: 16px;
    text-align: center;
}

/* 输入组 */
.input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.input-hint {
    font-size: 10px;
    color: #888;
    white-space: nowrap;
}

/* 子设置项默认样式 */
.leg-setting-sub,
.brace-setting-sub,
.light-settings-sub,
.weight-settings-sub {
    transition: opacity 0.2s;
}

/* 子设置项隐藏时的样式 */
.setting-row[style*="display: none"],
.light-settings-sub[style*="display: none"],
.weight-settings-sub[style*="display: none"] {
    display: none !important;
}

.radio-group {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}

.radio-label input[type="radio"] {
    width: auto;
    flex: none;
    margin: 0;
}

/* 复选框标签样式 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    flex: none;
}

.checkbox-label span {
    user-select: none;
}

.weight-adjust-btns {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.weight-adjust-btns .adj-btn {
    width: 24px;
    height: 22px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.weight-adjust-btns .adj-btn:hover {
    background: #e0e0e0;
    border-color: #999;
}

.weight-adjust-btns .adj-btn:active {
    background: #d0d0d0;
}

.weight-adjust-btns .adj-val {
    font-size: 12px;
    font-weight: bold;
    color: #1565c0;
    min-width: 18px;
    text-align: center;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.input-hint {
    font-size: 10px;
    color: #888;
    white-space: nowrap;
}

/* 添加类型按钮 */
.add-type-btn {
    padding: 10px;
    text-align: center;
    border-top: 1px solid #d0d0d0;
    background: #fff;
}

.add-type-btn button {
    padding: 6px 20px;
    border: 1px solid #666;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
}

.add-type-btn button:hover {
    background: #f0f0f0;
}

/* 中间绘图区 */
.draw-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e8e8e8;
    min-width: 0;
}

.draw-toolbar {
    height: 36px;
    background: #fff;
    border-bottom: 1px solid #d0d0d0;
    display: flex;
    align-items: center;
    padding: 0 15px;
}

.toolbar-info {
    font-size: 12px;
    color: #666;
}

.draw-content {
    flex: 1;
    overflow: auto;
    padding: 30px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* 横版A4 */
.draw-page {
    width: 297mm;
    height: 210mm;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: none;
    position: relative;
}

.draw-page.active {
    display: block;
}

.page-header {
    height: 40px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: relative;
    gap: 10px;
}

.page-title-size {
    font-size: 14px;
    font-weight: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* 图纸内页码标签 */
.page-tabs {
    position: absolute;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    height: 40px;
}

.page-brand {
    font-size: 13px;
    white-space: nowrap;
    color: #3498db;
    font-weight: bold;
    line-height: 40px;
    margin-left: auto;
    flex-shrink: 0;
}

.page-tab {
    width: 36px;
    height: 32px;
    border: 1px solid #333;
    border-bottom: none;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: -1px;
}

.page-tab:first-child {
    margin-left: 0;
}

.page-tab.active {
    background: #333;
    color: #fff;
    height: 36px;
}

.page-body {
    position: absolute;
    top: 36px;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 15px;
    overflow: auto;
}

.layout-canvas {
    width: 100%;
    height: 100%;
    background: #fafafa;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 80px;
    color: #999;
}

/* ============================================
   参数显示样式
   ============================================ */
.params-display {
    max-width: 900px;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.5;
}

.params-display h4 {
    margin: 25px 0 12px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.params-display h4:first-child {
    margin-top: 0;
}

.params-display table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: #f9f9f9;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.params-display table tr:nth-child(even) {
    background: #f2f2f2;
}

.params-display table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e8e8e8;
}

.params-display table td:first-child {
    font-weight: 500;
    color: #555;
    width: 180px;
    border-right: 1px solid #e8e8e8;
}

.params-display table td:last-child {
    color: #222;
    font-family: 'Courier New', monospace;
}

/* ============================================
   右侧参数面板样式
   ============================================ */
.params-panel {
    width: 320px;
    min-width: 320px;
    background: #f8f8f8;
    border-left: 1px solid #d0d0d0;
    display: flex;
    flex-direction: column;
}

.params-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* 右侧面板内的参数显示 */
.params-list .params-section {
    background: #fff;
    border: 1px solid #d0d0d0;
    margin-bottom: 8px;
}

.params-list .params-section-header {
    background: #f0f0f0;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #d0d0d0;
}

.params-list .params-section-body {
    padding: 6px;
}

.params-list .params-section table {
    width: 100%;
    border-collapse: collapse;
}

.params-list .params-section table td {
    padding: 6px 8px;
    font-size: 11px;
    border-bottom: 1px solid #eee;
}

.params-list .params-section table td:first-child {
    font-weight: 500;
    color: #555;
    width: 90px;
    border-right: 1px solid #eee;
}

.params-list .params-section table td:last-child {
    color: #222;
    font-family: 'Courier New', monospace;
}

.params-list .params-section table tr:nth-child(even) {
    background: #f9f9f9;
}

/* 桁架使用量表格 */
.params-list .usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: #fff;
    border: 1px solid #ddd;
}

.params-list .usage-table th {
    background: #f5f5f5;
    padding: 6px 4px;
    font-weight: 600;
    border-bottom: 1px solid #ddd;
    text-align: center;
}

.params-list .usage-table td {
    padding: 5px 4px;
    border-bottom: 1px solid #eee;
}

.params-list .usage-table td:first-child {
    font-weight: 500;
}

.params-list .usage-table .total-row {
    background: #f8f9fa;
    font-weight: bold;
}

/* 页面标签（右侧面板顶部） */
.params-page-info {
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #d0d0d0;
    margin-bottom: 8px;
    font-size: 12px;
    color: #333;
}

.params-page-info .page-name {
    font-weight: 600;
    font-size: 14px;
}

.params-page-info .page-size {
    color: #666;
    font-size: 11px;
}