/* Importación de Tipografía Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;600;700&display=swap');

/* Configuración Base del Documento */
body { 
    margin: 0; 
    padding: 0; 
    overflow: hidden; 
    font-family: 'Montserrat', sans-serif; /* Sistema Montserrat */
    font-weight: 300; /* Montserrat Light para cuerpo */
    color: #4D4D4D; /* Gris Técnico */
    background-color: #FFFFFF; /* Blanco Puro */
    display: flex; 
    flex-direction: column; 
    height: 100vh; 
}

/* Header y Elementos de la UI Superior */
#header-bar { 
    height: 60px; 
    background-color: #1A2B45; /* Azul Profundo */
    color: #FFFFFF; 
    display: flex; 
    align-items: center; 
    padding: 0 20px; 
    border-bottom: 3px solid #8CC63F; /* Verde Lima como acento inferior */
    z-index: 1001; 
    flex-shrink: 0; 
}

#header-bar .titles { 
    line-height: 1.2; 
    display: flex; 
    align-items: center; 
    gap: 20px; 
}

#header-bar h1 { 
    margin: 0; 
    font-family: 'Montserrat', sans-serif;
    font-weight: 700; /* Montserrat Bold */
    font-size: 1.2rem; 
    color: #FFFFFF; /* Blanco sobre Azul Profundo */
    display: flex; /* Añadido para alinear el logo perfectamente */
    align-items: center;
}

/* ============================================================
   NUEVO: AGREGADO DE LOGO/ÍCONO
   ============================================================ */
#header-bar h1::before {
    content: "";
    display: inline-block;
    width: 32px;  /* Ajusta el tamaño según prefieras */
    height: 32px;
    /* REEMPLAZA LA URL ABAJO POR TU ICONO (PNG o SVG) */
    background-image: url('https://img.icons8.com/?size=100&id=vxpEeK1ik6Dn&format=png&color=8cc63f'); 
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: 12px;
    vertical-align: middle;
}
/* ============================================================ */

#header-bar p { 
    margin: 0; 
    font-weight: 400; /* Montserrat Regular */
    font-size: 0.85rem; 
    color: #8CC63F; /* Verde Lima para destacar "Proyecto:" */
}

/* Selector de Proyectos (Generado por JS) */
#project-selector { 
    background: #FFFFFF; 
    color: #1A2B45; 
    border: 2px solid #8CC63F; /* Borde Verde Lima */
    padding: 5px 12px; 
    border-radius: 4px; 
    cursor: pointer; 
    outline: none;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

#project-selector:hover {
    background: #f0f0f0;
}

#project-selector option { 
    background: #FFFFFF; 
    color: #1A2B45; 
}

/* Contenedores de Potree */
.potree_container { 
    position: relative !important; 
    flex-grow: 1; 
    width: 100%; 
    overflow: hidden; 
    background-color: #000; /* El visor se mantiene negro para contraste LIDAR */
}

/* Footer y Créditos */
#footer-bar { 
    height: 35px; 
    background-color: #1A2B45; /* Azul Profundo */
    color: #FFFFFF; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 20px; 
    font-size: 0.75rem; 
    font-weight: 300;
    z-index: 1001; 
    flex-shrink: 0; 
}

#footer-bar a { 
    color: #8CC63F; /* Verde Lima Digital */
    text-decoration: none; 
    font-weight: 600;
}

#footer-bar a:hover {
    text-decoration: underline;
}

/* ============================================================
   SISTEMA DE AUTENTICACIÓN (SPLIT SCREEN LOGIN)
   ============================================================ */
#login-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: #FFFFFF;
    z-index: 9999; 
    display: flex;
}

#login-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Panel Izquierdo: Branding */
.login-brand-panel {
    flex: 1.2;
    background-color: #8CC63F; /* Tu color verde */
    background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.2) 0%, transparent 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: #FFFFFF;
    position: relative;
}

.brand-inner {
    max-width: 500px;
}

.login-logo-large {
    width: 100px;
    height: 100px;
    background-image: url('https://img.icons8.com/?size=100&id=vxpEeK1ik6Dn&format=png&color=ffffff'); /* Logo en blanco */
    background-size: contain;
    background-repeat: no-repeat;
    margin-bottom: 30px;
}

.login-brand-panel h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
}

.login-brand-panel p {
    font-size: 1.1rem;
    line-height: 1.6;
    opacity: 0.9;
    font-weight: 300;
}

.brand-footer {
    position: absolute;
    bottom: 40px;
    left: 60px;
    font-size: 0.8rem;
    opacity: 0.7;
    letter-spacing: 1px;
}

/* Panel Derecho: Formulario */
.login-form-panel {
    flex: 0.8;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

#login-box {
    width: 100%;
    max-width: 380px;
    text-align: left; /* Alineación a la izquierda para un look más moderno */
}

