/* 3D Map Visualization Styles */

.map3d-window {
    /* The canvas uses height:100%; it needs a real height on a parent to avoid 0px renderer size. */
    height: calc(100vh - 140px);
    min-height: 520px;
}

.map3d-canvas-host {
    /* Ensure the canvas host actually stretches inside the flex column window */
    min-height: 0;
}

.diagnostics-split-panel {
    height: calc(100vh - 140px);
    min-height: 520px;
}

.diagnostics-fullbleed {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-top: 16px;
    padding-left: 24px;
    padding-right: 24px;
}

.rtls-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.rtls-modal {
    width: min(720px, 100%);
    max-height: min(80vh, 900px);
    overflow: hidden;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.rtls-modal-lg {
    width: min(980px, 100%);
}

.rtls-modal .bi {
    line-height: 1;
}

.rtls-modal-body {
    overflow-y: auto;
    max-height: calc(80vh - 64px);
}

.map3d-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.92) 0%, rgba(22, 33, 62, 0.92) 100%);
    z-index: 5;
}

.map-inline-dialog {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 14;
    width: min(420px, calc(100% - 32px));
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 18px 28px rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.map3d-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 1rem;
}

.map3d-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.map3d-header h4 {
    color: #fff;
    margin: 0;
    font-weight: 600;
}

.map3d-stats {
    display: flex;
    gap: 0.5rem;
}

.map3d-canvas-container {
    flex: 1;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#threejs-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.map3d-legend {
    display: flex;
    gap: 2rem;
    justify-content: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ccc;
    font-size: 0.9rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.anchor-color {
    background: #2196F3;
    box-shadow: 0 0 8px #2196F3;
}

.legend-color.tag-color {
    background: #4CAF50;
    box-shadow: 0 0 8px #4CAF50;
    border-radius: 50%;
}

.legend-color.grid-color {
    background: repeating-linear-gradient(
        90deg,
        #ccc,
        #ccc 2px,
        transparent 2px,
        transparent 6px
    );
}

.map3d-controls {
    text-align: center;
    padding: 0.5rem;
    color: #888;
}

/* Tag info popup (future enhancement) */
.tag-info-popup {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tag-info-popup h5 {
    margin: 0 0 0.5rem 0;
    color: #4CAF50;
}

.tag-info-popup .coord {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .map3d-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .map3d-legend {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .map3d-container {
        height: calc(100vh - 100px);
    }
}

/* Animation for loading state */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-3d {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1.2rem;
    animation: pulse 1.5s ease-in-out infinite;
}
