*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #1a1a1a;
    font-family: 'Montserrat', sans-serif;
    color: white;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

.ui-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    pointer-events: none;
}

.project-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 1.8rem;
}

.project-title .title-text {
    font-weight: 700;
}

.project-title .title-icon {
    display: inline-flex;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

/* Escenario 3D */
#scene {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1500px; /* Profundidad */
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

#scene:active {
    cursor: grabbing;
}

#house {
    width: 400px;  /* Ajusta según el tamaño de tus croquis */
    height: 600px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(60deg) rotateZ(-20deg); /* Ángulo inicial */
    transition: transform 0.1s ease-out;
}

/* Las Plantas (Floors) */
.floor {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #4CAF50;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    /* Separación vertical entre plantas: 150px */
    transform: translateZ(calc(var(--i) * 180px));
    pointer-events: auto; /* Para poder clicar los botones */
}

.floor .map {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ajusta la imagen al contenedor */
    opacity: 0.9;
}

.label {
    position: absolute;
    top: -30px;
    left: 0;
    background: #4CAF50;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Los Puntos Calientes (Hotspots) */
.hotspot {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #ff5722;
    border-radius: 50%;
    border: 2px solid white;
    cursor: pointer;
    box-shadow: 0 0 10px #ff5722;
    animation: pulse 2s infinite;
    transform: translateZ(1px); /* Para que esté siempre encima de la foto */
}

.hotspot:hover {
    background: #ff9800;
    transform: scale(1.2) translateZ(1px);
}

.tooltip {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.hotspot:hover .tooltip {
    opacity: 1;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 87, 34, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 87, 34, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 87, 34, 0); }
}

/* Modal (Ventana emergente) */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 20px;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    position: relative;
    margin: 0 auto;
    padding: 20px;
    width: min(900px, calc(100vw - 40px));
    background: #222;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 30px rgba(0,0,0,0.5);
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #aaa;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover { color: white; }

.comparison-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.photo-box {
    flex: 1;
    min-width: 300px;
}

.photo-box img {
    width: 100%;
    height: 300px; /* Altura fija para uniformidad */
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #555;
}

.photo-box h3 {
    color: #4CAF50;
    margin-bottom: 10px;
}

.image-viewer {
    display: none;
    position: fixed;
    z-index: 300;
    inset: 0;
    padding: 20px;
    background: rgba(0,0,0,0.95);
    align-items: center;
    justify-content: center;
}

.image-viewer.show {
    display: flex;
}

.viewer-content {
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.viewer-content img {
    width: 100%;
    max-height: calc(90vh - 120px);
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.4);
}

.viewer-caption {
    font-size: 0.95rem;
    color: #ddd;
    text-align: center;
}

.viewer-close {
    position: absolute;
    top: -10px;
    right: 0;
    font-size: 36px;
    cursor: pointer;
    color: #fff;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.6);
    border: none;
    color: #fff;
    font-size: 40px;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
}

.viewer-prev { left: -50px; }
.viewer-next { right: -50px; }

.viewer-nav:active {
    transform: translateY(-50%) scale(0.95);
}

@media (max-width: 768px) {
    #scene {
        align-items: flex-start;
        padding-top: 100px;
    }

    #house {
        width: 90vw;
        height: 70vh;
        margin-top: 20px;
    }

    .ui-controls {
        width: auto;
        left: 20px;
        transform: none;
        text-align: left;
    }

    .ui-controls p,
    .project-title .title-text {
        display: none;
    }

    .project-title .title-icon {
        width: 56px;
        height: 56px;
        font-size: 2rem;
    }

    .comparison-container {
        flex-direction: column;
    }

    .photo-box img {
        height: auto;
        max-height: 40vh;
    }

    .modal-content {
        width: calc(100vw - 30px);
        max-width: none;
    }

    .viewer-content {
        max-width: 100%;
    }

    .viewer-content img {
        max-height: 70vh;
    }

    .viewer-prev {
        left: 10px;
    }

    .viewer-next {
        right: 10px;
    }

    .viewer-nav {
        font-size: 32px;
    }
}