/* cesium.css - v1.1.0 */

.viewer-geo-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #000;
}

.viewer-geo-wrapper.integrated-mode {
    height: calc(100vh - 90px);
}

.viewer-geo-wrapper.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    z-index: 10000;
}

body.viewer-geo-fullscreen-mode {
    overflow: hidden !important;
}

body.viewer-geo-fullscreen-mode .navbar,
body.viewer-geo-fullscreen-mode #main-navbar,
body.viewer-geo-fullscreen-mode .footer {
    display: none !important;
}

/* Header */
.viewer-geo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    padding: 0 16px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.viewer-geo-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.viewer-geo-header .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.viewer-geo-header .btn-back {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.viewer-geo-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.viewer-geo-title .fas {
    color: #2196F3;
}

.viewer-geo-scope-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #666;
    background: #f0f0f0;
    border-radius: 4px;
}

/* Conteneur Cesium */
.viewer-geo-container {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 400px;
}

.viewer-geo-container .cesium-viewer {
    width: 100% !important;
    height: 100% !important;
}

/* Loading */
.viewer-geo-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1e1e1e;
    color: #fff;
    gap: 16px;
}

.viewer-geo-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: viewer-geo-spin 1s linear infinite;
}

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

/* Error */
.viewer-geo-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8d7da;
    color: #721c24;
    padding: 32px;
    text-align: center;
    gap: 16px;
}

.viewer-geo-error-icon {
    font-size: 48px;
}

/* WebGL Context Lost overlay */
.viewer-context-lost-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.context-lost-content {
    text-align: center;
    color: #fff;
    max-width: 420px;
    padding: 32px;
}

.context-lost-icon {
    font-size: 48px;
    color: #ff9800;
    display: block;
    margin-bottom: 16px;
}

.context-lost-content h4 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #fff;
}

.context-lost-content p {
    font-size: 13px;
    color: #aaa;
    margin: 0 0 24px;
    line-height: 1.5;
}

.context-lost-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.context-lost-actions .btn {
    min-width: 260px;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.context-lost-actions .btn-primary {
    background: #2196F3;
    border: none;
    color: #fff;
}

.context-lost-actions .btn-primary:hover {
    background: #1976D2;
}

.context-lost-actions .btn-default {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ccc;
}

.context-lost-actions .btn-default:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.context-lost-actions .btn .fas {
    margin-right: 8px;
}

/* Welcome overlay */
.viewer-geo-welcome-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 32px 48px;
    border-radius: 12px;
    text-align: center;
    z-index: 100;
    pointer-events: none;
}

.viewer-geo-welcome-content h2 {
    margin: 0 0 12px 0;
    font-size: 24px;
}

.viewer-geo-welcome-content p {
    margin: 0;
    font-size: 14px;
}

/* Fullscreen overlay */
.viewer-geo-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10001;
    pointer-events: none;
}

.viewer-geo-fullscreen-overlay .overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
    pointer-events: auto;
}

