/* =============================================================================
   8-BIT PIXEL COMPONENTS
   ============================================================================= */

/* Tooltip - Pixel Info Box */
.tooltip {
    position: fixed;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: var(--space-md);
    font-family: var(--font-bios);
    font-size: var(--font-size-base);
    line-height: 1.8;
    pointer-events: none;
    z-index: 1000;
    max-width: 600px;
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--shadow-primary);
    border: var(--border-width) solid var(--border-primary);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: none !important; /* Hidden - replaced by sidebar overlay */
    transform: translateY(10px);
}

.tooltip.show {
    opacity: 0; /* Keep hidden even with show class */
    display: none !important;
    transform: translateY(0);
}

.tooltip h4 {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-size: var(--font-size-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-bios);
}

.tooltip .tooltip-name {
    flex: 1;
    margin-right: 8px;
}

/* 8-Bit Badges */
.tooltip .alias-level-tag {
    font-family: var(--font-bios);
    font-size: var(--font-size-xs);
    font-weight: 400;
    padding: 2px var(--space-xs);
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    display: inline-block;
    flex-shrink: 0;
    border: var(--border-width) solid var(--border-primary);
}

.tooltip .alias-level-tag.core {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 400;
}

/* Show in tree button in tooltip (icon only) */
.tooltip .tooltip-show-in-tree {
    background: var(--bg-interactive);
    border: var(--border-width) solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    font-family: var(--font-bios);
    line-height: 1;
}

.tooltip .tooltip-show-in-tree:hover {
    background: var(--cta-hover);
    color: var(--bg-primary);
}

.tooltip .tooltip-show-in-tree:active {
    background: var(--cta-active);
    transform: scale(0.95);
}

/* Component badges in tooltip */
.tooltip .alias-level-tag.component-set-badge {
    background-color: var(--status-success);
    color: var(--bg-primary);
    border-color: var(--status-success);
    font-weight: 400;
}

.tooltip .alias-level-tag.component-badge {
    background-color: var(--accent-cyan);
    color: var(--bg-primary);
    border-color: var(--accent-cyan);
    font-weight: 400;
}

/* Show in tree button in tooltip (icon only) */
.tooltip .tooltip-show-in-tree {
    background: var(--bg-interactive);
    border: var(--border-width) solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    font-family: var(--font-bios);
    line-height: 1;
}

.tooltip .tooltip-show-in-tree:hover {
    background: var(--cta-hover);
    color: var(--bg-primary);
}

.tooltip .tooltip-show-in-tree:active {
    background: var(--cta-active);
    transform: scale(0.95);
}

.tooltip .style-type-tag {
    font-family: var(--font-bios);
    font-size: var(--font-size-xs);
    font-weight: 400;
    padding: 2px var(--space-xs);
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    display: inline-block;
    flex-shrink: 0;
    border: var(--border-width) solid var(--border-primary);
}

.tooltip p {
    margin-bottom: 3px;
    margin-top: 3px;
}

.tooltip .type {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.tooltip-color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: var(--border-width) solid var(--border-primary);
    margin-left: 4px;
    vertical-align: middle;
    border-radius: 0px;
}

.tooltip-modes-list {
    padding-left: 8px;
    list-style: none;
}

.tooltip-modes-list li {
    margin: 4px 0;
    padding: 2px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary); /* Ensure consistent text color */
}

.tooltip-modes-list li:last-child {
    border-bottom: none;
}

/* Component usage lists in tooltip */
.tooltip-component-list {
    padding-left: 8px;
    list-style: none;
    margin: 8px 0;
}

.tooltip-component-list li {
    margin: 4px 0;
    padding: 4px 8px;
    font-size: 12px;
    background: var(--accent-cyan-10);
    border-left: var(--border-width-thick) solid var(--accent-cyan);
    border-radius: 0px;
    color: var(--text-primary);
}

/* Component Properties Section - Grey Container */
.component-properties-section {
    margin: 12px 0;
    padding: 12px;
    background: var(--color-gray-component-20);
    border-radius: 0px;
    border: 1px solid var(--color-gray-component-30);
}

.component-properties-section p {
    margin: 0 0 8px 0;
}

.component-properties-section .tooltip-component-list {
    margin: 0;
}

/* Ensure all hex color values in tooltips have consistent text color */
.tooltip p,
.tooltip li {
    color: var(--text-primary);
}

/* Desktop Tooltip Connection Impact Styles */
.tooltip .impact-oneliner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 0px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 12px;
    border: 1px solid var(--accent-white-10);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Risk level colors for desktop */
