/* --- Estilos Globales (Prevent Pull-to-Refresh & App Shell) --- */
html,
body {
    height: 100%;
    /* Fallback */
    height: 100dvh;
    /* Dynamic Viewport Height for Mobile */
    margin: 0;
    padding: 0;
    overscroll-behavior-y: none;
    overflow: hidden;
    /* Prevent body scroll, everything inside mobile-container */
}

/* --- Estilos Generales --- */
.screen {
    display: none;
    height: 100%;
    /* Force screen to take full container height */
    overflow: hidden;
    /* Prevent screen itself from scrolling, inner divs handle it */
}

.screen.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

@media (max-width: 768px) {
    body {
        background-color: #f3f4f6;
    }

    .mobile-container {
        height: 100%;
        width: 100%;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
        /* Ensure no leak */
        display: flex;
        flex-direction: column;
    }
}

/* Fix for Desktop: Restore min-height for the container so it doesn't collapse */
@media (min-width: 769px) {
    .mobile-container {
        height: 95vh;
        max-height: 95vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
}

/* --- Estilos del Mapa --- */
#screenAssessment {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#visitMapContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-color: #2c3e50;
    /* Fondo oscuro para transición suave al satélite */
}

#visitMap {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Overlay de carga del mapa */
#mapLoaderOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 1);
    z-index: 4000;
    /* Encima de todo */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Estado del GPS (Flotante arriba izquierda) */
.map-status {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 3000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    font-family: monospace;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: block !important;
}

/* Controles Flotantes (Botones abajo) */
.floating-controls {
    position: fixed;
    bottom: 40px;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: none;
    /* Permite hacer clic en el mapa a los lados */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Botón Terminar Visita */
.finish-btn-styled {
    pointer-events: auto;
    background-color: #dc2626;
    /* Rojo */
    color: white;
    padding: 14px 28px;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 2px solid white;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.1s active;
}

.finish-btn-styled:active {
    transform: scale(0.95);
    background-color: #b91c1c;
}

/* Botón Recentrar (Diana) */
.recenter-btn {
    pointer-events: auto;
    background-color: white;
    color: #333;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid #ccc;
}

.recenter-btn:active {
    background-color: #f3f4f6;
}

/* --- Robust Spinner Fix --- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.rounded-full {
    border-radius: 9999px !important;
}

.border-4 {
    border-width: 4px !important;
}

/* Fallback for spinner border colors if Tailwind fails or is overridden */
/* FORCE SPINNER FIX (Aggressive Override) */
#historySpinner,
#reportSpinner {
    /* display: block !important; REMOVED */
    width: 48px !important;
    height: 48px !important;
    border: 4px solid #e5e7eb !important;
    border-top: 4px solid #3b82f6 !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
    margin: 2rem auto !important;
    animation: spin 1s linear infinite;
}