html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

/* Aplicación */
#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    font-family: Arial, sans-serif;
    background: #eef2f5;
}

/* Panel lateral */
#sidebar {
    width: 340px;
    background: #ffffff;
    border-right: 1px solid #cfd6dd;
    display: flex;
    flex-direction: column;
    box-shadow: 3px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* Logo */
#logo {
    background: #1f4e79;
    color: white;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icono {
    height: 44px;
    width: auto;
    padding: 4px;
    background: #ffffff;
    border-radius: 5px;
}

#logo h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: 1px;
}

#logo p {
    margin: 2px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

/* Bloques */
.bloque{

    padding:16px;

    border-top:2px solid #c7d2dc;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.9),
        0 -1px 2px rgba(0,0,0,.04);

}

.bloque label {
    display: block;
    padding: 6px 0;
    font-size: 14px;
    cursor: pointer;
}

#buscador {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid #cfd6dd;
    border-radius: 5px;
    font-size: 14px;
}

/* Zona mapa */
#main {
    flex: 1;
    position: relative;
}

#mapa {
    width: 100%;
    height: 100%;
}

/* Ficha de punto kilométrico */
.ficha-pk-panel h3 {
    margin: 0 0 10px 0;
    color: #1f4e79;
    font-size: 20px;
}

.ficha-pk-panel p {
    margin: 6px 0;
    font-size: 14px;
}
/* =========================================================
   ÁRBOL DE CAPAS
   ========================================================= */

.bloque-capas {
    padding: 14px 12px;
}

/* Cada grupo plegable */
.grupo-capas {
    margin-bottom: 7px;
    border: 1px solid #dce3e9;
    border-radius: 5px;
    overflow: hidden;
    background: #ffffff;
}

/* Cabecera del grupo */
.grupo-capas summary {
    display: flex;
    align-items: center;
    gap: 7px;

    padding: 9px 10px;
    background: #edf3f7;
    color: #234f78;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;
    user-select: none;
    list-style: none;
}

/* Oculta el triángulo automático del navegador */
.grupo-capas summary::-webkit-details-marker {
    display: none;
}

/* Flecha personalizada */
.flecha-grupo::before {
    content: "▶";
    display: inline-block;
    font-size: 10px;
    transition: transform 0.18s ease;
}

/* Gira la flecha cuando el grupo está abierto */
.grupo-capas[open] .flecha-grupo::before {
    transform: rotate(90deg);
}

/* Cambio visual al pasar por encima */
.grupo-capas summary:hover {
    background: #dfeaf2;
}

/* Contenido interior */
.contenido-grupo {
    padding: 5px 8px 8px;
    background: #ffffff;
}

/* Cada fila de capa */
.fila-capa {
    display: flex !important;
    align-items: center;
    gap: 8px;

    min-height: 28px;
    padding: 3px 5px !important;

    border-radius: 4px;
    font-size: 13px !important;
    cursor: pointer;
}

.fila-capa:hover {
    background: #f1f5f8;
}

.fila-capa input {
    margin: 0;
}

/* Capas todavía no implementadas */
.capa-pendiente {
    color: #9aa3aa;
    cursor: not-allowed;
}

.capa-pendiente:hover {
    background: transparent;
}

.texto-grupo-pendiente {
    margin: 4px 2px;
    color: #9aa3aa;
    font-size: 12px;
    font-style: italic;
}

/* =========================================================
   FILTRADO DE RESULTADOS (bloque → activo → atributo)
   ========================================================= */

.fila-filtro {
    margin-bottom: 10px;
}

.fila-filtro label {
    display: block;
    margin-bottom: 4px;
    color: #556472;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.fila-filtro select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 9px;
    border: 1px solid #cfd6dd;
    border-radius: 5px;
    background: #f4f6f8;
    color: #9aa3aa;
    font-size: 13px;
    cursor: not-allowed;
}

/* =========================================================
   PEQUEÑOS SÍMBOLOS DE LEYENDA
   ========================================================= */