.viewer-geo-fullscreen-overlay .viewer-geo-title {
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.viewer-geo-fullscreen-overlay .viewer-geo-title .fas {
    color: #64B5F6;
}

.viewer-geo-fullscreen-overlay .viewer-geo-scope-badge {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

.viewer-geo-fullscreen-overlay .overlay-buttons {
    display: flex;
    gap: 8px;
}

.viewer-geo-fullscreen-overlay .btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
}

.viewer-geo-fullscreen-overlay .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.viewer-geo-fullscreen-overlay .btn-close-viewer {
    background: rgba(220, 53, 69, 0.6);
    border-color: rgba(220, 53, 69, 0.8);
}

/* Auto-hide fullscreen controls */
.viewer-geo-wrapper.fullscreen-mode:not(:hover) .viewer-geo-fullscreen-overlay .overlay-header {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.viewer-geo-wrapper.fullscreen-mode:hover .viewer-geo-fullscreen-overlay .overlay-header {
    opacity: 1;
}

/* Viewer Tabs */
.viewer-geo-tabs {
    display: flex;
    gap: 4px;
}

.btn-viewer-tab {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f5f5f5;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-viewer-tab:hover {
    background: #e8e8e8;
    color: #333;
}

.btn-viewer-tab.active {
    background: #2196F3;
    border-color: #2196F3;
    color: #fff;
}

.btn-viewer-tab .fas {
    font-size: 12px;
}

/* Fullscreen overlay tabs */
.viewer-geo-fullscreen-overlay .viewer-geo-tabs {
    margin-right: 8px;
}

.viewer-geo-fullscreen-overlay .btn-viewer-tab {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.8);
}

.viewer-geo-fullscreen-overlay .btn-viewer-tab:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.viewer-geo-fullscreen-overlay .btn-viewer-tab.active {
    background: #2196F3;
    border-color: #2196F3;
    color: #fff;
}

/* Panels */
.viewer-geo-panel {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 400px;
}

/* Embedded child viewer: hide duplicate header/overlay from cesium.js when inside a panel */
.viewer-geo-panel .viewer-geo-wrapper > .viewer-geo-header {
    display: none !important;
}

.viewer-geo-panel .viewer-geo-wrapper > .viewer-geo-fullscreen-overlay {
    display: none !important;
}

.viewer-geo-panel .viewer-geo-wrapper {
    height: 100% !important;
}

.viewer-geo-panel .viewer-geo-wrapper.integrated-mode {
    height: 100% !important;
}

/* Potree container overrides */
.viewer-potree-container {
    background: #1e1e1e;
}

.viewer-potree-container .potree_container {
    width: 100% !important;
    height: 100% !important;
}

/* Potree Settings Panel */
/* ─── Potree settings section (inside vsp-panel) ───────────── */

.potree-settings-section {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.potree-settings-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    letter-spacing: 0.3px;
    transition: color 0.12s, background 0.12s;
}

.potree-settings-section-header:hover {
    color: #ddd;
    background: rgba(255, 255, 255, 0.04);
}

.potree-section-icon {
    font-size: 11px;
    opacity: 0.6;
}

.potree-section-chevron {
    font-size: 9px;
    opacity: 0.5;
    margin-left: 4px;
    transition: transform 0.15s;
}

.potree-section-chevron.collapsed {
    transform: rotate(-90deg);
}

.potree-settings-section-body {
    /* starts expanded — jQuery slideToggle manages display */
}

.potree-settings-body {
    padding: 6px 10px;
}

.potree-settings-body label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0 2px;
    font-size: 11px;
    color: #aaa;
}

.potree-settings-body label .val {
    color: #4fc3f7;
    font-weight: 600;
    font-family: monospace;
    min-width: 40px;
    text-align: right;
}

.potree-settings-body input[type="range"] {
    width: 100%;
    height: 4px;
    margin: 4px 0 10px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
}

.potree-settings-body input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #4fc3f7;
    cursor: pointer;
}

.potree-settings-body input[type="checkbox"] {
    margin-right: 8px;
    accent-color: #4fc3f7;
}

/* Settings panel: warning badge in section header */
.potree-settings-badge {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ff9800;
    color: #000;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    margin-left: 4px;
}

/* Settings panel: warning value highlight */
.potree-settings-body .val.warn {
    color: #ff9800;
}

/* Settings panel: warning message line */
.potree-settings-warn {
    color: #ff9800;
    font-size: 10px;
    margin: -2px 0 4px;
    padding-left: 2px;
}

.potree-settings-warn .fas {
    font-size: 9px;
    margin-right: 3px;
}

/* Settings panel: slider tooltip (floating overlay on hover) */
.potree-slider-group {
    position: relative;
}
.potree-settings-tip {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 10;
    font-size: 10px;
    line-height: 1.4;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}
.potree-slider-group:hover .potree-settings-tip {
    display: block;
}
.potree-settings-tip .tip-up,
.potree-settings-tip .tip-down {
    display: block;
    padding: 2px 0;
}
.potree-settings-tip .tip-up {
    color: #81c784;
}
.potree-settings-tip .tip-down {
    color: #4fc3f7;
}
.potree-settings-tip .fas {
    font-size: 8px;
    width: 10px;
    text-align: center;
    margin-right: 3px;
    opacity: 0.7;
}

/* Settings panel: GPU info bar */
.potree-gpu-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 6px;
    font-size: 10px;
    color: #666;
}

.potree-gpu-icon {
    font-size: 12px;
    opacity: 0.6;
    flex-shrink: 0;
}

