/* Using Tailwind CSS for most styling - keeping only essential custom CSS */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* File status messages */
.file-status {
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

.file-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.file-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.file-status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Tree container */
.tree-container {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    min-height: 700px;
    padding: 30px 20px;
    overflow: scroll;
    position: relative;
    cursor: default;
}

/* List container */
.list-container {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    min-height: 700px;
    max-height: 800px;
    padding: 20px;
    overflow-y: auto;
    position: relative;
}

/* List items */
.list-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.list-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.list-item-level {
    font-weight: 700;
    font-size: 11px;
    color: #667eea;
    background: #e0e7ff;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
}

.list-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item-name {
    font-weight: 700;
    font-size: 13px;
    color: #1e293b;
}

.list-item-details {
    display: flex;
    gap: 15px;
    font-size: 11px;
    color: #64748b;
}

.list-item-quantity {
    font-weight: 600;
    color: #667eea;
}

.list-item-type {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Level-based indentation */
.list-item[data-level="0"] {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 2px solid #fb923c;
}

.list-item[data-level="0"] .list-item-name {
    color: #c2410c;
    font-size: 14px;
}

.list-item[data-level="1"] { margin-left: 30px; }
.list-item[data-level="2"] { margin-left: 60px; }
.list-item[data-level="3"] { margin-left: 90px; }
.list-item[data-level="4"] { margin-left: 120px; }
.list-item[data-level="5"] { margin-left: 150px; }
.list-item[data-level="6"] { margin-left: 180px; }
.list-item[data-level="7"] { margin-left: 210px; }
.list-item[data-level="8"] { margin-left: 240px; }
.list-item[data-level="9"],
.list-item[data-level="10"],
.list-item[data-level="11"],
.list-item[data-level="12"] { margin-left: 270px; }

/* Fullscreen zoom controls */
.fullscreen-zoom-controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: rgba(102, 126, 234, 0.95);
    padding: 15px 20px;
    border-radius: 50px;
    display: none;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 999999;
    backdrop-filter: blur(10px);
}

:fullscreen .fullscreen-zoom-controls,
:-webkit-full-screen .fullscreen-zoom-controls,
:-moz-full-screen .fullscreen-zoom-controls,
:-ms-fullscreen .fullscreen-zoom-controls,
.tree-container.in-fullscreen .fullscreen-zoom-controls {
    display: flex !important;
}

.zoom-control-btn {
    width: 45px;
    height: 45px;
    border: none;
    background: white;
    color: #667eea;
    font-size: 28px;
    font-weight: bold;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    line-height: 1;
}

.zoom-control-btn:hover {
    transform: scale(1.1);
    background: #667eea;
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.zoom-control-btn:active {
    transform: scale(0.95);
}

.fullscreen-zoom-level {
    color: white;
    font-size: 20px;
    font-weight: 700;
    min-width: 70px;
    text-align: center;
    user-select: none;
}

/* Treant.js Custom Styling */
.tree-container .Treant {
    width: 100% !important;
    height: auto !important;
    min-height: 700px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.tree-container .Treant svg path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tree-container .Treant > .node:first-child,
.tree-container .Treant .node-centered {
    margin: 0 auto;
}

.tree-container .Treant > svg {
    display: block;
    margin: 0 auto;
}

.tree-container .node {
    cursor: pointer;
}

.tree-container .node-name {
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 4px;
    line-height: 1.3;
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.tree-container .node-quantity {
    font-size: 10px;
    font-weight: 600;
    margin: 4px 0;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    display: inline-block;
}

.tree-container .node-type {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 4px;
    letter-spacing: 0.3px;
}

/* BOM Node Styling */
.bom-node {
    padding: 10px 12px;
    background: white;
    color: #1e293b;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
    min-width: 180px;
    max-width: 400px;
    text-align: center;
    transition: all 0.3s;
    border: 2px solid #e2e8f0;
}

.bom-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.bom-node-root {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 2px solid #fb923c;
    font-size: 12px;
    font-weight: 700;
    min-width: 300px;
    max-width: 500px;
    padding: 12px 20px;
}

.bom-node-root .node-name {
    color: #c2410c;
}

.bom-node-root .node-quantity {
    color: #ea580c;
}

.bom-node-root .node-type {
    color: #f97316;
}

.bom-node-component {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 2px solid #60a5fa;
}

.bom-node-component .node-name {
    color: #1e40af;
}

.bom-node-component .node-quantity {
    color: #2563eb;
}

.bom-node-component .node-type {
    color: #3b82f6;
}

.bom-node-leaf {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #4ade80;
}

.bom-node-leaf .node-name {
    color: #15803d;
}

.bom-node-leaf .node-quantity {
    color: #16a34a;
}

.bom-node-leaf .node-type {
    color: #22c55e;
}

/* Loading Spinner */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .tree-container,
    .list-container {
        min-height: 500px;
    }
    
    .bom-node {
        min-width: 150px;
        padding: 12px 14px;
    }
    
    .list-item[data-level="1"] { margin-left: 15px; }
    .list-item[data-level="2"] { margin-left: 30px; }
    .list-item[data-level="3"] { margin-left: 45px; }
    .list-item[data-level="4"],
    .list-item[data-level="5"],
    .list-item[data-level="6"],
    .list-item[data-level="7"],
    .list-item[data-level="8"],
    .list-item[data-level="9"],
    .list-item[data-level="10"],
    .list-item[data-level="11"],
    .list-item[data-level="12"] { margin-left: 60px; }
}

/* Collapse indicators styling */
.collapse-indicator {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    border-radius: 3px;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
    font-size: 12px;
    font-weight: bold;
    color: #3b82f6;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    margin-right: 8px;
}

.collapse-indicator:hover {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
    transform: scale(1.1);
}

.collapse-indicator:active {
    transform: scale(0.95);
}

/* Tree view collapse indicators */
.tree-container .collapse-indicator {
    font-size: 14px;
    width: 22px;
    height: 22px;
    line-height: 20px;
}

/* List view collapse indicators */
.list-container .collapse-indicator {
    font-size: 12px;
    width: 18px;
    height: 18px;
    line-height: 16px;
}

/* Export Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px 28px;
    border-bottom: 2px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 36px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    line-height: 1;
}

.close-btn:hover {
    color: #ef4444;
    background-color: #fee2e2;
    transform: rotate(90deg);
}

.modal-body {
    padding: 28px;
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.export-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    border: 3px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    gap: 8px;
}

.export-option-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.export-visible:hover {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.export-full:hover {
    border-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

/* Mobile responsive for modal */
@media (max-width: 640px) {
    .export-options {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .export-option-btn {
        padding: 24px 16px;
    }
}