.form-header {
    margin-bottom: 40px;
}

.form-header h3 {
    font-size: 1.8rem;
    color: #1A2B45;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.form-header p {
    color: #888;
    font-size: 0.9rem;
    margin: 0;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1A2B45;
    margin-bottom: 8px;
    text-transform: uppercase;
}

#login-box input { 
    width: 100%; 
    padding: 15px; 
    background: #F8F9FA; 
    border: 2px solid #EEE; 
    color: #1A2B45; 
    border-radius: 8px; 
    box-sizing: border-box; 
    font-family: 'Montserrat', sans-serif;
    transition: all 0.3s ease;
}

#login-box input:focus {
    outline: none;
    border-color: #8CC63F;
    background: #FFF;
    box-shadow: 0 0 0 4px rgba(140, 198, 63, 0.1);
}

#login-box button { 
    width: 100%; 
    padding: 16px; 
    background: #1A2B45; /* Azul oscuro para el botón de acción para contraste */
    border: none; 
    color: #FFFFFF; 
    font-family: 'Montserrat', sans-serif;
    font-weight: 700; 
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 8px; 
    cursor: pointer; 
    margin-top: 10px; 
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(26, 43, 69, 0.2);
}

#login-box button:hover { 
    background: #253a5c; 
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(26, 43, 69, 0.3);
}

.form-footer {
    margin-top: 30px;
    text-align: center;
    border-top: 1px solid #EEE;
    padding-top: 20px;
}

.form-footer p {
    font-size: 0.8rem;
    color: #888;
    line-height: 1.5;
}

.form-footer a {
    color: #8CC63F;
    text-decoration: none;
    font-weight: 600;
}

/* Responsividad para móviles */
@media (max-width: 900px) {
    .login-brand-panel { display: none; }
    .login-form-panel { flex: 1; }
}

/* Área de Usuario Logueado */
#user-info { 
    display: none; 
    color: #FFFFFF; 
    font-size: 0.85rem; 
    margin-left: auto; 
    align-items: center; 
}

#user-email {
    font-weight: 400;
    margin-right: 15px;
}

#logout-btn { 
    background: transparent; 
    border: 1.5px solid #8CC63F; 
    color: #8CC63F; 
    padding: 6px 15px; 
    border-radius: 4px; 
    cursor: pointer; 
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

#logout-btn:hover { 
    background: #8CC63F; 
    color: #1A2B45; 
}

.login-logo {
    width: 64px; 
    height: 64px;
    background-image: url('https://img.icons8.com/?size=100&id=vxpEeK1ik6Dn&format=png&color=8cc63f'); 
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin: 0 auto 20px auto; 
}
/* ============================================================
   PERSONALIZACIÓN INTERNA DE POTREE (BRANDING)
   ============================================================ */

/* 1. Fondo del contenedor lateral y fuentes */
#potree_sidebar_container, 
.potree_menu,
.jstree-menu {
    background-color: #1A2B45 !important; /* Azul Profundo */
    color: #FFFFFF !important;
    font-family: 'Montserrat', sans-serif !important;
}

/* 2. Encabezados de secciones (Acordeones) */
.potree_sidebar_section_header {
    background-color: #121f32 !important; /* Azul más oscuro para contraste */
    color: #8CC63F !important; /* Verde Lima Digital */
    font-weight: 600 !important;
    border-bottom: 1px solid #4D4D4D !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 3. Personalización de Iconos (Filtro para color Verde Lima) */
.potree_sidebar_section_header img, 
#potree_quick_buttons img,
.potree_toolbar_item img {
    filter: invert(72%) sepia(54%) saturate(464%) hue-rotate(43deg) brightness(93%) contrast(89%) !important;
}

/* 4. Sliders e Inputs dentro del menú */
input[type=range] {
    accent-color: #8CC63F !important; /* El color del control deslizante */
}

input[type=text], select {
    background: #FFFFFF !important;
    color: #1A2B45 !important;
    border-radius: 3px !important;
    border: none !important;
}

/* 5. Botones de herramientas rápidas */
.potree_short_description {
    color: #8CC63F !important;
    font-weight: bold !important;
}

/* 6. Scrollbar (Barra de desplazamiento) estilo técnico */
#potree_sidebar_container::-webkit-scrollbar {
    width: 6px;
}

#potree_sidebar_container::-webkit-scrollbar-track {
    background: #1A2B45;
}

#potree_sidebar_container::-webkit-scrollbar-thumb {
    background: #4D4D4D; /* Gris Técnico */
    border-radius: 10px;
}

#potree_sidebar_container::-webkit-scrollbar-thumb:hover {
    background: #8CC63F; /* Resalta en Verde al interactuar */
}

