/* Responsive Info Panel - Persistent sidebar on desktop/tablet, Bottom overlay on mobile */

/* Info panel container */
.mobile-overlay {
    position: fixed;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    will-change: transform;
    -webkit-overflow-scrolling: touch;
}

/* Desktop/Tablet: Persistent right-side sidebar (no overlay behavior) */
@media (min-width: 769px) {
    .mobile-overlay {
        top: 0;
        right: 0;
        bottom: 0;
        width: 400px;
        max-width: 40vw;
        border-left: var(--border-width) solid var(--border-primary);
        border-radius: 0;
       
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        z-index: 100; /* Lower z-index - part of layout, not overlay */
    }
    
    .mobile-overlay.show {
        transform: translateX(0);
    }
}

/* Adjust canvas when info sidebar is visible on desktop/tablet */
@media (min-width: 769px) {
    /* Add class to body when sidebar is shown via JavaScript */
    body.info-sidebar-open .canvas-container {
        margin-right: 400px;
        transition: margin-right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    body.info-sidebar-open .canvas-container svg {
        transition: none; /* Let D3 handle SVG transitions */
    }
    
    /* Also push the version/file info bar */
    body.info-sidebar-open .file-info-container {
        right: 416px; /* 400px sidebar + 16px original offset */
        transition: right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
}

/* Mobile: Bottom overlay (original behavior) */
@media (max-width: 768px) {
    .mobile-overlay {
        bottom: 0;
        left: 0;
        right: 0;
        border-top: var(--border-width) solid var(--border-primary);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 0 var(--shadow-primary);
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        max-height: 70vh;
        z-index: 9999; /* High z-index for mobile overlay */
    }
    
    .mobile-overlay.show {
        transform: translateY(0);
    }
}

/* Overlay header with drag handle */
.mobile-overlay-header {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

/* Desktop/Tablet: Header with close button */
@media (min-width: 769px) {
    .mobile-overlay-header {
        justify-content: space-between;
        border-bottom: var(--border-width) solid var(--border-primary);
        padding: 12px 20px;
        display: flex;
        gap: var(--space-sm);
    }
}

/* Overlay header buttons */
.overlay-show-in-tree-btn,
.overlay-close-btn {
    background: var(--bg-interactive);
    border: var(--border-width) solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    padding: var(--space-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    font-family: var(--font-bios);
    line-height: 1;
}

.overlay-close-btn {
    margin-right: auto;
}

.overlay-show-in-tree-btn {
    margin-left: auto;
}

.overlay-show-in-tree-btn:hover,
.overlay-close-btn:hover {
    background: var(--cta-hover);
    color: var(--bg-primary);
}

.overlay-show-in-tree-btn:active,
.overlay-close-btn:active {
    background: var(--cta-active);
    transform: scale(0.95);
}

/* Mobile: Header with drag handle */
@media (max-width: 768px) {
    .mobile-overlay-header {
        border-bottom: var(--border-width) solid var(--border-primary);
        border-radius: 16px 16px 0 0;
    }
}

/* Drag handle for swipe-to-close - mobile only */
.mobile-overlay-handle {
    width: 32px;
    height: 2px;
    background: var(--border-primary);
    border-radius: 0px;
    margin: 0 auto 4px auto;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
    cursor: grab;
    opacity: 0.6;
}

/* Hide drag handle on desktop/tablet */
@media (min-width: 769px) {
    .mobile-overlay-handle {
        display: none;
    }
}

.mobile-overlay-handle:active {
    background: var(--accent-cyan);
    opacity: 0.8;
    cursor: grabbing;
}

/* Overlay content area */
.mobile-overlay-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* Desktop/Tablet: More padding and scroll */
@media (min-width: 769px) {
    .mobile-overlay-content {
        padding: 20px;
        overflow-y: auto;
        max-height: calc(100vh - 60px); /* Account for header */
    }
}

/* Mobile: Original styling */
@media (max-width: 768px) {
    .mobile-overlay-content {
        padding: 16px;
    }
}

/* Content styling similar to tooltip */
.mobile-overlay-content h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-primary);
    font-weight: 600;
}

.mobile-overlay-content .tooltip-name {
    flex: 1;
    margin-right: 8px;
}

.mobile-overlay-content .alias-level-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 0px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    display: inline-block;
    border: var(--border-width) solid var(--border-primary);
    flex-shrink: 0;
}

.mobile-overlay-content .alias-level-tag.core {
    background-color: var(--cta-primary);
    color: var(--bg-primary);
    border-color: var(--cta-primary);
}

.mobile-overlay-content p {
    margin: 8px 0;
    color: var(--text-secondary);
}

.mobile-overlay-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Color swatch styling */
.mobile-overlay-content .tooltip-color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-primary);
    margin-left: 6px;
    margin-right: 4px;
    vertical-align: middle;
    border-radius: 0px;
}

