/* --- CORE LAYOUT --- */
:root {
    --glass-bg: rgba(18, 18, 24, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --highlight: #4facfe;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --danger: #ff5050;
}

body { 
    margin: 0; padding: 0; overflow: hidden; 
    font-family: 'Inter', 'Segoe UI', Helvetica, sans-serif; 
    background: #000; color: var(--text-main); 
}

#viewer-container { 
    position: absolute; width: 100%; height: 100%; 
    left: 0; top: 0; z-index: 0; 
}

/* --- GLASS PANEL SYSTEM --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    transition: width 0.3s ease, opacity 0.3s ease;
}

/* --- SIDEBAR --- */
#ui-panel {
    position: absolute; top: 20px; left: 20px; bottom: 60px;
    width: 320px; z-index: 1000;
    display: flex; flex-direction: column;
}

#ui-panel.collapsed {
    width: 48px; height: 48px; bottom: auto;
    overflow: hidden; cursor: pointer;
    background: rgba(18, 18, 24, 0.6);
}

#panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    min-height: 48px; box-sizing: border-box;
}

.brand { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap; }
.brand .highlight { color: var(--highlight); }

#panel-toggle { 
    cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
    width: 24px; height: 24px;
}
#panel-toggle:hover { color: white; }

#ui-content {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}
/* Scrollbar Styling */
#ui-content::-webkit-scrollbar { width: 6px; }
#ui-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
#ui-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* --- CONTROLS --- */
.control-group { margin-bottom: 24px; }

.section-label {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 10px;
}

.btn-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

button {
    width: 100%; padding: 10px 8px; border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    transition: all 0.2s;
}

button:hover { background: rgba(255, 255, 255, 0.15); color: white; }
button:active { transform: scale(0.98); }

button.active {
    background: var(--highlight);
    color: #09090b; /* Dark text for contrast on blue */
    font-weight: 700;
    box-shadow: 0 0 15px rgba(79, 172, 254, 0.3);
}

button.danger { background: rgba(255, 80, 80, 0.15); color: #ff8080; }
button.danger:hover { background: rgba(255, 80, 80, 0.3); color: white; }
button.secondary { background: transparent; border: 1px solid var(--glass-border); }

button.print { background: #e0e0e0; color: #000; font-weight: 800; }

iconify-icon { font-size: 16px; flex-shrink: 0; }

/* --- INPUTS --- */
.slider-header {
    display: flex; justify-content: space-between;
    font-size: 11px; color: var(--text-muted); margin-bottom: 6px;
}
input[type="range"] { width: 100%; cursor: pointer; accent-color: var(--highlight); }
select {
    width: 100%; padding: 10px;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--glass-border);
    color: white; border-radius: 6px;
    outline: none; cursor: pointer;
}

.sub-panel {
    background: rgba(0,0,0,0.2);
    padding: 12px; border-radius: 8px;
    margin-bottom: 15px; border: 1px solid var(--glass-border);
}

.mt-2 { margin-top: 10px; }

/* --- RIGHT LEGEND --- */
#legend-panel {
    position: absolute; top: 20px; right: 20px;
    width: 90px; padding: 15px;
    z-index: 1000; display: none; 
    flex-direction: column; align-items: center;
}
.legend-title { font-size: 10px; font-weight: bold; color: var(--text-muted); margin-bottom: 10px; }
.gradient-wrapper { display: flex; height: 200px; gap: 8px; width: 100%; }
.bar {
    flex: 1; border-radius: 3px;
    background: linear-gradient(to top, #000080, #0000FF, #00FFFF, #00FF00, #FFFF00, #FF0000, #800000);
}
.ticks {
    display: flex; flex-direction: column; justify-content: space-between;
    text-align: right; font-size: 11px; font-family: monospace; color: #ddd;
}

/* --- COMPASS --- */
#compass-panel {
    position: absolute; bottom: 80px; right: 20px;
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; z-index: 1000;
}
#compass-panel:hover { background: rgba(255,255,255,0.15); }
.compass-n {
    position: absolute; top: 5px; font-size: 9px; font-weight: 800; color: #ff5050; pointer-events: none;
}
#compass-arrow-wrapper {
    color: #ddd; transition: transform 0.1s linear; pointer-events: none;
}

/* --- PROFILE CHART --- */
#profile-panel {
    position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
    width: 600px; height: 200px; z-index: 1000;
    display: none; flex-direction: column;
    padding: 15px;
}
.profile-meta {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: var(--text-muted); margin-bottom: 10px;
}
.profile-meta .title { font-weight: bold; color: white; }
#profile-canvas {
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.3); border-radius: 4px;
}

/* --- STATUS BAR --- */
#status-bar {
    position: absolute; bottom: 15px; left: 20px; right: 20px;
    display: flex; justify-content: space-between; pointer-events: none;
}
.pill {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 6px 14px; border-radius: 20px;
    font-size: 11px; color: var(--text-muted);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* --- RESPONSIVE / PRINT --- */
@media (max-width: 768px) {
    #ui-panel { width: 280px; }
    #profile-panel { width: 90%; bottom: 80px; }
    .pill { display: none; } /* Hide status text on small screens */
    #status-bar { justify-content: center; }
    #status-bar .pill:first-child { display: block; } /* Show only left pill */
}

@media print {
    body, #viewer-container { background: white !important; }
    #ui-panel, #status-bar, #potree_sidebar_container, #compass-panel { display: none !important; }
    #legend-panel, #profile-panel { 
        display: flex !important; border: 1px solid #000; 
        background: white; color: black; box-shadow: none; 
    }
    .pill, button { display: none; }
    canvas { border: 1px solid #000; }
}