/* 7. Eliminar bordes innecesarios y modernizar */
.potree_sidebar_section_content {
    background-color: #1A2B45 !important;
    border: none !important;
}

/* Ajuste para que los textos de las listas (jstree) sean legibles */
.jstree-anchor, .jstree-text {
    color: #FFFFFF !important;
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 300 !important;
}

.jstree-clicked {
    background: rgba(140, 198, 63, 0.3) !important; /* Fondo verde suave al seleccionar */
    border-radius: 4px;
}

/* ============================================================
   CORRECCIÓN Y LIMPIEZA DE INTERFAZ (VERSIÓN SEGURA)
   ============================================================ */

/* 1. Ocultar específicamente los enlaces de potree y redes sociales */
#potree_sidebar_container a[href*="potree.org"],
#potree_sidebar_container a[href*="github.com"],
#potree_sidebar_container a[href*="twitter.com"],
#potree_sidebar_container .potree_version {
    display: none !important;
}

/* Ocultar la selección de idiomas sin romper el layout */
.potree_language_selection {
    display: none !important;
}

/* 2. Asegurar que el contenedor del menú sea visible y use tu paleta */
#potree_sidebar_container {
    display: block !important; 
    background-color: #1A2B45 !important; /* Azul Profundo */
    opacity: 1 !important;
    visibility: visible !important;
}

/* 3. Resaltar el nombre del proyecto con Montserrat Bold */
#current-project {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700 !important; 
    font-size: 1.1rem;
    color: #8CC63F; /* Verde Lima Digital */
    text-transform: uppercase;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5); /* Mejora lectura sobre fondos oscuros */
}

/* 4. Modernizar botones internos (Show/Hide, Clipping, etc.) */
.potree_container input[type="button"], 
.potree_container button {
    background-color: #FFFFFF !important;
    border: 2px solid #8CC63F !important; /* Verde Lima */
    color: #1A2B45 !important; /* Azul Profundo */
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 600 !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    cursor: pointer;
    margin-bottom: 2px !important;
}

.potree_container input[type="button"]:hover {
    background-color: #8CC63F !important;
    color: #FFFFFF !important;
}

/* 5. Estilizar el botón de toggle (Hamburguesa) para que no se pierda */
#potree_menu_toggle {
    background-color: #1A2B45 !important;
    border: 2px solid #8CC63F !important;
    border-radius: 5px !important;
    padding: 5px !important;
}

/* ============================================================
   VERSIÓN CORREGIDA: PERSONALIZACIÓN DE BARRA LATERAL
   ============================================================ */

/* 1. ASEGURAR VISIBILIDAD (Evita que el panel desaparezca) */
#potree_sidebar_container {
    display: flex !important; 
    flex-direction: column !important;
    background-color: #1A2B45 !important; /* Azul Profundo */
    visibility: visible !important;
}

/* 2. OCULTAR ELEMENTOS NO DESEADOS (Selectores específicos) */
.potree_language_selection, 
.potree_sidebar_section_header ~ div[style*="font-size: 80%"],
#potree_sidebar_container a[href*="potree.org"],
#potree_sidebar_container a[href*="github.com"] {
    display: none !important;
}

/* 3. TIPOGRAFÍA Y TEXTOS */
#potree_sidebar_container * {
    font-family: 'Montserrat', sans-serif !important;
}

/* Títulos de secciones (Apariencia, Herramientas, etc.) */
.potree_sidebar_section_header {
    background-color: rgba(255, 255, 255, 0);
}

/* ============================================================
   GUÍA DE USO Y VENTANA MODAL (OPTIMIZADA Y CORREGIDA)
   ============================================================ */

/* Botón de Ayuda en el Header */
#guide-btn {
    background: transparent !important;
    border: 1.5px solid #8CC63F !important;
    color: #8CC63F !important;
    padding: 6px 15px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    margin-right: 15px !important;
    transition: all 0.3s ease !important;
    display: inline-block !important;
}

#guide-btn:hover {
    background: #8CC63F !important;
    color: #1A2B45 !important;
}

/* Overlay - CORRECCIÓN: display: none inicial para evitar apertura automática */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(26, 43, 69, 0.96) !important;
    display: none; /* JS se encarga de cambiar a 'flex' al abrir */
    justify-content: center !important;
    align-items: center !important;
    z-index: 100000 !important;
}

/* Caja de Contenido - Espaciado Mejorado */
.modal-content {
    background: #FFFFFF !important;
    padding: 30px 35px !important; /* Más aire interno */
    border-radius: 12px !important;
    max-width: 480px !important;
    width: 90% !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5) !important;
    border-top: 6px solid #8CC63F !important;
    font-family: 'Montserrat', sans-serif !important;
    text-align: left !important;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-content h3 {
    color: #1A2B45 !important;
    margin-top: 0 !important;
    font-weight: 700 !important;
    font-size: 1.2rem !important; /* Unificado */
    margin-bottom: 25px !important;
    text-align: center;
}