/* Mode list styling */
.mobile-overlay-content .tooltip-modes-list {
    padding-left: 0;
    list-style: none;
    margin: 8px 0;
}

.mobile-overlay-content .tooltip-modes-list li {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: var(--border-width) solid var(--border-primary);
    border-radius: 0px;
    margin: 4px 0;
}

/* Backdrop for overlay - only on mobile */
.mobile-overlay-backdrop {
    display: none; /* No backdrop on desktop - sidebar is part of layout */
}

/* Show backdrop only on mobile */
@media (max-width: 768px) {
    .mobile-overlay-backdrop {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--overlay-dark);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    .mobile-overlay-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Close button for desktop/tablet */
.overlay-close-btn {
    display: none;
    background: transparent;
    border: var(--border-width) solid var(--border-primary);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 0px;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

@media (min-width: 769px) {
    .overlay-close-btn {
        display: flex;
    }
    
    .overlay-close-btn:hover {
        color: var(--text-primary);
        border-color: var(--text-primary);
        background: var(--bg-hover);
    }
    
    .overlay-close-btn:active {
        transform: scale(0.95);
    }
}

/* Hide regular tooltip on mobile - now hidden on all devices since we use sidebar */
@media (max-width: 768px) {
    .tooltip {
        display: none !important;
    }
}

/* Hide tooltip on desktop/tablet too when using sidebar */
@media (min-width: 769px) {
    .tooltip {
        display: none !important;
    }
}

/* Animation for smooth appearance */
@keyframes mobileOverlaySlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-overlay.animate-in {
    animation: mobileOverlaySlideUp 0.3s ease-out;
}

/* Responsive adjustments for very small screens */
@media (max-width: 375px) {
    .mobile-overlay-content {
        padding: 12px;
        font-size: 13px;
    }
    
    .mobile-overlay-content h4 {
        font-size: 15px;
    }
}

/* Ensure overlay content doesn't interfere with other elements */
.mobile-overlay-content * {
    user-select: text;
    -webkit-user-select: text;
}

/* Mobile overlay actions section */
.mobile-overlay-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gh-border);
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Show in tree button - icon only, 8-bit style */
.mobile-show-in-tree {
    background: var(--bg-interactive);
    border: var(--border-width) solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    padding: var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    font-family: var(--font-bios);
}

.mobile-show-in-tree:hover {
    background: var(--cta-hover);
    color: var(--bg-primary);
}

.mobile-show-in-tree:active {
    background: var(--cta-active);
    transform: scale(0.95);
}

.show-in-tree-icon {
    font-size: 16px;
    line-height: 1;
}

.show-in-tree-text {
    font-weight: 500;
}

/* Show full path button - similar styling with different color accent */
.mobile-show-full-path {
    background: transparent;
    border: 1px solid var(--gh-border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 0px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    min-height: 40px; /* Touch-friendly height */
    font-family: inherit;
}

.mobile-show-full-path:hover {
    color: var(--color-purple-accent); /* Purple accent for path functionality */
    border-color: var(--color-purple-accent);
    background: var(--color-purple-accent-10);
}

.mobile-show-full-path:active {
    color: var(--color-purple-accent-dark);
    border-color: var(--color-purple-accent-dark);
    background: var(--color-purple-accent-15);
    transform: scale(0.98);
}

.show-full-path-icon {
    font-size: 16px;
    line-height: 1;
}

.show-full-path-text {
    font-weight: 500;
}

/* Mobile Connection Impact Styles */
.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 mobile */
.impact-oneliner.risk-high {
    background: var(--risk-high-bg);
    border-color: var(--risk-high-border);
    color: var(--risk-high-text);
}

.impact-oneliner.risk-medium {
    background: var(--risk-medium-bg);
    border-color: var(--risk-medium-border);
    color: var(--risk-medium-text);
}

.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 */
.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;
}

.component-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--accent-white-05);
}

.component-stat-item:last-child {
    border-bottom: none;
}

.component-stat-item .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.component-stat-item .stat-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Unified Component Usage Section for Mobile */
.mobile-overlay-content .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;
}

.mobile-overlay-content .usage-subsection {
    border-bottom: 1px solid var(--color-blue-component-15);
}

.mobile-overlay-content .usage-subsection:last-child {
    border-bottom: none;
}

.mobile-overlay-content .usage-subsection.empty .usage-header {
    opacity: 0.5;
    cursor: default !important;
}

.mobile-overlay-content .usage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--color-blue-component-10);
    transition: background 0.2s;
}