.tooltip .impact-oneliner.risk-high {
    background: var(--risk-high-bg);
    border-color: var(--risk-high-border);
    color: var(--risk-high-text);
}

.tooltip .impact-oneliner.risk-medium {
    background: var(--risk-medium-bg);
    border-color: var(--risk-medium-border);
    color: var(--risk-medium-text);
}

.tooltip .impact-oneliner.risk-low {
    background: var(--risk-low-bg);
    border-color: var(--risk-low-border);
    color: var(--risk-low-text);
}

/* Component Stats Section - appears right after risk indicator in desktop tooltip */
.tooltip .component-stats-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0px;
}

.tooltip .component-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--accent-white-05);
}

.tooltip .component-stat-item:last-child {
    border-bottom: none;
}

.tooltip .component-stat-item .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tooltip .component-stat-item .stat-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Unified Component Usage Section */
.tooltip .component-usage-section {
    margin: 12px 0;
    background: var(--color-blue-component-08);
    border: 1px solid var(--color-blue-component-25);
    border-radius: 0px;
    overflow: hidden;
}

.tooltip .usage-subsection {
    border-bottom: 1px solid var(--color-blue-component-15);
}

.tooltip .usage-subsection:last-child {
    border-bottom: none;
}

.tooltip .usage-subsection.empty .usage-header {
    opacity: 0.5;
    cursor: default !important;
}

.tooltip .usage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--color-blue-component-10);
    transition: background 0.2s;
}

.tooltip .usage-header:hover {
    background: var(--color-blue-component-12);
}

.tooltip .usage-subsection.empty .usage-header:hover {
    background: var(--color-blue-component-10);
}

.tooltip .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip .usage-toggle {
    font-size: 10px;
    color: var(--color-blue-component);
    transition: transform 0.2s;
    display: inline-block;
    width: 12px;
}

.tooltip .usage-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tooltip .usage-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-blue-component);
    min-width: 24px;
    text-align: right;
}

.tooltip .usage-list {
    padding: 8px 12px 12px 32px;
    list-style: none;
    margin: 0;
    background: var(--accent-black-20);
}

.tooltip .usage-list li {
    margin: 4px 0;
    padding: 4px 8px;
    font-size: 11px;
    background: var(--accent-cyan-10);
    border-left: var(--border-width-thick) solid var(--accent-cyan);
    border-radius: 0px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Cross-file usage items have distinct styling */
.tooltip .usage-list li.cross-file-usage {
    background: rgba(151, 71, 255, 0.1);
    border-left-color: #9747FF;
}

.tooltip .cross-file-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(151, 71, 255, 0.2);
    border: 1px solid #9747FF;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 600;
    color: #9747FF;
    margin-left: 6px;
}

.tooltip .usage-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tooltip .usage-figma-link {
    flex-shrink: 0;
    font-size: 14px;
    text-decoration: none;
    color: var(--text-muted);
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 4px;
    border-radius: 0px;
    background: transparent;
    width: 22px;
    height: 22px;
}

.tooltip .usage-figma-link:hover {
    opacity: 1;
    background: var(--color-blue-component-15);
}

.tooltip .usage-figma-link:active {
    background: var(--color-blue-component-25);
}

/* Path Action Button */
.tooltip .usage-path-btn {
    flex-shrink: 0;
    font-size: 14px;
    text-decoration: none;
    color: var(--text-muted);
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 4px;
    border-radius: 0px;
    background: transparent;
    width: 22px;
    height: 22px;
    border: none;
    cursor: pointer;
}

.tooltip .usage-path-btn:hover {
    opacity: 1;
    background: var(--color-purple-accent-10);
}

.tooltip .usage-path-btn:active,
.tooltip .usage-path-btn.active {
    background: var(--color-purple-accent-25);
}

/* Detachment Metric Display */
.tooltip .detachment-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--color-orange-component-10);
    border-radius: 0px;
    margin: 8px 0;
    border-left: 3px solid var(--color-orange-component);
}

.tooltip .detachment-metric .metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.tooltip .detachment-metric .metric-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-orange-component);
}

/* Permutation Metric Display */
.tooltip .permutation-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--color-purple-analytics-10);
    border-radius: 0px;
    margin: 8px 0;
    border-left: 3px solid var(--color-purple-analytics);
}

.tooltip .permutation-metric .metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.tooltip .permutation-metric .metric-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-purple-analytics);
}


/* Loading States */
.loading {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, 0);
    text-align: center;
    z-index: 10001; /* Above backdrop */
    background: transparent; 
    display: none;
    max-width: 600px;
}

.loading.visible {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Loading backdrop - dims the screen behind the loading module */
.loading-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85); /* White dimmed overlay for black-on-white theme */
    z-index: 10000; /* Below loading module, above everything else */
    display: none;
    pointer-events: none;
}

