/* --- THE LABORATORY OVERLAY --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 3, 10, 0.95);
    backdrop-filter: blur(15px);
    z-index: 2000;
    display: none; /* Hidden by default */
    align-items: center; justify-content: center;
    transition: all 0.5s ease;
}

.modal-container {
    width: 90%; max-width: 1200px;
    background: #050505;
    border: 1px solid rgba(0, 212, 255, 0.2);
    position: relative;
    padding: 60px 40px;
}

.close-modal {
    position: absolute; top: 20px; right: 20px;
    background: none; border: none; color: #fff;
    font-size: 30px; cursor: pointer; opacity: 0.5;
}

.modal-content { display: flex; gap: 40px; }

/* Sidebar HUD Styling */
.modal-sidebar { width: 250px; flex-shrink: 0; border-right: 1px solid rgba(255,255,255,0.1); }
.spec-group { margin-bottom: 30px; }
.spec-label { font-size: 10px; text-transform: uppercase; color: #00d4ff; letter-spacing: 2px; }
.modal-sidebar h4 { color: #fff; font-family: monospace; margin-top: 5px; }

.status-glow { color: #00ff88 !important; text-shadow: 0 0 10px #00ff88; }

/* The Viewer Area */
.modal-viewer { flex-grow: 1; position: relative; }
.viewer-controls { margin-bottom: 20px; display: flex; gap: 15px; }
.view-toggle { 
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    color: #888; padding: 8px 15px; font-size: 11px; cursor: pointer;
}
.view-toggle.active { border-color: #00d4ff; color: #00d4ff; }

.image-wrapper { position: relative; overflow: hidden; aspect-ratio: 16/9; }
#modal-img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s; }

.xray-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: none; background: rgba(0, 71, 171, 0.1);
    align-items: center; justify-content: center;
}
/* Ensure the SVG inside the modal fits perfectly and glows */
#modal-xray-svg svg {
    width: 50%; /* Or whatever fits your design */
    height: auto;
    filter: drop-shadow(0 0 20px #00d4ff);
    transition: all 0.5s ease;
}

/* Add a subtle scan-line effect to the X-Ray mode */
.xray-overlay::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 50%,
        rgba(0, 212, 255, 0.05) 51%
    );
    background-size: 100% 4px;
    pointer-events: none;
}

/* --- LABORATORY MOBILE REFINEMENT --- */
@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        padding: 40px 20px 20px 20px; /* Reduced padding */
        max-height: 90vh;
        overflow-y: auto; /* Allows scrolling inside the modal if content is long */
    }

    .modal-content {
        flex-direction: column; /* Stacks sidebar on top of image */
        gap: 30px;
    }

    .modal-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 20px;
        display: grid;
        grid-template-columns: 1fr 1fr; /* Two-column grid for specs to save space */
        gap: 15px;
    }

    .spec-group {
        margin-bottom: 0;
    }

    .spec-label {
        font-size: 8px; /* Slightly smaller for mobile */
    }

    .modal-sidebar h4 {
        font-size: 13px;
    }

    /* Viewer Adjustments */
    .modal-viewer {
        width: 100%;
    }

    .viewer-controls {
        justify-content: center;
        flex-wrap: wrap; /* Prevents buttons from cutting off */
    }

    .view-toggle {
        padding: 6px 12px;
        font-size: 10px;
        flex: 1; /* Makes buttons equal width on mobile */
        text-align: center;
    }

    .image-wrapper {
        aspect-ratio: 4 / 3; /* Better fit for mobile portrait viewing */
    }

    #modal-xray-svg svg {
        width: 80%; /* Larger percentage on mobile to be legible */
    }
    .close-modal {
    padding: 10px; /* Bigger tap target */
    z-index: 2001; /* Ensure it stays on top */
    }
}

/* Fix for very small screens (iPhone SE, etc) */
@media (max-width: 480px) {
    .modal-sidebar {
        grid-template-columns: 1fr; /* Single column for very narrow phones */
    }
}