/* ================= BASE GENERAL ================= */
body {
    margin: 0;
    padding: 0;

    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #2c2c2c;
    background: #f4f6f8;
}

.leaflet-container {
    font-family: inherit;
}

/* ================= MAPA ================= */
#map {
    width: 100%;
    height: 100vh;
}

/* ================= PANEL LATERAL IZQUIERDO ================= */
.panel-capas {
    position: absolute;
    top: 15px;
    left: 15px;

    width: 260px;
    max-height: 80vh;
    overflow-y: auto;

    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);

    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);

    z-index: 1000;
    transition: all 0.25s ease;

    scrollbar-width: none;
    -ms-overflow-style: none;
}

.panel-capas::-webkit-scrollbar {
    display: none;
}

/* ================= HEADER ================= */
.panel-header {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    color: white;
    padding: 12px;
    border-radius: 14px 14px 0 0;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ================= GRUPOS ================= */
.grupo {
    border-bottom: 1px solid #e5e5e5;
}

.grupo h4 {
    margin: 0;
    padding: 10px 12px;

    cursor: pointer;
    background: transparent;

    display: flex;
    justify-content: space-between;
    align-items: center;

    font-size: 13px;
    font-weight: 600;
    color: #444;

    transition: background 0.2s;
}

.grupo h4:hover {
    background: rgba(0,0,0,0.05);
}

/* ================= SUBCAPAS ================= */
.subcapas {
    padding: 8px 12px 12px 12px;
    display: none;
}

.subcapas label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
}

/* ================= PANEL DERECHO ================= */
#infoParcela {
    display: none; /* 🔥 esto faltaba */

    position: absolute;
    right: 15px;
    top: 50px;

    width: 360px;
    max-height: 75vh;
    overflow-y: auto;

    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(6px);

    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);

    padding: 14px;

    z-index: 1000;

    scrollbar-width: none;
    -ms-overflow-style: none;

    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* 🔧 FIX INPUT */
#buscarNomenclatura {
    box-sizing: border-box;
    width: 100%;
}

/* 🔧 FIX PANEL BODY */
.panel-body {
    max-height: 60vh;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.panel-body.oculto {
    max-height: 0;
    overflow: hidden;
    padding: 0;
}

#infoParcela::-webkit-scrollbar {
    display: none;
    overflow: hidden;
}

/* ================= TITULOS PANEL DERECHO ================= */
#infoParcela h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
}

/* ================= BLOQUES DE INFO ================= */
.info-item {
    margin-bottom: 8px;
}

.info-label {
    font-size: 11px;
    color: #777;
    text-transform: uppercase;
}

.info-value {
    font-size: 14px;
    font-weight: 500;
}

/* ================= INPUTS Y BOTONES ================= */
input, button {
    font-family: inherit;
    font-size: 14px;
}

input {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    transition: border 0.2s;
}

input:focus {
    outline: none;
    border-color: #2e7d32;
}

