/* Modern Premium CSS Stylesheet for SVG to Resolume XML Converter */

:root {
    --bg-dark: #0a0b11;
    --bg-card: rgba(20, 22, 34, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(168, 85, 247, 0.4);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-glow: rgba(168, 85, 247, 0.15);
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Space Grotesk', 'Courier New', Courier, monospace;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 45%);
}

/* Glassmorphism utility */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
}

.app-container {
    display: flex;
    height: 100vh;
    min-height: 600px;
    overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid var(--border-color);
    background: rgba(15, 17, 28, 0.85);
    z-index: 10;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                border-color 0.3s ease;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}

.sidebar-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-toggle-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}


.brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    background: var(--primary-gradient);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 1px;
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Sidebar Sections */
.control-section {
    margin-bottom: 32px;
}

.control-section h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-num {
    background: rgba(255, 255, 255, 0.06);
    color: var(--primary);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

select option {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

/* Slider Controls */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
    margin: 10px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-value-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.range-badge {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

/* Switch toggle */
.toggle-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.toggle-container input {
    display: none;
}

.toggle-slider {
    width: 38px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    position: relative;
    margin-right: 10px;
    transition: background 0.2s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: transform 0.2s ease;
}

.toggle-container input:checked + .toggle-slider {
    background: var(--success);
}

.toggle-container input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Help Blocks */
.help-box {
    background: rgba(255, 255, 255, 0.02);
    border-left: 2px solid var(--border-color);
    padding: 10px;
    border-radius: 0 6px 6px 0;
    margin-top: 10px;
}

.help-box p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Workspace main content */
.workspace {
    flex: 1;
    min-width: 0;           /* CRITICAL: allows flex child to shrink below content size */
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding: 20px;
    background: #0b0c16;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: rgba(20, 22, 34, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
    gap: 12px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.idle { background-color: var(--text-muted); }
.status-indicator.success { background-color: var(--success); box-shadow: 0 0 8px var(--success); }
.status-indicator.working { background-color: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-indicator.error { background-color: var(--danger); box-shadow: 0 0 8px var(--danger); }

#status-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Card components */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.3s, box-shadow 0.3s;
    min-height: 0;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.card-body {
    padding: 20px;
    flex: 1;
    min-height: 0;
}

.scrollable-y {
    overflow-y: auto;
}

/* Main Grid Layout */
.workspace-grid {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
    height: 100%;
}

/* Tabs styles in main card header */
.preview-tabs-header {
    padding: 0;
    display: block;
    border-bottom: 1px solid var(--border-color);
}

/* Main tab bar: scrollable tabs + pinned legend */
.main-tab-bar {
    display: flex;
    align-items: center;
    gap: 0;
    height: 48px;
    overflow: hidden;
}

.main-tab-scroll {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    width: 100%;
    padding: 0 12px;
    height: 100%;
}
.main-tab-scroll::-webkit-scrollbar { display: none; }

.main-tab-scroll .tab-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 6px 4px;
}

.canvas-legend {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: rgba(20, 22, 34, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 10;
    font-size: 0.72rem;
    pointer-events: none;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.15);
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Canvas Viewport */
.canvas-card {
    flex: 1;
    min-width: 0;
    min-height: 0;
}

/* Styled above as overlay */

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

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.color-dot.input { background: #8b5cf6; }
.color-dot.output { background: #10b981; }

.canvas-wrapper {
    position: relative;
    background: #0f111a;
    border-radius: 0 0 16px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 480px; /* Fixed height to prevent size runaway loop */
    max-height: 70vh; /* Responsive constraint for smaller displays */
}

canvas {
    max-width: 100%;
    max-height: 100%;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

/* Canvas Zoom Controls */
.zoom-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    z-index: 10;
    background: rgba(20, 22, 34, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.zoom-controls button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.8rem;
    transition: background 0.15s;
}

.zoom-controls button:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* XML Code Editor View */
.code-container {
    background: #06070d;
    padding: 20px;
    height: 480px;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 0 0 16px 16px;
}

.code-container pre {
    margin: 0;
}

.code-container code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: #b4bfe4;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Right Panel */
.right-panel {
    width: 360px;
    min-width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    overflow: hidden;
}

.right-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
    gap: 0;
}

/* Drag Zone card */
.drag-card {
    border: 2px dashed var(--border-color);
    cursor: pointer;
    text-align: center;
    transition: all 0.25s ease;
}

.drag-card:hover, .drag-card.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.03);
    box-shadow: 0 0 20px var(--accent-glow);
}

.drop-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.drop-content svg {
    color: var(--text-secondary);
    transition: transform 0.25s ease, color 0.25s ease;
}

.drag-card:hover svg, .drag-card.dragover svg {
    color: var(--primary);
    transform: translateY(-4px);
}

.drop-content p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.file-hidden {
    display: none;
}

/* Slices & Layers list container */
.layers-card {
    flex: 1;
    min-height: 200px;
}

.list-container {
    padding: 0;
}

.empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.layers-list {
    list-style: none;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    gap: 12px;
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.layer-checkbox {
    cursor: pointer;
}

.layer-color-preview {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.1);
}

.layer-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-pts-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Action Buttons Container */
.action-card {
    padding: 20px;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary);
    padding: 0;
}

.btn-text:hover {
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 0.95rem;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Instruction Footer block */
.instruction-box {
    padding: 24px;
}

.instruction-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.instruction-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.instruction-steps ol {
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.instruction-steps li {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.instruction-steps strong {
    color: var(--text-primary);
}

.path-code {
    display: block;
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-mono);
    color: var(--success);
    font-size: 0.75rem;
    word-break: break-all;
}

kbd {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    box-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

/* Scrollbar Stylings */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Responsive Sizing & Media Queries
   ========================================================================== */

/* 100vh height boundaries on desktop to prevent runaways */
@media (min-width: 1025px) {
    .app-container {
        height: 100vh;
        overflow: hidden;
    }
    
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }
    
    .workspace {
        height: 100vh;
        overflow: hidden;
        padding: 30px;
        display: flex;
        flex-direction: column;
    }
    
    .workspace-grid {
        flex: 1;
        min-height: 0;
        grid-template-rows: 1fr;
    }
    
    .right-panel {
        height: 100%;
        min-height: 0;
    }
    
    .layers-card {
        flex: 1;
        min-height: 150px;
    }

    .canvas-wrapper, .code-container {
        height: 100% !important;
        flex: 1;
        max-height: none;
    }
}

/* Medium Screens (Tablets / Smaller Laptops) */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    .sidebar {
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar.collapsed {
        height: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin: 0 !important;
        border: none !important;
        overflow: hidden;
    }
    
    .workspace {
        height: auto;
        padding: 20px;
    }
    
    .workspace-grid {
        flex-direction: column;
        height: auto;
    }
    
    .right-panel {
        height: auto;
    }
    
    .right-panel.collapsed {
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden;
    }
    
    .canvas-wrapper, .code-container {
        height: 400px;
    }
}

/* Small Mobile Screens */
@media (max-width: 600px) {
    .workspace {
        padding: 12px;
    }
    
    .brand {
        padding: 16px;
    }
    
    .scrollable-content {
        padding: 16px;
    }
    
    .workspace-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .btn {
        width: 100%;
    }
    
    .canvas-wrapper, .code-container {
        height: 300px;
    }
    
    .preview-tabs-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px;
        height: auto;
        gap: 8px;
    }
    
    .tabs {
        height: auto;
        width: 100%;
    }
    
    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 6px;
    }
    
    .canvas-legend {
        width: 100%;
        justify-content: space-between;
    }
}

/* Slice Properties Panel Styles */
.slider-group-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 24px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    letter-spacing: 0.5px;
}

.slider-label-val {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.slider-label-val label {
    margin-bottom: 0;
}

.slider-range-group {
    margin-bottom: 14px;
}

/* Screen Group Header in Slices List */
.screen-group {
    margin-bottom: 12px;
}

.screen-group-header {
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    border-left: 3px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.screen-group-header .screen-tag {
    font-size: 0.65rem;
    background: rgba(139, 92, 246, 0.15);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Highlight style for active slice in layers list */
.layer-item.active {
    background: rgba(139, 92, 246, 0.12) !important;
    border-left: 3px solid var(--primary);
}

.layer-item {
    cursor: pointer;
    transition: background-color 0.2s, border-left 0.2s;
    border-left: 3px solid transparent;
}

/* Custom XML File Upload UI */
.custom-file-upload {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.xml-upload-label {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.xml-upload-label:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.03);
}

.custom-file-upload.has-file .xml-upload-label {
    border-style: solid;
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.03);
    color: var(--text-primary);
    padding-right: 40px; /* Make space for clear button */
}

.upload-icon {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.2s;
}

.xml-upload-label:hover .upload-icon {
    color: var(--primary);
}

.custom-file-upload.has-file .upload-icon {
    color: var(--success);
}

.btn-clear-xml {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-clear-xml:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.port-filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #fff;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.port-filter-label:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Modal Overlay Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 6, 10, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.25s ease-out;
}

.modal-content {
    width: 460px;
    max-width: 90%;
    padding: 30px;
    border-radius: 20px;
    border: 1px solid var(--border-hover);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(168, 85, 247, 0.1);
    animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.size-options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.size-opt-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    text-align: left;
    padding: 16px 20px !important;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.25s ease;
    width: 100%;
}

.size-opt-btn:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.08) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
}

.size-opt-btn .opt-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.size-opt-btn .opt-desc {
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 4px;
    font-family: var(--font-mono);
}

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

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}


/* ==========================================================================
   PREMIUM UI/UX UPGRADES (GLASSMORPHISM, TOOLBARS, PALETTES & GAUGES)
   ========================================================================== */

/* Glassmorphism Variables & Tokens */
:root {
    --glass-bg: rgba(20, 22, 39, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --neon-purple: #a855f7;
    --neon-cyan: #06b6d4;
    --neon-emerald: #10b981;
    --neon-rose: #f43f5e;
}

/* Premium Glassmorphic Styles */
.glass-premium {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 12px;
}

/* Floating Canvas Toolbar overlay */
.floating-canvas-toolbar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 6px;
    border-radius: 10px;
    z-index: 100;
    pointer-events: auto;
    background: rgba(15, 17, 28, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.floating-canvas-toolbar .tool-btn {
    background: transparent;
    border: none;
    color: #9ca3af;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.floating-canvas-toolbar .tool-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.floating-canvas-toolbar .tool-btn.active {
    color: #fff;
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}

.floating-canvas-toolbar .tool-separator {
    width: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin: 4px 2px;
}

/* Visual Cabinet Palette in Sidebar */
.visual-cabinet-palette {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.visual-cabinet-card {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.visual-cabinet-card:hover {
    border-color: rgba(168, 85, 247, 0.5);
    background: rgba(168, 85, 247, 0.04);
}

.visual-cabinet-card.active {
    border-color: var(--neon-purple);
    background: rgba(168, 85, 247, 0.12);
    box-shadow: inset 0 0 10px rgba(168, 85, 247, 0.15), 0 0 10px rgba(168, 85, 247, 0.1);
}

.visual-cabinet-card .cab-thumb {
    width: 30px;
    height: 30px;
    border: 1.5px solid #9ca3af;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.visual-cabinet-card.active .cab-thumb {
    border-color: var(--neon-purple);
    box-shadow: 0 0 8px var(--neon-purple);
}

.visual-cabinet-card.type-b .cab-thumb {
    height: 48px;
    width: 24px;
}

.visual-cabinet-card .cab-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-primary);
}

.visual-cabinet-card .cab-size {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Floating 3D Controls overlay */
.floating-3d-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    z-index: 100;
    pointer-events: auto;
    width: 170px;
}

.floating-3d-controls h5 {
    margin: 0 0 6px 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.floating-3d-controls .ctrl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: #d1d5db;
}

/* Port Bandwidth Progress Bars */
.port-bandwidth-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
    max-height: 190px;
    overflow-y: auto;
    padding-right: 4px;
}

.port-bandwidth-gauge {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.port-bandwidth-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.port-bandwidth-track {
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.port-bandwidth-bar {
    height: 100%;
    width: 0%;
    background: var(--neon-emerald);
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.port-bandwidth-bar.warning {
    background: #f59e0b; /* Yellow */
}

.port-bandwidth-bar.danger {
    background: var(--neon-rose); /* Red */
    box-shadow: 0 0 5px var(--neon-rose);
}

/* Phase Load Gauges */
.phase-loads-wrapper {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    justify-content: space-between;
}

.phase-load-column {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.phase-load-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
}

.phase-load-name.phase-a { color: #f43f5e; }
.phase-load-name.phase-b { color: #3b82f6; }
.phase-load-name.phase-c { color: #10b981; }

.phase-load-bar-track {
    width: 8px;
    height: 60px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    margin: 4px 0;
}

.phase-load-bar-fill {
    width: 100%;
    height: 0%;
    position: absolute;
    bottom: 0;
    left: 0;
    background: #f43f5e;
    border-radius: 4px;
    transition: height 0.3s ease;
}

.phase-load-value {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Cost Breakdown Visual Bar */
.cost-breakdown-wrapper {
    margin: 10px 0 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cost-breakdown-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
    display: flex;
}

.cost-segment {
    height: 100%;
    transition: width 0.3s ease;
}

.cost-segment.cabinets { background: #8b5cf6; } /* Purple */
.cost-segment.wiring { background: #06b6d4; }    /* Cyan */
.cost-segment.structure { background: #f59e0b; } /* Orange */

.cost-breakdown-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.cost-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cost-legend-color {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.cost-legend-color.cabinets { background: #8b5cf6; }
.cost-legend-color.wiring { background: #06b6d4; }
.cost-legend-color.structure { background: #f59e0b; }

/* =============================================
   PREMIUM VISUAL UPGRADES - Phase 2
   ============================================= */

/* Animated workspace header gradient glow */
.workspace-header {
    position: relative;
    overflow: hidden;
}
.workspace-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--primary) 30%, #22d3ee 60%, var(--primary) 80%, transparent 100%);
    background-size: 200% 100%;
    animation: headerGlow 4s linear infinite;
    opacity: 0.6;
}
@keyframes headerGlow {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Card hover shimmer */
.calc-card {
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.calc-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
    transition: left 0.6s ease;
    pointer-events: none;
}
.calc-card:hover::before {
    left: 150%;
}
.calc-card:hover {
    border-color: rgba(139,92,246,0.25);
    box-shadow: 0 4px 24px rgba(139,92,246,0.08);
}

/* Active tab neon underline indicator */
.tab-btn.active {
    position: relative;
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 2px;
    border-radius: 1px;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    box-shadow: 0 0 8px rgba(168,85,247,0.7);
}

/* Custom scrollbar for sidebar and sub-panels */
.scrollable-content::-webkit-scrollbar,
.manual-sidebar-scroll::-webkit-scrollbar,
.led-calc-sidebar::-webkit-scrollbar,
#manual-bom-view::-webkit-scrollbar {
    width: 4px;
}
.scrollable-content::-webkit-scrollbar-track,
.manual-sidebar-scroll::-webkit-scrollbar-track,
.led-calc-sidebar::-webkit-scrollbar-track,
#manual-bom-view::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.02);
    border-radius: 2px;
}
.scrollable-content::-webkit-scrollbar-thumb,
.manual-sidebar-scroll::-webkit-scrollbar-thumb,
.led-calc-sidebar::-webkit-scrollbar-thumb,
#manual-bom-view::-webkit-scrollbar-thumb {
    background: rgba(139,92,246,0.4);
    border-radius: 2px;
}
.scrollable-content::-webkit-scrollbar-thumb:hover,
.manual-sidebar-scroll::-webkit-scrollbar-thumb:hover,
.led-calc-sidebar::-webkit-scrollbar-thumb:hover,
#manual-bom-view::-webkit-scrollbar-thumb:hover {
    background: rgba(139,92,246,0.7);
}

/* Power circuit badge pulse on overload */
@keyframes overloadPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}
#power-loops-container > div[data-overload="true"] {
    animation: overloadPulse 1.5s ease-in-out infinite;
}

/* Floating toolbar active tool glow */
.tool-btn.active {
    position: relative;
    box-shadow: 0 0 12px var(--neon-cyan, #22d3ee);
}
.tool-btn.active::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(34,211,238,0.3), rgba(139,92,246,0.3));
    z-index: -1;
    animation: toolGlow 2s ease-in-out infinite alternate;
}
@keyframes toolGlow {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* Port bandwidth bar smooth transitions */
.port-bandwidth-bar {
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                background-color 0.3s ease;
}
.port-bandwidth-bar.warning {
    background: linear-gradient(90deg, #f59e0b, #ef4444) !important;
}
.port-bandwidth-bar.danger {
    background: #ef4444 !important;
    box-shadow: 0 0 6px rgba(239,68,68,0.6);
    animation: dangerFlash 1s ease-in-out infinite alternate;
}
@keyframes dangerFlash {
    from { opacity: 1; }
    to { opacity: 0.6; }
}

/* Phase load fill bars */
.phase-load-bar-fill {
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 3px 3px 0 0;
}

/* Visual cabinet palette card hover */
.cab-palette-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.cab-palette-card:hover {
    transform: translateY(-2px);
}
.cab-palette-card.selected {
    animation: selectedPulse 2s ease-in-out infinite;
}
@keyframes selectedPulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--neon-cyan, #22d3ee); }
    50% { box-shadow: 0 0 0 4px rgba(34,211,238,0.4), 0 0 20px rgba(34,211,238,0.2); }
}

/* Smooth BOM cost segment transitions */
.cost-segment {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sub-tabs layout mapping wrapper */
#manual-sub-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
