/* --- BOM TOOL GENERAL LAYOUT --- */
.bom-tool-wrapper { max-width: 1200px; margin: 2rem auto; padding: 1rem; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.bom-tool-header { text-align: center; margin-bottom: 2.5rem; }
.bom-tool-header h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.bom-tool-subtitle { font-size: 1.1rem; color: #666; }

/* --- PROGRESS BAR --- */
.bom-progress-bar { max-width: 100%; margin-bottom: 2.5rem; }
.bom-progress-bar ul { display: flex; justify-content: space-between; list-style: none; padding: 0; margin: 0; }
.bom-progress-bar li { flex: 1; text-align: center; position: relative; color: #a0aec0; font-weight: bold; font-size: 0.9rem; }
.bom-progress-bar li::before { content: ''; display: block; width: 30px; height: 30px; border-radius: 50%; background-color: #fff; border: 2px solid #e2e8f0; margin: 0 auto 10px auto; transition: all 0.3s; }
.bom-progress-bar li::after { content: ''; position: absolute; width: 100%; height: 2px; background-color: #e2e8f0; top: 14px; left: -50%; z-index: -1; transition: all 0.3s; }
.bom-progress-bar li:first-child::after { content: none; }
.bom-progress-bar li.active::before { background-color: #2563eb; border-color: #2563eb; }
.bom-progress-bar li.active { color: #2c3e50; }
.bom-progress-bar li.completed::before { background-color: #2563eb; border-color: #2563eb; content: '✔'; color: white; line-height: 30px; font-size: 16px; }
.bom-progress-bar li.completed::after { background-color: #2563eb; }

/* --- CARD STYLING --- */
.bom-tool-card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); margin-bottom: 2rem; overflow: hidden; }
.card-header { display: flex; align-items: center; padding: 1rem 1.5rem; background: #f7fafc; border-bottom: 1px solid #e2e8f0; }
.card-header .step-number { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; background-color: #4a5568; color: #fff; border-radius: 50%; font-weight: bold; margin-right: 1rem; }
.card-header h2 { margin: 0; font-size: 1.5rem; }
.card-content { padding: 1.5rem; }

/* --- FILE UPLOAD AREA --- */
.file-upload-area { border: 2px dashed #cbd5e0; border-radius: 8px; padding: 2rem; text-align: center; cursor: pointer; transition: background-color 0.2s, border-color 0.2s; }
.file-upload-area:hover, .file-upload-area.dragover { background-color: #f0f4f8; border-color: #a0aec0; }
.file-upload-area label { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.file-upload-area svg { width: 48px; height: 48px; color: #a0aec0; margin-bottom: 1rem; }
.file-upload-area #file-upload-text { font-weight: 500; color: #4a5568; }
#bom-file-input { display: none; }
#download-template-link { display: block; text-align: center; margin-top: 1rem; color: #4a5568; font-size: 0.9rem; }

/* --- MAPPING TABLE (FIXED LAYOUT) --- */
.table-container { width: 100%; overflow-x: auto; }
#bom-mapping-table { width: 100% !important; border-collapse: collapse !important; font-size: 0.9rem !important; table-layout: fixed !important; }
#bom-mapping-table th, #bom-mapping-table td { border: 1px solid #e2e8f0 !important; padding: 10px !important; text-align: left !important; white-space: normal !important; word-break: break-word !important; vertical-align: top !important; }
/* FIX: The problematic flex properties have been removed from the TH element */
#bom-mapping-table th { background-color: #f7fafc !important; font-weight: bold !important; }
/* FIX: Flex properties are now applied to a child div to preserve the table layout */
#bom-mapping-table .th-content { display: flex; flex-direction: column; gap: 8px; }
#bom-mapping-table th select { width: 100% !important; }
#bom-mapping-table tbody tr:nth-child(even) { background-color: #f7fafc !important; }
#bom-mapping-table td { color: #4a5568 !important; vertical-align: middle !important; }

/* --- BUTTONS & LOADER --- */
.button-primary { background-color: #2563eb !important; color: #ffffff !important; border: none; padding: 12px 24px !important; font-size: 1rem !important; font-weight: bold; border-radius: 6px; cursor: pointer; transition: background-color 0.2s; display: block; margin-top: 1.5rem; margin-left: auto; }
.button-primary:hover { background-color: #1d4ed8 !important; }
.loader { border: 5px solid #f3f3f3; border-top: 5px solid #3498db; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 2rem auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- FILTER BUTTONS --- */
.bom-filters { display: flex; gap: 10px; margin-bottom: 1.5rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 1.5rem; }
.filter-btn { padding: 8px 16px; border: 1px solid #cbd5e0; background-color: #fff; border-radius: 6px; cursor: pointer; font-weight: 500; transition: all 0.2s; }
.filter-btn:hover { background-color: #f7fafc; border-color: #a0aec0; }
.filter-btn.active { background-color: #2563eb; color: #fff; border-color: #2563eb; }

/* --- CIRCULAR PROGRESS BAR (MATCH SCORE) --- */
.match-score-circle { width: 60px; height: 60px; position: relative; margin: 0 auto; }
.match-score-circle .score-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 1rem; font-weight: bold; }
.match-score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.match-score-circle .circle-bg { fill: none; stroke: #e2e8f0; stroke-width: 8; }
.match-score-circle .circle-fg { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease-out; }
.match-score-circle.exact .circle-fg { stroke: #16a34a; }
.match-score-circle.exact .score-text { color: #16a34a; }
.match-score-circle.partial .circle-fg { stroke: #f59e0b; }
.match-score-circle.partial .score-text { color: #f59e0b; }

/* --- RESULTS TABLES --- */
.bom-results-section { margin-bottom: 2rem; }
.bom-results-section h3 { font-size: 1.25rem; margin-bottom: 1rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; }
#bom-matched-table, #bom-unmatched-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: fixed; }
#bom-matched-table th, #bom-matched-table td, #bom-unmatched-table th, #bom-unmatched-table td { border: 1px solid #e2e8f0; padding: 12px; text-align: left; vertical-align: middle; }
#bom-matched-table th, #bom-unmatched-table th { background-color: #f7fafc; font-weight: bold; }
#bom-matched-table .match-score-col { width: 100px; text-align: center; }
#bom-matched-table img { max-width: 50px; height: auto; border-radius: 4px; border: 1px solid #e2e8f0; }
#bom-matched-table .product-name a { font-weight: bold; text-decoration: none; color: #2563eb; }
#bom-matched-table .product-name a:hover { text-decoration: underline; }
#bom-matched-table .product-sku { font-size: 0.85rem; color: #666; }
#bom-matched-table input.qty { width: 70px; padding: 8px; text-align: center; border: 1px solid #cbd5e0; border-radius: 6px; }
.stock-status.instock { color: #16a34a; font-weight: bold; }
.stock-status.outofstock { color: #dc2626; font-weight: bold; }

/* --- RESULTS SUMMARY & ACTION --- */
.bom-results-summary { margin-top: 2rem; padding: 1.5rem; background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 1.5rem; }
.assembly-multiplier { display: flex; align-items: center; gap: 0.5rem; }
.assembly-multiplier label { font-weight: bold; color: #4a5568; }
.assembly-multiplier input { width: 80px; padding: 8px; text-align: center; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 1rem; font-weight: bold; }
.bom-total-cost { font-size: 1.5rem; font-weight: bold; margin-right: auto; flex-grow: 1; }
.bom-total-cost .total-label { font-weight: normal; color: #4a5568; margin-right: 0.5rem; }
#add-to-cart-btn { min-width: 200px; }
@media (max-width: 768px) { .bom-results-summary { flex-direction: column; align-items: stretch; } .bom-total-cost { text-align: center; margin-bottom: 1rem; margin-right: 0; } #add-to-cart-btn { width: 100%; text-align: center; } }