button {
    background: linear-gradient(135deg, #0057a4, #003f7a);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* ================= HR ================= */
hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 12px 0;
}

/* ================= ANIMACION ================= */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* HEADER */
.panel-header-colapsable {
    display:flex;
    justify-content:space-between;
    align-items:center;

    background:#0057a4;
    color:white;

    padding:10px;
    font-weight:600;
}

/* BOTON */
.panel-header-colapsable button {
    background:transparent;
    border:none;
    color:white;
    font-size:18px;
    cursor:pointer;
}


/* COLAPSADO */
/* 🔥 cuando el panel está colapsado */
.panel-colapsable.colapsado .panel-body {
    max-height: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* EXPANDIDO */
.panel-colapsable.expandido {
    height:auto;
}



/* BLOQUE LIMPIO Y CONSOLIDADO DEL POPUP DE MAPPA */

.popup-central {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    z-index: 2000;

    width: min(94vw, 820px);
    max-height: 92vh;

    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    padding: 12px;
    box-sizing: border-box;
}

.popup-ficha-arbol{
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: white;
    border-radius: 18px;
    overflow: hidden;
    height: 100%;
    max-height: 100%;
}

.popup-ficha-header{
    background: linear-gradient(135deg,#0057a4,#003f7a);
    color: white;
    padding: 12px 16px 10px;
}

.popup-header-top{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
}

.popup-tipo{
    font-size:11px;
    text-transform:uppercase;
    opacity:.9;
    letter-spacing:.5px;
}

.popup-titulo{
    margin:6px 0 2px;
    font-size:22px;
    line-height:1.05;
    max-width: calc(100% - 40px);
}

.popup-subtitulo{
    font-size:12px;
    opacity:.9;
}

.btn-cerrar-popup{
    background:transparent;
    border:none;
    color:white;
    font-size:20px;
    cursor:pointer;
    flex:0 0 auto;
}

.popup-contenido-horizontal{
    display:grid;
    grid-template-columns: minmax(0, 1.15fr) 280px;
    gap:14px;
    padding:14px 14px 10px;
    min-height:0;
    overflow:hidden;
    align-items:start;
}

.popup-columna-datos{
    flex:1;
    display:flex;
    flex-direction:column;
    min-width:0;
    min-height:0;

    justify-content: space-between;
    height:100%;
}

.popup-columna-imagen{
    width:280px;
    flex:0 0 280px;
    display:flex;
    align-items:flex-start;
    justify-content:center;
}

.popup-imagen-principal-wrap{
    width:100%;
    display:flex;
    flex-direction:column;
    gap:10px;
}

.popup-imagen-principal{
    width:100%;
    aspect-ratio: 4 / 5;
    max-height: 305px;
    object-fit:cover;
    border-radius:14px;
    cursor:pointer;
    display:block;
}

.popup-mini-galeria{
    display:grid;
    grid-template-columns:repeat(3, 1fr);
    gap:8px;
    width:100%;
}

.mini-foto{
    height:76px;
    border-radius:10px;
    overflow:hidden;
    background:#ececec;
    border:1px solid #e2e2e2;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:11px;
    color:#666;
    text-align:center;
    padding:6px;
    box-sizing:border-box;
}

.mini-foto img{
    width:100%;
    height:100%;
    object-fit:cover;
    cursor:pointer;
    display:block;
}

.mini-foto.vacia{
    background: linear-gradient(135deg, #f5f5f5, #e9eef5);
    font-weight: 600;
}

.popup-ficha-badges{
    display:flex;
    gap:10px;
    margin-bottom:12px;
    flex-wrap:wrap;
}

.badge-riesgo,
.badge-estado{
    padding:6px 12px;
    border-radius:999px;
    color:white;
    font-size:12px;
    font-weight:600;
}

.badge-bajo{ background:#2e7d32; }
.badge-medio{ background:#f59e0b; }
.badge-alto{ background:#d32f2f; }
.badge-estado{ background:#607d8b; }

.popup-ficha-datos{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    min-height:0;
}

.dato-item{
    display:flex;
    flex-direction:column;
}

.dato-item label{
    font-size:11px;
    text-transform:uppercase;
    color:#666;
    margin-bottom:4px;
}

.dato-item input,
.dato-item select,
.dato-item textarea{
    border:1px solid #ddd;
    border-radius:10px;
    padding:8px 10px;
    font-size:14px;
    background:#fafafa;
    box-sizing:border-box;
    width:100%;
}

.dato-item textarea{
    min-height:64px;
    resize:none;
    overflow:auto;
    font-family:inherit;
    line-height:1.35;
}

.dato-observaciones{
    grid-column:1 / -1;
}

.popup-ficha-botones{
    display:grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap:10px;
    padding:12px 14px 14px;
    border-top:1px solid #eee;
    background:#fafafa;
    align-self:end;
}

.popup-ficha-botones button{
    width:100%;
    padding:8px 10px;
}

.sin-imagen{
    width:100%;
    aspect-ratio: 4 / 5;
    max-height: 305px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:#f1f1f1;
    border-radius:14px;
    color:#777;
    overflow:hidden;
}

.popup-ficha-arbol .dato-item input,
.popup-ficha-arbol .dato-item select,
.popup-ficha-arbol .dato-item textarea {
    margin-bottom: 0;
}

.popup-ficha-arbol .dato-item input:disabled,
.popup-ficha-arbol .dato-item select:disabled,
.popup-ficha-arbol .dato-item textarea:disabled {
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    color: #222;
    padding-left: 0;
    padding-right: 0;
    resize: none;
}

.popup-ficha-arbol.modo-edicion .dato-item input:not(:disabled),
.popup-ficha-arbol.modo-edicion .dato-item select:not(:disabled),
.popup-ficha-arbol.modo-edicion .dato-item textarea:not(:disabled) {
    background: #fafafa;
    border: 1px solid #ddd;
    padding: 10px;
}
.tipo-mapa-select{

    background: transparent !important;
    border: none !important;

    color: rgba(255,255,255,.92);

    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;

    padding: 0;
    margin: 0;

    outline: none;
    box-shadow: none;

    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    cursor: default;

    pointer-events: none;
}

/* SOLO cuando entra en edición */
.popup-ficha-arbol.modo-edicion .tipo-mapa-select{

    pointer-events: auto;

    background: rgba(255,255,255,.12) !important;

    border: 1px solid rgba(255,255,255,.25) !important;

    border-radius: 8px;

    padding: 4px 8px;

    color: white;

    cursor: pointer;

    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
}
/* ================= OVERLAY GENERAL ================= */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1999;
}

/* ================= IMAGEN AMPLIADA ================= */
.img-overlay {
    position: fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background: rgba(0,0,0,0.8);
    display:flex;
    align-items:center;
    justify-content:center;
    z-index:3000;
}

.img-ampliada {
    max-width: 90%;
    max-height: 90%;
    border-radius:10px;
    box-shadow:0 10px 40px rgba(0,0,0,0.5);
    transition: transform 0.1s ease;
    user-select: none;
}

/* ================= LOADER PARCELAS ================= */
#loaderParcelas {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    z-index: 5000;
    display: none;
}

/* ================= MOBILE ================= */
@media(max-width:700px){
    .popup-central{
        width: 94vw;
        max-height: 90vh;
        padding: 8px;
    }

    .popup-contenido-horizontal{
        grid-template-columns:1fr;
        gap:14px;
    }

    .popup-columna-imagen{
        width:100%;
        flex:unset;
    }

    .popup-imagen-principal{
        max-height:240px;
    }

    .sin-imagen{
        max-height:240px;
    }

    .popup-ficha-datos{
        grid-template-columns:1fr;
    }

    .popup-ficha-botones{
        grid-template-columns:1fr;
    }

    .popup-titulo{
        font-size:22px;
    }
}

/* ================= ZOOM HORIZONTAL ================= */
.leaflet-control-zoom {
    display: flex !important;
    flex-direction: row !important;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.leaflet-control-zoom a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background-color: #1e1e2f;
    color: #fff;
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    font-size: 14px !important;
    text-decoration: none;
    border: none;
    border-right: 1px solid rgba(255,255,255,0.15);
    transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
    background-color: #0057a4;
}

.leaflet-control-zoom a:last-child {
    border-right: none;
}

.leaflet-bar a,
.leaflet-bar a:hover {
    border-bottom: none;
}

input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

input[type="password"]::-webkit-credentials-auto-fill-button,
input[type="password"]::-webkit-password-toggle-button {
    display: none !important;
}

.icono-estado{
    width: 18px;
    height: 18px;
    object-fit: contain;
}