.mobile-overlay-content .usage-header:hover {
    background: var(--color-blue-component-12);
}

.mobile-overlay-content .usage-subsection.empty .usage-header:hover {
    background: var(--color-blue-component-10);
}

.mobile-overlay-content .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-overlay-content .usage-toggle {
    font-size: 10px;
    color: var(--color-blue-component);
    transition: transform 0.2s;
    display: inline-block;
    width: 12px;
}

.mobile-overlay-content .usage-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-overlay-content .usage-count {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-blue-component);
    min-width: 24px;
    text-align: right;
}

.mobile-overlay-content .usage-list {
    padding: 8px 12px 12px 12px;
    list-style: none;
}

.mobile-overlay-content .usage-list li {
    margin: 4px 0;
    padding: 6px 10px;
    font-size: 11px;
    background: var(--color-blue-component-10);
    border-left: 3px solid var(--color-blue-component);
    border-radius: 0px;
    color: var(--gh-text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mobile-overlay-content .usage-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-overlay-content .usage-figma-link {
    flex-shrink: 0;
    font-size: 10px;
    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: 20px;
    height: 20px;
}

.mobile-overlay-content .usage-figma-link:hover {
    opacity: 1;
    background: var(--color-blue-component-15);
}

.mobile-overlay-content .usage-figma-link:active {
    background: var(--color-blue-component-25);
}

/* Path Action Button for Mobile */
.mobile-overlay-content .usage-path-btn {
    flex-shrink: 0;
    font-size: 10px;
    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: 20px;
    height: 20px;
    border: none;
    cursor: pointer;
}

.mobile-overlay-content .usage-path-btn:hover {
    opacity: 1;
    background: var(--color-purple-accent-10);
}

.mobile-overlay-content .usage-path-btn:active,
.mobile-overlay-content .usage-path-btn.active {
    background: var(--color-purple-accent-25);
}

/* Detachment Metric for Mobile */
.mobile-overlay-content .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);
}

.mobile-overlay-content .detachment-metric .metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.mobile-overlay-content .detachment-metric .metric-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-orange-component);
}

/* Permutation Metric for Mobile */
.mobile-overlay-content .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);
}

.mobile-overlay-content .permutation-metric .metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.mobile-overlay-content .permutation-metric .metric-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-purple-analytics);
}

/* Component list styling for mobile */
.mobile-overlay-content .tooltip-component-list {
    padding-left: 0;
    list-style: none;
    margin: 8px 0;
}

.mobile-overlay-content .tooltip-component-list li {
    margin: 4px 0;
    padding: 6px 10px;
    font-size: 12px;
    background: var(--color-blue-component-10);
    border-left: 3px solid var(--color-blue-component);
    border-radius: 0px;
    color: var(--gh-text-secondary);
}

/* 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;
}

/* ===== FIGMA ANALYTICS SECTION ===== */
.figma-analytics-section {
    margin: 16px 0;
    padding: 16px;
    background: var(--color-purple-analytics-08);
    border-radius: 0px;
    border: 1px solid var(--color-purple-analytics-20);
}

.analytics-header {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-purple-analytics);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-interactive);
    border-radius: 0px;
    border: 1px solid var(--border-secondary);
}

.analytics-label {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.analytics-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== USING FILES SECTION ===== */
.using-files-section {
    margin: 16px 0;
    padding: 12px;
    background: var(--color-cyan-file-08);
    border-radius: 0px;
    border: 1px solid var(--color-cyan-file-20);
}

.using-files-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 0px;
    user-select: none;
}

.using-files-header:hover {
    background: var(--color-cyan-file-10);
}

.using-files-toggle {
    font-size: 10px;
    color: var(--color-cyan-file);
    transition: transform 0.2s ease;
    display: inline-block;
    width: 12px;
}

.using-files-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-cyan-file);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.using-files-list {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-cyan-file-20);
}

.using-file-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--accent-black-30);
    border-radius: 0px;
    border-left: 3px solid var(--color-cyan-file);
}

.using-file-item:last-child {
    margin-bottom: 0;
}

.file-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.file-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.file-current-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--gh-success);
    color: var(--text-primary);
    border-radius: 0px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.file-item-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.file-stat {
    color: var(--text-muted);
}

.file-stat strong {
    color: var(--color-cyan-file);
    font-weight: 700;
}

.file-stat-separator {
    color: var(--gh-border);
}

/* ===== FILE SOURCE BADGE ===== */
.component-file-source {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 8px 0 12px 0;
    background: var(--bg-secondary);
    border: var(--border-width) solid var(--border-primary);
    border-radius: 0px;
    font-size: 12px;
    color: var(--text-secondary);
}

.file-source-icon {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

.file-source-text {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