/* Secciones internas - Fuentes unificadas a 0.85rem y 0.95rem */
.guide-section {
    margin-bottom: 20px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    padding-bottom: 12px !important;
}

.guide-section:last-of-type {
    border-bottom: none !important;
}

.guide-section h4 {
    color: #1A2B45 !important;
    margin-bottom: 8px !important;
    font-weight: 700 !important;
    font-size: 0.95rem !important; /* Unificado */
    text-transform: uppercase !important;
}

.guide-section p, 
.guide-section ul, 
.guide-section ol, 
.guide-section li {
    font-size: 0.85rem !important; /* Unificado con el resto del sitio */
    color: #4D4D4D !important;
    line-height: 1.6 !important; /* Mejor legibilidad */
    margin-bottom: 4px !important;
}

.guide-section ul, 
.guide-section ol {
    padding-left: 18px !important;
}

/* Botón ENTENDIDO */
.close-guide {
    width: 100% !important;
    padding: 14px !important;
    background: #8CC63F !important;
    border: none !important;
    color: #FFFFFF !important;
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    margin-top: 10px !important;
    transition: background 0.3s ease !important;
}

.close-guide:hover {
    background: #7ab332 !important;
}

/* Estilo para el Modal de Ética Profesional */
.dev-box {
    border-top: 6px solid #1A2B45 !important; /* Azul para transmitir seriedad */
    max-width: 500px !important;
}

.dev-message p {
    font-size: 0.85rem !important;
    line-height: 1.6 !important;
    color: #4D4D4D !important;
    margin-bottom: 15px !important;
}

.highlight-text {
    background: #f4f8f0; /* Un verde muy tenue de fondo */
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #8CC63F; /* Tu verde lima */
    font-style: italic;
}

.dev-contact-button {
    display: inline-block;
    padding: 10px 20px;
    border: 1.5px solid #8CC63F;
    color: #8CC63F;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.75rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.dev-contact-button:hover {
    background: #8CC63F;
    color: #FFFFFF;
}

/* ============================================================
   SISTEMA DE INTERCAMBIO DE VISORES (SWITCH)
   ============================================================ */
#view-toggle {
    display: none; /* Se activa por JS si el proyecto lo permite */
    align-items: center;
    background: #121f32;
    border-radius: 6px;
    padding: 3px;
    margin-left: 15px;
    border: 1px solid #4D4D4D;
}

.toggle-btn {
    background: transparent;
    color: #FFFFFF;
    border: none;
    padding: 6px 12px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: #8CC63F;
    color: #1A2B45;
}

/* ============================================================
   CONTENEDOR DEL VISOR RASTER (DEM)
   ============================================================ */
#raster-container {
    display: none; /* Oculto por defecto, Potree es prioridad */
    flex-grow: 1;
    width: 100%;
    position: relative;
    background: #0b1624;
}

#map {
    width: 100%;
    height: 100%;
    background: #0b1624;
}

/* Pantalla de Carga Raster */
#loader-raster {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #0b1624;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    transition: opacity 0.5s ease;
}

#loader-raster .spinner {
    width: 50px; height: 50px;
    border: 5px solid #1a2a3a;
    border-top: 5px solid #8CC63F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Contenedor de Controles a la Derecha */
.right-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 200px;
    pointer-events: none;
}

/* Estilo Unificado para Paneles DEM */
.custom-panel {
    background: rgba(26, 43, 69, 0.9) !important;
    color: white !important;
    padding: 12px 15px !important;
    border-radius: 8px !important;
    border: 1px solid #8CC63F !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    backdrop-filter: blur(8px);
    pointer-events: auto;
}

.panel-label {
    font-size: 0.7rem;
    color: #8CC63F;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    font-weight: 700;
}

.panel-value { font-size: 1.3rem; font-family: monospace; font-weight: bold; }

/* Estilos Leyenda Inyectada */
.legend-item { display: flex; align-items: center; margin-bottom: 5px; font-size: 0.75rem; }
.legend-color { width: 14px; height: 14px; margin-right: 8px; border: 1px solid rgba(255,255,255,0.2); border-radius: 2px; }

#reset-measure {
    background: #8CC63F; color: #1A2B45; border: none;
    padding: 6px; border-radius: 4px; cursor: pointer;
    font-weight: bold; font-size: 0.65rem; margin-top: 10px; width: 100%;
    text-transform: uppercase;
    transition: background 0.3s ease;
}

#reset-measure:hover { background: #b4e674; }
