/* Estilos generales */
body {
    margin: 0;
    overflow: hidden;
    font-family: 'Roboto', Arial, sans-serif;
    touch-action: none; /* Prevenir comportamiento de desplazamiento predeterminado en dispositivos táctiles */
    -webkit-overflow-scrolling: touch; /* Mejor desplazamiento en iOS */
    position: fixed; /* Ayuda con problemas de desplazamiento en iOS */
    width: 100%;
    height: 100%;
    user-select: none; /* Evitar selección de texto al arrastrar */
    -webkit-user-select: none;
}

/* Pantalla de carga */
#app-loading,
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
    transition: opacity 0.5s ease;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Updated loading container with better spacing */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Style for percentage text */
#loading-percentage {
    font-size: 1.4em;
    font-weight: bold;
    margin-bottom: 8px;
}

/* Style for size information text */
#loading-size {
    font-size: 1.1em;
    opacity: 0.9;
}

#loading-progress {
    font-size: 1.2em;
    font-weight: bold;
}

/* Panel de información de edificios */
#building-info {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 350px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-height: calc(100vh - 250px); /* Increased space at bottom to avoid overlapping controls */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Mejorar desplazamiento en iOS */
}

#building-info h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #1a365d;
    font-size: 1.5em;
}

#building-info h4 {
    margin-top: 0;
    margin-bottom: 5px;
    color: #4890e9;
    font-size: 1.2em;
}

#building-info p {
    margin-bottom: 8px;
    line-height: 1.4;
}

#close-info-btn {
    margin-top: 15px;
    padding: 8px 16px;
    background-color: #3182ce;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#close-info-btn:hover {
    background-color: #2b6cb0;
}

/* Estilos mejorados para las reseñas */
.reviews-container {
    margin-top: 20px;
    border-top: 1px solid #e2e8f0;
    padding-top: 15px;
}

.review {
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 6px;
    color: #333333; /* Color de texto oscuro para todos los tipos de reseñas */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Sombra sutil para mejor definición */
}

.review-good {
    background-color: #dcfce7; /* Verde más vibrante */
    border-left: 4px solid #22c55e;
}

.review-neutral {
    background-color: #fef9c3; /* Amarillo más vibrante */
    border-left: 4px solid #eab308;
}

.review-bad {
    background-color: #fee2e2; /* Rojo más vibrante */
    border-left: 4px solid #ef4444;
}

.review-rating {
    font-weight: bold;
    margin-bottom: 5px;
}

.review-date {
    font-size: 0.8em;
    color: #4b5563; /* Gris más oscuro para mejor contraste */
    margin-bottom: 8px;
}

.review-comment {
    font-size: 0.9em;
    line-height: 1.5;
    max-height: 100px; /* Limiting height of individual comments */
    overflow-y: auto;
    color: #1f2937; /* Gris muy oscuro para el texto del comentario */
}

#reset-camera {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid #3498db; /* Añado contorno azul */
    padding: 10px 15px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    font-size: 14px; /* Tamaño base para escritorio */
}

#reset-camera:hover {
    background-color: rgba(0, 0, 0, 0.9);
    border-color: #2980b9; /* Cambio de color del contorno al pasar el ratón */
}

#position-panel {
    position: absolute;
    top: 70px; /* Posicionado debajo del botón de reset */
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid #3498db;
    padding: 10px 15px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    z-index: 100;
    min-width: 120px;
    font-size: 14px; /* Tamaño base para escritorio */
}

.position-row {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
}

.position-row span {
    margin-left: 10px;
    color: #3498db;
    font-weight: bold;
}

#mobile-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none; /* Oculto por defecto, se mostrará según el tamaño de pantalla */
    z-index: 100;
}

.control-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px; /* Aumentado espacio entre filas */
}

#mobile-controls button {
    width: 70px;
    height: 70px; 
    margin: 0 7px; /* Más espacio entre botones */
    font-size: 28px; /* Texto más grande */
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid #3498db;
    border-radius: 10px; /* Bordes más redondeados */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: manipulation; /* Mejora para táctil */
    -webkit-touch-callout: none; /* Previene el menú contextual en iOS */
    -webkit-tap-highlight-color: rgba(0,0,0,0); /* Eliminar highlight táctil */
    z-index: 150; /* Asegurar que estén por encima del canvas */
}

/* Mostrar controles en pantallas táctiles o pequeñas */
@media (max-width: 1024px) {
    #mobile-controls {
        display: block;
    }
}

/* Mostrar controles en pantallas grandes en la esquina inferior derecha */
@media (min-width: 1025px) {
    #mobile-controls {
        display: block;
        bottom: 20px;
        right: 20px;
    }
}

/* Reglas para pantallas pequeñas y dispositivos móviles */
@media (max-width: 768px) {
    #building-info {
        top: 15px;
        right: 15px;
        left: 15px; /* Expandir a la izquierda también */
        width: auto; /* Ancho automático para cubrir el espacio disponible */
        max-width: none;
        font-size: 16px; /* Texto más grande */
        max-height: calc(100vh - 200px); /* Even more space for mobile controls */
    }
    
    #building-info h3 {
        font-size: 1.8em; /* Título más grande */
    }
    
    #building-info h4 {
        font-size: 1.5em; /* Subtítulo más grande */
    }
    
    #building-info p {
        font-size: 1.1em;
        line-height: 1.6;
    }
    
    #close-info-btn {
        padding: 12px 20px; /* Botón de cerrar más grande */
        font-size: 16px;
        margin-top: 20px;
    }
    
    #reset-camera {
        padding: 14px 20px; /* Botón más grande */
        font-size: 16px;
    }
    
    #position-panel {
        padding: 14px 20px;
        font-size: 16px;
        top: 85px; /* Ajustar posición para evitar solapamiento */
    }
    
    .position-row {
        margin: 8px 0; /* Más espacio entre filas */
    }
    
    /* Controles móviles más grandes para pantallas táctiles */
    #mobile-controls {
        bottom: 25px;
        right: 25px;
    }
    
    #mobile-controls button {
        width: 80px; /* Botones más grandes en móvil */
        height: 80px;
        font-size: 32px;
    }
    
    /* Mayor espaciado entre botones para evitar tocar el incorrecto */
    .control-row {
        margin-bottom: 15px;
    }
    
    .review {
        padding: 15px; /* Más padding para las reseñas */
    }
    
    .review-rating, .review-date, .review-comment {
        font-size: 1.1em; /* Texto más grande */
    }
    
    .review-comment {
        font-size: 1.1em; /* Texto más grande */
        max-height: 120px; /* Slightly larger for mobile but still limited */
    }
}

/* Ajustes específicos para iPhone con pantallas pequeñas */
@media only screen and (max-device-width: 428px) and (orientation: portrait) {
    #mobile-controls {
        bottom: 40px; /* Más espacio desde abajo en iPhone */
    }
    
    #mobile-controls button {
        width: 85px; /* Aún más grandes para iPhone */
        height: 85px;
        font-size: 36px;
    }
}

/* Añadir indicador visual para canvas arrastrable */
canvas {
    touch-action: none; /* Asegurar que el canvas no procese gestos táctiles nativos */
    -webkit-tap-highlight-color: rgba(0,0,0,0); /* Eliminar highlight táctil */
    cursor: grab; /* Mostrar cursor de mano abierta por defecto */
}

canvas:active {
    cursor: grabbing; /* Mostrar cursor de mano cerrada al arrastrar */
}