.potree-gpu-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.potree-gpu-tier {
    flex-shrink: 0;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Settings panel: reset button */
.potree-settings-reset-row {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.potree-settings-reset {
    width: 100%;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #aaa;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.potree-settings-reset:hover {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
    border-color: rgba(76, 175, 80, 0.3);
}

.potree-settings-reset .fas {
    margin-right: 6px;
    font-size: 12px;
}

/* Hide Cesium.ion logo */
.cesium-viewer .cesium-widget-credits {
    display: none !important;
}

/* Toolbar styles moved to viewer-toolbar.css (shared between Cesium & Potree) */

/* ===== Potree Colorbar (bottom center) ===== */
.potree-colorbar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    backdrop-filter: blur(8px);
}

.potree-colorbar-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

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

.potree-colorbar-btn.active {
    background: #4fc3f7;
    color: #000;
    font-weight: 600;
}

/* ===== Potree Elevation Palette (left) ===== */
.potree-elevation-palette {
    position: absolute;
    left: var(--lp-offset, 16px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 900;
    transition: left 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    backdrop-filter: blur(8px);
}

.potree-palette-track {
    position: relative;
    width: 20px;
    height: 300px;
}

.potree-palette-gradient {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.potree-palette-handle {
    position: absolute;
    left: 24px;
    width: auto;
    height: 20px;
    display: flex;
    align-items: center;
    cursor: ns-resize;
    z-index: 210;
    user-select: none;
    -webkit-user-select: none;
    transform: translateY(-50%);
}

.potree-palette-handle::before {
    content: '';
    display: block;
    width: 14px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    margin-right: 4px;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.potree-palette-handle-label {
    color: #fff;
    font-size: 10px;
    font-family: monospace;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

.potree-palette-dropdown {
    margin-top: 10px;
}

.potree-palette-select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #ddd;
    font-size: 10px;
    padding: 3px 4px;
    outline: none;
    cursor: pointer;
    width: 80px;
}

.potree-palette-select option {
    background: #222;
    color: #ddd;
}

/* ===== Potree Classification Panel (right) ===== */
.potree-classification-panel {
    position: absolute;
    right: var(--rp-offset, 12px);
    top: var(--vsp-panel-top, 118px);
    z-index: 900;
    transition: right 0.25s ease, top 0.25s ease;
    width: 260px;
    max-height: calc(100% - 120px);
    background: rgba(20, 20, 20, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #ddd;
    font-size: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
}

.potree-classification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.potree-classification-close {
    cursor: pointer;
    opacity: 0.6;
    font-size: 14px;
}

.potree-classification-close:hover {
    opacity: 1;
}

.potree-classification-list {
    overflow-y: auto;
    padding: 6px 0;
    flex: 1;
}

.potree-class-row {
    display: flex;
    align-items: center;
    padding: 5px 14px;
    gap: 8px;
    transition: background 0.15s;
}

.potree-class-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.potree-class-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.potree-class-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.potree-class-name {
    flex: 1;
    font-size: 11px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.potree-class-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.potree-class-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
    transition: color 0.2s;
}

.potree-class-btn:hover {
    color: #fff;
}

.potree-class-btn.potree-dimmed {
    color: rgba(255, 255, 255, 0.2);
}

/* ─── Classification file groups ─────────────────────────── */
.potree-class-file-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.potree-class-file-group:last-child {
    border-bottom: none;
}
.potree-class-file-header {
    padding: 7px 14px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.potree-class-file-header:hover {
    background: rgba(255, 255, 255, 0.07);
}
.potree-class-file-chevron {
    font-size: 9px;
    transition: transform 0.15s;
}
.potree-class-file-group.collapsed .potree-class-file-chevron {
    transform: rotate(-90deg);
}
.potree-class-file-count {
    color: #777;
    font-weight: 400;
}
.potree-class-file-list {
    overflow: hidden;
    transition: max-height 0.2s ease;
}
.potree-class-file-group.collapsed .potree-class-file-list {
    max-height: 0 !important;
    overflow: hidden;
}

/* ─── Leaflet z-index stacking fixes ──────────────────────── */
/* Leaflet map panes use z-index 200–800. Panel containers and
   toolbars inside the map must sit above all Leaflet panes. */

.viewer-left-panel-container,
.viewer-right-panel-container,
.viewer-style-panel-container {
    /* Containers are flow-sized (0-height) wrappers.
       z-index lives on the actual panels (.viewer-left-panel etc.)
       which already have position: absolute. */
}

.viewer-geo-panel .viewer-toolbar {
    z-index: 1000;
}

/* Responsive */
@media (max-width: 768px) {
    .viewer-geo-wrapper.integrated-mode {
        height: calc(100vh - 60px);
    }
    .viewer-geo-title {
        font-size: 16px;
    }
    .viewer-geo-tabs {
        gap: 2px;
    }
    .btn-viewer-tab {
        padding: 4px 10px;
        font-size: 12px;
    }
}

/* ─── Right panel coexistence ───────────────────────────────── */
/* When both the right metadata panel and Potree panels overlap,
   Potree panels (settings, classification) appear above the
   right panel since they are transient overlays. */

.viewer-right-panel-container ~ .viewer-geo-panel .potree-classification-panel {
    z-index: 260;
}