.simbolo-capa {
    display: inline-block;
    flex: 0 0 auto;
}

/* Punto kilométrico */
.simbolo-punto {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1f4e79;
    border: 1px solid #ffffff;
    box-shadow: 0 0 0 1px #1f4e79;
}
/* Distribución vertical del panel lateral */

#sidebar {
    height: 100vh;
    overflow-y: auto;
}

.bloque-buscador {
    flex: 0 0 auto;
}

.bloque-capas,
.bloque-campanas,
.bloque-filtrado,
.bloque-analisis {
    flex: 0 0 auto;
}
/* =========================================================
   SEPARACIÓN VISUAL ENTRE ZONAS DEL PANEL
   ========================================================= */

/* Buscador, árbol de capas e información */
.bloque {
    position: relative;
    padding: 16px 18px;
    border-top: 2px solid #c7d2dc;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 -1px 3px rgba(0, 0, 0, 0.05);
}

/* El primer bloque después del logo no necesita borde superior */
#logo + .bloque {
    border-top: none;
    box-shadow: none;
}

/* Títulos de cada zona */
.bloque > h2 {
    margin: 0 0 12px 0;
    padding: 8px 10px;

    background: #1f4e79;
    border-left: 4px solid #2589bd;
    border-radius: 4px;

    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
}

/* =========================================================
   AUTOCOMPLETADO DEL BUSCADOR
   ========================================================= */

.contenedor-buscador {
    position: relative;
}

.sugerencias-buscador {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;

    display: none;
    z-index: 2000;

    max-height: 220px;
    overflow-y: auto;

    background: #ffffff;
    border: 1px solid #c7d2dc;
    border-radius: 5px;

    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
}

.sugerencias-buscador.visible {
    display: block;
}

.sugerencia-pk {
    display: block;
    width: 100%;

    padding: 10px 12px;

    border: none;
    border-bottom: 1px solid #e4e9ed;
    background: #ffffff;

    color: #263746;
    font-size: 13px;
    text-align: left;

    cursor: pointer;
}

.sugerencia-pk:last-child {
    border-bottom: none;
}

.sugerencia-pk:hover,
.sugerencia-pk:focus {
    background: #eaf2f8;
    color: #1f4e79;
    outline: none;
}

.sugerencia-vacia {
    padding: 10px 12px;
    color: #7a858d;
    font-size: 13px;
}
/* =========================================================
   VENTANA EMERGENTE: FICHA DEL PUNTO KILOMÉTRICO
   ========================================================= */

.overlay-ficha-pk {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    pointer-events: none;

    opacity: 0;
    transition: opacity 0.3s ease;

    z-index: 2500;
}

.overlay-ficha-pk.active {
    opacity: 1;
}

.popup-ficha-pk {
    position: fixed;
    top: 50%;
    left: 50%;

    background-color: rgba(255, 255, 255, 0.5);
    border: 3px solid #2589bd;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;

    width: 90%;
    max-width: 380px;

    pointer-events: none;
    transform: translate(-50%, calc(-50% - 20px));
    transition: transform 0.3s ease;
}

.overlay-ficha-pk.active .popup-ficha-pk {
    pointer-events: auto;
    transform: translate(-50%, -50%);
}

.popup-ficha-pk.arrastrando {
    transition: none;
    user-select: none;
}

/* Faldón superior con el nombre de la capa (barra de arrastre) */
.cabecera-ficha-pk {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 12px 16px;

    background: #1f4e79;
    color: #ffffff;

    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;

    cursor: grab;
}

.popup-ficha-pk.arrastrando .cabecera-ficha-pk {
    cursor: grabbing;
}

.cuerpo-ficha-pk {
    padding: 24px 32px 32px;
}

.btn-cerrar-ficha-pk {
    flex: 0 0 auto;

    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #ffffff;

    cursor: pointer;
    transition: opacity 0.2s ease;
}

.btn-cerrar-ficha-pk:hover {
    opacity: 0.7;
}