.loading-backdrop.visible {
    display: block;
}

/* ===== BIOS BOOT SEQUENCE LOADING ANIMATION ===== */
.bios-boot-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: var(--bg-primary);
    border: var(--border-width-thick) solid var(--border-primary);
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--shadow-primary);
    min-width: 500px;
    max-width: 600px;
}

/* BIOS Header Section */
.bios-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    width: 100%;
    border-bottom: var(--border-width) solid var(--border-primary);
    padding-bottom: var(--space-md);
}

.bios-title {
    font-family: var(--font-bios);
    font-size: var(--font-size-xl);
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 2px;
}

.bios-copyright {
    font-family: var(--font-bios);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Boot Sequence Section */
.bios-boot-sequence {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
}

.boot-line {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-bios);
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.boot-label {
    font-weight: normal;
}

.boot-cursor {
    display: inline-block;
    animation: biosBlinkCursor 1s steps(2) infinite;
    font-weight: bold;
}

@keyframes biosBlinkCursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Pixelated Progress Bar */
.bios-progress-container {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-bios);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    width: 100%;
}

.progress-bracket {
    font-weight: bold;
    color: var(--text-primary);
}

.bios-progress-bar {
    flex: 1;
    height: 20px;
    background: var(--bg-secondary);
    border: var(--border-width) solid var(--border-primary);
    position: relative;
    overflow: hidden;
}

.bios-progress-fill {
    height: 100%;
    background: var(--text-primary);
    width: 0%;
    transition: width 0.3s ease-out;
    position: relative;
}

/* Scanline effect on progress bar */
.bios-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

.progress-percentage {
    font-weight: bold;
    min-width: 40px;
    text-align: right;
    color: var(--text-primary);
}

/* BIOS Status Messages */
.bios-status {
    font-family: var(--font-bios);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    min-height: 40px;
    white-space: pre-line;
}

/* System Status Footer */
.bios-system-status {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    width: 100%;
    border-top: var(--border-width) solid var(--border-primary);
    padding-top: var(--space-md);
}

.status-line {
    font-family: var(--font-bios);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.status-line span {
    font-weight: bold;
    color: var(--text-primary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .bios-boot-container {
        min-width: 320px;
        max-width: 90vw;
        padding: var(--space-md);
    }
    
    .bios-title {
        font-size: var(--font-size-lg);
    }
    
    .boot-line,
    .bios-progress-container {
        font-size: var(--font-size-sm);
    }
}

/* Legacy support - keep for any remaining references */
.progress-details {
    margin-top: 8px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-muted);
    max-width: 480px;
    line-height: 1.4;
    text-align: center;
    font-style: italic;
}

.progress-details.highlight {
    color: var(--text-muted);
}

@keyframes fadeInOut {    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Tree Loading State Styles */
.tree-placeholder.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: 200px;
}

.tree-placeholder.loading-state .loading-animation-container {
    margin-bottom: 20px;
}

.tree-placeholder.loading-state .loading-progress {
    width: 100%;
}

.tree-placeholder.loading-state .loading-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.loading-step {
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.6;
    transition: all 0.3s ease;
    padding: 4px 8px;
    border-radius: 0px;
}

.loading-step.active {
    color: var(--accent-color);
    opacity: 1;
    background: rgba(var(--accent-color-rgb), 0.1);
    font-weight: 500;
}

.loading-step.complete {
    color: var(--text-secondary);
    opacity: 0.8;
}

.loading-step.complete::before {
    content: '✓ ';
    color: var(--success-color, #22c55e);
}

/* Tree Empty State - matches initial app loading */
.tree-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    min-height: 200px;
    text-align: center;
}

.empty-state-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state-icon {
    font-size: 24px;
    opacity: 0.6;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
}

/* Error Display Styles */
.error-display-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    padding: 16px;
    text-align: center;
}

.error-display-container h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.error-message-detail {
    font-size: 14.4px;
    color: var(--text-tertiary);
    margin-top: 8px;
}

.button-retry {
    margin-top: 16px;
    padding: 8px 16px;
    background: var(--accent-button);
    color: white;
    border: none;
    border-radius: 0px;
    cursor: pointer;
    font-size: 14.4px;
    transition: background-color 0.2s;
}

.button-retry:hover {
    background: var(--accent-button-hover);
}

/* Enhanced Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        position: fixed;
        left: -280px;
        top: 72px;
        height: calc(100vh - 72px);
        z-index: 200;
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100vw;
        left: -100vw;
    }
    
    .sidebar.open {
        left: 0;
    }
}
