* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1900px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.header h1 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 300;
}

.header p {
    margin: 0;
    opacity: 0.9;
    font-size: 14px;
}

.input-section {
    padding: 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.input-controls {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 15px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #2c3e50;
}

#textInput {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#textInput:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.parse-button {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.parse-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.tree-section {
    padding: 25px;
    background: white;
}

.tree-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.tree-panel {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.tree-panel h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tree-panel h3:before {
    content: '🌳';
    font-size: 20px;
}

.tree-view {
    height: 500px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    position: relative;
}

.tree-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    gap: 5px;
}

.zoom-btn {
    background: rgba(52, 152, 219, 0.9);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.zoom-btn:hover {
    background: rgba(41, 128, 185, 0.9);
    transform: scale(1.1);
}

.table-section {
    padding: 25px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.table-section h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
}

.table-controls {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    color: #2c3e50;
}

#partNoFilter {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
    transition: border-color 0.3s ease;
}

#partNoFilter:focus {
    outline: none;
    border-color: #3498db;
}

.clear-filter-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s ease;
}

.clear-filter-btn:hover {
    background: #c0392b;
}

.table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
}

table.dataTable {
    width: 100% !important;
    font-size: 12px;
    border-collapse: collapse;
}

table.dataTable thead th {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border: none;
}

table.dataTable tbody td {
    padding: 10px 8px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}

table.dataTable tbody tr:hover {
    background: #e8f4f8;
}

.vsm-row {
    background: linear-gradient(90deg, #e8f6f3 0%, #d5f4e6 100%) !important;
    font-style: italic;
}

.vsm-row:hover {
    background: linear-gradient(90deg, #d1f2eb 0%, #c3e9d0 100%) !important;
}

/* 新的表格功能樣式 */
.expand-all-btn, .collapse-all-btn {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
    transition: background 0.3s ease;
}

.expand-all-btn:hover, .collapse-all-btn:hover {
    background: #138496;
}

.action-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.toggle-btn, .vsm-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    background: #218838;
}

.vsm-btn {
    background: #007bff;
    margin-left: 5px;
}

.vsm-btn:hover {
    background: #0056b3;
}

.vsm-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.hierarchical-table .child-row {
    display: none;
}

.hierarchical-table .child-row.show {
    display: table-row;
}

.bom-level-0 { padding-left: 0px; }
.bom-level-1 { padding-left: 20px; }
.bom-level-2 { padding-left: 40px; }
.bom-level-3 { padding-left: 60px; }
.bom-level-4 { padding-left: 80px; }

.vsm-subtable {
    margin: 10px 0;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.vsm-subtable table {
    width: 100%;
    font-size: 11px;
    margin: 0;
}

.vsm-subtable thead th {
    background: #f8f9fa;
    color: #495057;
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.vsm-subtable tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid #f1f3f4;
}

.vsm-subtable tbody tr:hover {
    background: #f8f9fa;
}

/* BOM節點類型顏色 */
.node-make {
    fill: #e74c3c;
    stroke: #c0392b;
}

.node-buy {
    fill: #95a5a6;
    stroke: #7f8c8d;
}

.node-default {
    fill: #3498db;
    stroke: #2980b9;
}

.node-non-control {
    fill: #95a5a6;
    stroke: #7f8c8d;
}

.node-takt {
    fill: #e74c3c;
    stroke: #c0392b;
}

.node {
    cursor: pointer;
    stroke-width: 2px;
    transition: all 0.3s ease;
}

.node:hover {
    stroke-width: 3px;
    filter: brightness(1.2);
}

.node-rect {
    rx: 5;
    ry: 5;
}

.node-text {
    font-size: 10px;
    fill: #2c3e50;
    pointer-events: none;
    font-weight: normal;
}

.node-text-name {
    font-size: 9px;
    fill: #7f8c8d;
    pointer-events: none;
    font-weight: normal;
}

.link {
    fill: none;
    stroke: #bdc3c7;
    stroke-width: 2px;
    transition: stroke-width 0.3s ease;
}

.tooltip {
    position: absolute;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 12px;
    pointer-events: none;
    z-index: 2000;
    max-width: 350px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
}

.error {
    color: #e74c3c;
    background: linear-gradient(135deg, #fdeded 0%, #f8d7da 100%);
    border: 2px solid #e74c3c;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: 500;
}

.success {
    color: #27ae60;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #27ae60;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: 500;
}

.level-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.level-0 { background: #e74c3c; }
.level-1 { background: #f39c12; }
.level-2 { background: #3498db; }
.level-3 { background: #2ecc71; }
.level-4 { background: #9b59b6; }

/* Modal 樣式 */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #e74c3c;
}

.modal-body {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.copy-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 15px;
    transition: background 0.3s ease;
}

.copy-btn:hover {
    background: #218838;
}

.dataTables_wrapper .dataTables_filter input {
    margin-left: 0.5em;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_length select {
    padding: 5px 10px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 8px 12px;
    margin: 0 2px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #3498db;
    color: white !important;
    border-color: #3498db;
}

/* Bootstrap Table specific styling */
.bootstrap-table .btn {
    font-size: 11px;
    padding: 2px 6px;
    margin: 1px;
    border-radius: 3px;
}

.bootstrap-table .btn-outline-primary {
    color: #007bff;
    border-color: #007bff;
}

.bootstrap-table .btn-outline-primary:hover {
    background-color: #007bff;
    color: white;
}

.bootstrap-table .btn-outline-success {
    color: #28a745;
    border-color: #28a745;
}

.bootstrap-table .btn-outline-success:hover {
    background-color: #28a745;
    color: white;
}

.bootstrap-table .expand-icon {
    font-weight: bold;
    font-size: 12px;
}

.bootstrap-table .me-1 {
    margin-right: 0.25rem;
}

/* Bootstrap table treegrid styling */
.bootstrap-table .treegrid-indent {
    width: 16px;
    height: 16px;
    display: inline-block;
    position: relative;
}

.bootstrap-table .treegrid-expander {
    cursor: pointer;
    font-weight: bold;
    color: #007bff;
}

@media (max-width: 768px) {
    .input-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .tree-view {
        height: 400px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    .bootstrap-table .btn {
        font-size: 10px;
        padding: 1px 4px;
    }
}
