/* ==========================================================================
   JC PATH LAB - VISOR 3D WEBGL DE PIEZA QUIRÚRGICA CON PINES HISTOPATOLÓGICOS
   Three.js + GPU + Rotación 360° + Raycasting + Láminas H&E de Alta Resolución
   ========================================================================== */

.surgical3d-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 520px;
    background: radial-gradient(circle at 50% 45%, #0f1d38 0%, #030712 100%);
    border-radius: 14px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid rgba(56, 189, 248, 0.25);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.surgical3d-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    cursor: grab;
    outline: none;
}
.surgical3d-canvas:active {
    cursor: grabbing;
}

/* HUD Superior Translúcido */
.surgical3d-hud-header {
    position: absolute;
    top: 14px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 20;
}

.surgical3d-badge-pill {
    pointer-events: auto;
    background: rgba(15, 23, 42, 0.82);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(56, 189, 248, 0.38);
    border-radius: 9999px;
    padding: 7px 16px;
    color: #f8fafc;
    font-size: 0.82rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.surgical3d-badge-pill i {
    color: #38bdf8;
    font-size: 0.95rem;
    animation: surgicalSpin 14s linear infinite;
}

@keyframes surgicalSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.surgical3d-btn-group {
    pointer-events: auto;
    display: flex;
    gap: 8px;
}

.surgical3d-btn-tool {
    background: rgba(15, 23, 42, 0.78);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}
.surgical3d-btn-tool:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
    color: #ffffff;
    transform: scale(1.06);
}
.surgical3d-btn-tool.active {
    background: rgba(16, 185, 129, 0.25);
    border-color: #10b981;
    color: #34d399;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

/* Indicador de ayuda táctil */
.surgical3d-hint {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.75);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 20px;
    pointer-events: none;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Leyenda Inferior de Márgenes */
.surgical3d-legend-bar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(11, 19, 41, 0.88);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 9999px;
    padding: 7px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 20;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
    max-width: 94%;
    overflow-x: auto;
}

.surgical3d-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity 0.2s;
}
.surgical3d-legend-item:hover {
    opacity: 0.8;
}

.surgical3d-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
    flex-shrink: 0;
}
.dot-green { background: #10b981; color: #10b981; }
.dot-red   { background: #ef4444; color: #ef4444; }
.dot-cyan  { background: #38bdf8; color: #38bdf8; }
.dot-purple{ background: #a855f7; color: #a855f7; }

/* Etiquetas 2D en Pantalla (Screen-Space Badges proyectadas) */
.surgical3d-label {
    position: absolute;
    transform: translate(-50%, -100%);
    pointer-events: auto;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid #38bdf8;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.7), 0 0 12px rgba(56, 189, 248, 0.5);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.2s ease;
    margin-top: -14px;
    z-index: 18;
}
.surgical3d-label:hover {
    transform: translate(-50%, -112%) scale(1.08);
    border-color: #34d399;
    box-shadow: 0 6px 20px rgba(0,0,0,0.8), 0 0 18px rgba(52, 211, 153, 0.6);
}
.surgical3d-label.occluded {
    opacity: 0.25;
    pointer-events: none;
}

/* ==========================================================================
   MODAL FLOTANTE HISTOPATOLÓGICO H&E (GLASSMORPHISM V2)
   ========================================================================== */
.surgical3d-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 6, 23, 0.82);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    backdrop-filter: blur(14px) saturate(180%);
    z-index: 2000500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.surgical3d-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.surgical3d-modal-card {
    background: rgba(15, 23, 42, 0.90);
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    backdrop-filter: blur(24px) saturate(190%);
    border: 1px solid rgba(56, 189, 248, 0.42);
    border-radius: 20px;
    width: 960px;
    max-width: 96vw;
    height: 650px;
    max-height: 92vh;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.85), 0 0 35px rgba(56, 189, 248, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.92) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.surgical3d-modal-overlay.active .surgical3d-modal-card {
    transform: scale(1) translateY(0);
}

.surgical3d-modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(2, 6, 23, 0.5);
}

.surgical3d-modal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 10px;
}

.surgical3d-modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.surgical3d-modal-close:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #f87171;
}

.surgical3d-modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Microscopio Virtual H&E */
.surgical3d-microscope-view {
    flex: 1.65;
    background: #000000;
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
}
.surgical3d-microscope-img {
    position: absolute;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.05s ease-out;
}

.surgical3d-zoom-bar {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    gap: 5px;
    background: rgba(15, 23, 42, 0.85);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 5px;
    z-index: 10;
}
.surgical3d-zoom-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    padding: 5px 10px;
    font-size: 0.74rem;
    font-weight: 700;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}
.surgical3d-zoom-btn.active, .surgical3d-zoom-btn:hover {
    background: #0284c7;
    color: #ffffff;
}

.surgical3d-scale-box {
    position: absolute;
    bottom: 18px;
    right: 18px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 5px;
    color: #f1f5f9;
    font-size: 0.70rem;
    font-family: monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 10;
}
.surgical3d-scale-bar-line {
    width: 65px;
    height: 3px;
    background: #38bdf8;
    border-radius: 2px;
}

/* Panel Lateral Diagnóstico */
.surgical3d-meta-panel {
    flex: 1;
    padding: 22px;
    background: rgba(11, 19, 41, 0.75);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.surgical3d-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    width: fit-content;
}
.chip-green  { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.45); }
.chip-red    { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.45); }
.chip-cyan   { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.45); }
.chip-purple { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.45); }

.surgical3d-meta-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.surgical3d-meta-group label {
    font-size: 0.70rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.surgical3d-meta-group span, 
.surgical3d-meta-group p {
    font-size: 0.88rem;
    color: #e2e8f0;
    line-height: 1.45;
    margin: 0;
}

/* Responsivo para celulares */
@media (max-width: 768px) {
    .surgical3d-wrapper {
        min-height: 420px;
    }
    .surgical3d-modal-body {
        flex-direction: column;
    }
    .surgical3d-microscope-view {
        flex: 1.2;
        min-height: 250px;
    }
    .surgical3d-meta-panel {
        flex: 1;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 14px;
    }
}
