/* =========================================
   1. VARIABLES Y RESET
   ========================================= */
:root {
    --uaem-verde: #1B5E20;
    --uaem-dorado: #9E8B39;
    --uaem-negro: #1a1a1a;
    --blanco: #ffffff;
    --gris-fondo: #f5f5f5;
}

html {
    height: 100%; /* VITAL: Define la altura base */
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Segoe UI', sans-serif; 
}

body { 
    display: flex; 
    flex-direction: column; 
    min-height: 100vh; 
    background-color: var(--uaem-negro);
    
    /* Evita selección y resaltado en móviles */
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* =========================================
   2. HEADER
   ========================================= */
header {
    background-color: var(--uaem-verde);
    color: var(--blanco);
    padding: 0 1.5rem;
    border-bottom: 4px solid var(--uaem-dorado);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    height: 70px; 
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.logo-area { display: flex; align-items: center; gap: 12px; }
.uaem-logo { height: 45px; width: auto; }
.logo-secundario { height: 35px; width: auto; }
.logo-dark-fix { filter: brightness(0) invert(1); opacity: 0.95; }

header h1 { 
    font-size: 1.1rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    margin-left: 10px; 
    letter-spacing: 0.5px;
}
.detalle-2d { font-weight: 300; opacity: 0.8; font-size: 0.9em; }

.btn-home-simple { 
    color: var(--blanco); 
    font-size: 1.2rem; 
    text-decoration: none; 
    transition: 0.3s; 
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 5px;
    background: rgba(255,255,255,0.1);
}
.btn-home-simple:hover { background: rgba(255,255,255,0.2); }
.btn-home-simple span { font-size: 0.9rem; }

/* =========================================
   3.1 BARRA DE INSTRUCCIONES (ESTILO IMAGEN)
   ========================================= */
.barra-instrucciones {
    background-color: var(--uaem-negro);
    padding: 10px 20px;
    transition: all 0.5s ease;
    max-height: 200px; 
    overflow: hidden;
    flex-shrink: 0; /* Evita que se aplaste */
    border-bottom: 1px solid #333;
    z-index: 900;
}

.barra-instrucciones.oculta {
    max-height: 0; padding: 0 20px; opacity: 0; border: none;
}

.contenido-barra {
    background-color: white;
    max-width: 1000px; margin: 0 auto;
    border-left: 6px solid var(--uaem-verde);
    border-radius: 6px;
    padding: 15px 20px;
    display: flex; align-items: center; gap: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.icono-barra {
    background-color: var(--uaem-verde); color: white;
    width: 45px; height: 45px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}

.texto-barra h3 { color: var(--uaem-verde); font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.texto-barra p { font-size: 0.95rem; color: #555; margin: 0; line-height: 1.3; }

.btn-cerrar-barra {
    margin-left: auto; background: none; border: none;
    color: #aaa; font-size: 1.2rem; cursor: pointer; padding: 5px;
}
.btn-cerrar-barra:hover { color: red; }


/* =========================================
   3. PRELOADER
   ========================================= */
#preloader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

#preloader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-logo { width: 90px; margin-bottom: 20px; animation: pulseLogo 1.5s infinite ease-in-out; }
.loader-circle {
    width: 40px; height: 40px;
    margin: 0 auto 15px auto;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--uaem-dorado);
    border-radius: 50%;
    animation: spinCircle 1s linear infinite;
}
.loader-content p { color: #666; font-size: 0.9rem; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; }

@keyframes spinCircle { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulseLogo { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.05); opacity: 0.8; } 100% { transform: scale(1); opacity: 1; } }

/* =========================================
   4. CONTENEDOR PRINCIPAL (VISOR)
   ========================================= */
.contenedor-visor {
    position: relative;
    width: 100%;
    height: calc(100vh - 70px); 
    background-color: #000; 
    overflow: hidden; 
    display: flex; 
}

#panorama {
    width: 100%;
    height: 100%;
    z-index: 1;
    touch-action: none; 
}

/* --- TAPA EN PC (GRANDE) --- */
.tapa-polo {
    width: 500px;  
    height: 500px;
    
    background-image: url('recursos/fondo.jpg'); 
    background-size: cover; 
    background-position: center;
    background-repeat: no-repeat;
    
    border-radius: 50%; 
    border: 10px solid var(--uaem-dorado); 
    
    pointer-events: none;
    display: block !important; opacity: 1 !important;
    
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

/* =========================================
   5. BOTONES FLOTANTES (GYRO, INFO, PLAY)
   ========================================= */

/* Botón Giroscopio (Switch) */
.btn-flotante-gyro {
    display: none; 
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(4px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 8px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    align-items: center; 
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.btn-flotante-gyro.gyro-on {
    background: var(--uaem-dorado); 
    color: #1a1a1a; 
    border-color: var(--uaem-dorado);
    box-shadow: 0 0 15px rgba(158, 139, 57, 0.6); 
}
.btn-flotante-gyro:hover { transform: translateX(-50%) scale(1.05); }

/* --- NUEVO: GRUPO FLOTANTE (INFO & PLAY) --- */
.grupo-flotante {
    position: absolute;
    bottom: 30px; 
    right: 30px;  
    display: flex;
    flex-direction: column; /* Apilados */
    gap: 15px;
    z-index: 20;
}

.btn-round {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.btn-round:hover {
    background-color: var(--uaem-verde);
    border-color: var(--uaem-verde);
    transform: scale(1.1);
}

/* Animación para cuando el Auto-Tour está activo */
.btn-round.tour-activo {
    background-color: var(--uaem-dorado);
    border-color: var(--uaem-dorado);
    color: #000;
    animation: pulseTour 2s infinite;
}

@keyframes pulseTour {
    0% { box-shadow: 0 0 0 0 rgba(158, 139, 57, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(158, 139, 57, 0); }
    100% { box-shadow: 0 0 0 0 rgba(158, 139, 57, 0); }
}

/* =========================================
   6. VENTANA MODAL (POP-UP INFORMACIÓN)
   ========================================= */
.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 300;
    display: flex; justify-content: center; align-items: center;
    opacity: 1; visibility: visible;
    transition: all 0.4s ease;
}

.modal-overlay.hidden {
    opacity: 0; visibility: hidden; pointer-events: none;
}

.modal-content {
    background: white;
    width: 90%; max-width: 450px;
    padding: 30px;
    border-radius: 15px;
    border-top: 6px solid var(--uaem-dorado);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    text-align: center;
    transform: translateY(0) scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(50px) scale(0.9);
}

.btn-cerrar-modal {
    position: absolute;
    top: 10px; right: 15px;
    background: none; border: none;
    font-size: 1.5rem; color: #999;
    cursor: pointer; transition: 0.3s;
}
.btn-cerrar-modal:hover { color: red; transform: rotate(90deg); }

.icono-modal { font-size: 3rem; color: var(--uaem-dorado); margin-bottom: 10px; }
#modal-titulo { color: var(--uaem-verde); font-size: 1.4rem; margin-bottom: 10px; }
#modal-texto { font-size: 1rem; color: #555; line-height: 1.6; }

/* =========================================
   7. CONTROLES DE NAVEGACIÓN (PC)
   ========================================= */
.controles-navegacion {
    position: absolute;
    top: 20px; right: 20px;
    width: 240px;
    background: rgba(255, 255, 255, 0.95);
    padding: 0; 
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    z-index: 100;
    max-height: 80%;
    overflow: hidden; 
    display: flex;
    flex-direction: column;
}

.header-controles {
    background: var(--uaem-verde);
    padding: 12px 15px;
    color: white;
}
.header-controles h3 { font-size: 1rem; margin: 0; display: flex; align-items: center; gap: 8px; }

.lista-botones {
    padding: 10px;
    overflow-y: auto; 
    max-height: 400px;
}

.btn-escena { 
    display: block; 
    width: 100%; 
    padding: 12px 15px; 
    margin-bottom: 8px; 
    background: white; 
    border: 1px solid #eee; 
    border-radius: 8px; 
    cursor: pointer; 
    text-align: left; 
    transition: 0.2s;
    font-size: 0.95rem;
    color: #444;
    display: flex; align-items: center; gap: 10px;
}
.btn-escena i { color: var(--uaem-verde); opacity: 0.7; }
.btn-escena:hover { background-color: #f0f0f0; transform: translateX(3px); }
.btn-escena.activo { 
    background-color: var(--uaem-verde); 
    color: white; 
    border-color: var(--uaem-verde); 
    box-shadow: 0 2px 8px rgba(27, 94, 32, 0.3);
}
.btn-escena.activo i { color: var(--uaem-dorado); opacity: 1; }

/* =========================================
   8. FOOTER
   ========================================= */
footer {
    background-color: var(--uaem-negro);
    color: #e0e0e0;
    border-top: 5px solid var(--uaem-dorado);
    padding-top: 2rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1000px; margin: 0 auto;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 3rem;
    padding: 0 1rem 2rem 1rem;
}
.footer-col h4 { color: var(--uaem-dorado); font-size: 1.1rem; margin-bottom: 1rem; text-transform: uppercase; }
.footer-link { display: flex; align-items: center; gap: 10px; color: #bbb; text-decoration: none; margin-bottom: 10px; transition: 0.3s; }
.footer-link:hover { color: var(--uaem-dorado); }
.footer-copyright { background-color: #111; text-align: center; padding: 1rem; border-top: 1px solid #333; font-size: 0.85rem; color: #666; }

/* =========================================
   9. RESPONSIVE / MÓVIL (CORRECCIONES FINALES)
   ========================================= */
@media (max-width: 768px) {
    
    .btn-flotante-gyro { display: flex; }

    header { height: 60px; padding: 0.5rem 1rem; }
    .uaem-logo { height: 32px; }
    .logo-secundario { height: 28px; }
    header h1 { display: none; } 
    .btn-home-simple span { display: none; } 

    .contenedor-visor { 
        flex-direction: column; 
        height: calc(100vh - 60px); 
    }

    #panorama {
        position: relative;
        flex-grow: 1; 
        height: auto; 
        width: 100%;
    }

    /* --- CORRECCIÓN TAMAÑO TAPA (CELULAR) --- */
    .tapa-polo {
        /* 150px para que no tape la foto */
        width: 150px !important;  
        height: 150px !important;
        border-width: 4px; 
    }

    /* --- NUEVO: POSICIÓN DE BOTONES FLOTANTES EN MÓVIL --- */
    .grupo-flotante {
        /* Los subimos para que no queden detrás del menú deslizable */
        bottom: 140px; 
        right: 15px;
    }
    .btn-round { width: 45px; height: 45px; font-size: 1rem; }

    /* CONTENEDOR BOTONES (MENU ABAJO) */
    .controles-navegacion {
        position: relative;
        top: auto; right: auto; bottom: auto; left: auto;
        
        width: 100%; 
        max-width: 100vw;
        max-height: none;
        
        border-radius: 0;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
        background: #fff;
        z-index: 102;
        padding-bottom: env(safe-area-inset-bottom);
        
        display: block; 
        overflow: hidden; 
    }

    .header-controles {
        padding: 8px 15px;
        text-align: center;
        border-bottom: 1px solid #eee;
    }
    .header-controles h3 { justify-content: center; font-size: 0.9rem; }

    /* =========================================
   BARRA DE INSTRUCCIONES (SECCIÓN FIJA)
   ========================================= */
.barra-instrucciones {
    background-color: var(--uaem-negro); /* Fondo oscuro detrás de la tarjeta */
    padding: 10px 20px;
    /* Animación al cerrar */
    transition: all 0.5s ease;
    max-height: 150px; /* Altura máxima para la animación */
    overflow: hidden;
}

/* Estado oculto (para JS) */
.barra-instrucciones.oculta {
    max-height: 0;
    padding: 0 20px;
    opacity: 0;
}

/* La "Tarjeta" visual */
.contenido-barra {
    background-color: white;
    max-width: 1000px;
    margin: 0 auto;
    
    /* ESTILO DE TU IMAGEN */
    border-left: 6px solid var(--uaem-verde);
    border-radius: 6px;
    padding: 15px 20px;
    
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.icono-barra {
    background-color: var(--uaem-verde);
    color: white;
    width: 45px; height: 45px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.texto-barra h3 {
    color: var(--uaem-verde);
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.texto-barra p {
    font-size: 0.95rem;
    color: #555;
    margin: 0;
    line-height: 1.3;
}

.btn-cerrar-barra {
    margin-left: auto; /* Empuja la X a la derecha */
    background: none; border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}
.btn-cerrar-barra:hover { color: red; }

/* =========================================
   AJUSTE AL VISOR (IMPORTANTE)
   ========================================= */
.contenedor-visor {
    width: 100%;
    /* ANTES: height: calc(100vh - 70px);  <-- BORRAR O COMENTAR ESTO */
    
    /* AHORA: Usamos Flex para que se adapte si hay barra o no */
    flex: 1; 
    
    background-color: #000; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column;
    min-height: 0; /* Vital para Firefox/Flexbox */
}

/* =========================================
   RESPONSIVE (CELULAR)
   ========================================= */
@media (max-width: 768px) {
    .barra-instrucciones { padding: 10px; }
    
    .contenido-barra {
        padding: 12px;
        align-items: flex-start; /* Alinear arriba si el texto es largo */
    }
    
    .icono-barra { width: 35px; height: 35px; font-size: 1rem; margin-top: 3px; }
    .texto-barra h3 { font-size: 1rem; }
    .texto-barra p { font-size: 0.85rem; }
}

    /* LISTA HORIZONTAL (SCROLL FUNCIONAL) */
    .lista-botones {
        display: flex;       
        flex-direction: row; 
        flex-wrap: nowrap;   
        
        overflow-x: auto;    
        overflow-y: hidden;
        
        width: 100%;
        gap: 15px;
        padding: 15px;
        background: #f9f9f9;
        
        justify-content: flex-start;
        align-items: center;

        -webkit-overflow-scrolling: touch; 
        pointer-events: auto; 
    }

    .lista-botones::-webkit-scrollbar { height: 4px; }
    .lista-botones::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

    /* BOTONES (TARJETAS) */
    .btn-escena {
        flex: 0 0 auto;     
        width: auto !important; /* CLAVE */
        
        min-width: 140px;    
        max-width: 200px;    
        
        margin-bottom: 0;
        font-size: 0.85rem;
        padding: 10px 15px;
        white-space: normal; 
        
        display: flex;
        align-items: center;
        justify-content: center;
        
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    footer { display: none; } 
}