:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(15, 23, 42, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --danger: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden; /* Prevent scrolling, canvas fills screen */
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* Nav Overlay */
#nav-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Let clicks pass through except on children */
}

.back-btn {
    pointer-events: auto;
    display: inline-block;
    padding: 8px 16px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
    width: max-content;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.viewer-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Info Panel */
#info-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 350px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 10;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

#info-panel.hidden {
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
}

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

.panel-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

#close-panel {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

#close-panel:hover {
    color: var(--text-main);
}

.panel-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    width: max-content;
    background: var(--warning);
    color: #fff;
}

#component-desc {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-muted);
}

#component-details.hidden {
    display: none;
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 5px 0;
}

h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.fault-code-text {
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

#diagnostic-rec {
    font-size: 0.9rem;
    line-height: 1.5;
}

.upload-section {
    margin-top: 10px;
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
}

.small-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

input[type="file"] {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Loading Screen */
#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 0.5s ease;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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