:root {
    --primary: #0ea5e9;
    --dark: #1e293b;
    --glass: rgba(255, 255, 255, 0.98);
    --border: #e2e8f0;
    --sidebar-width: 240px;
    --toolbar-width: 50px; 
}

body, html { margin:0; padding:0; height:100%; width: 100%; font-family: 'Inter', sans-serif; overflow:hidden; }
#map { height: 100vh; width: 100vw; z-index: 1; position: absolute; top:0; left:0; }

/* --- SIDEBAR IZQUIERDO --- */
#sidebar-left { 
    position: absolute; 
    top: 15px; 
    bottom: 80px;  /* ← MÁS ESPACIO ABAJO PARA EL BOTÓN */
    left: 15px; 
    width: var(--sidebar-width);
    background: var(--glass); z-index: 2000; display: flex; flex-direction: column;
    border-radius: 16px; border: 1px solid var(--border);
    transition: transform 0.4s ease; backdrop-filter: blur(10px); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}
#sidebar-left.collapsed { transform: translateX(-270px); }
.sidebar-header { padding: 15px 20px; border-bottom: 1px solid var(--border); }
.brand h1 { font-size: 0.8rem; margin: 0; font-weight: 800; color: var(--dark); }
.sidebar-content { flex: 1; padding: 10px; overflow-y: auto; }

/* Copyright footer sin botón */
.sidebar-copyright {
    padding: 6px 0; 
    text-align: center; 
    font-size: 0.6rem; 
    color: #64748b; 
    border-top: 1px solid #f1f5f9; 
    background: #fff;
    border-radius: 0 0 16px 16px;
}

/* --- BOTONES FLOTANTES PARA PANELES --- */

/* Botón flotante para panel izquierdo */
.sidebar-toggle-btn {
    display: flex;
    position: fixed;
    bottom: 15px;  /* ← MISMA ALTURA QUE EL DERECHO */
    left: 15px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 2100;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.05);
    background: #0284c7;
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

/* Botón flotante para panel derecho */
.toolbar-toggle-btn {
    display: flex;
    position: fixed;
    bottom: 15px;  /* ← MISMA ALTURA QUE EL IZQUIERDO */
    right: 15px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 2100;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.toolbar-toggle-btn:hover {
    transform: scale(1.05);
    background: #0284c7;
}

.toolbar-toggle-btn:active {
    transform: scale(0.95);
}

/* --- BARRA DERECHA --- */
.esri-toolbar {
    position: fixed; 
    top: 15px;
    bottom: auto; 
    right: 15px; 
    width: var(--toolbar-width);
    background: #ffffff; 
    z-index: 2050;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    border-radius: 12px; 
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    padding: 5px 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.esri-toolbar.hidden-toolbar { 
    transform: translateX(120%);
    opacity: 0;
}

/* Controles de mapa */
.map-controls-group { 
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    align-items: center;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.map-control-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #64748b;
}

.map-control-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.map-control-btn:hover {
    background: #f1f5f9;
    color: var(--dark);
}

.map-control-btn:active {
    background: #e2e8f0;
    transform: scale(0.95);
}

.map-control-btn.gps-active svg {
    fill: #0ea5e9;
}

.map-control-btn.gps-searching svg {
    fill: #f59e0b;
    animation: pulse 1s infinite;
}

/* Herramientas */
.toolbar-group { 
    display: flex; 
    flex-direction: column; 
    gap: 3px; 
    width: 100%; 
    align-items: center;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.tool-btn {
    width: 34px; 
    height: 34px;
    border: none; 
    background: transparent;
    border-radius: 7px; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: all 0.2s ease;
    color: #64748b;
}
.tool-btn svg { width: 20px; height: 20px; fill: currentColor; }
.tool-btn:hover { background: #f1f5f9; color: var(--dark); }
.tool-btn:active { background: #e2e8f0; transform: scale(0.95); }
.tool-btn.active { background: #e0f2fe; color: var(--primary); }

/* Controles de Zoom integrados (solo web) */
.zoom-controls-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    align-items: center;
}

/* --- PANELES DE CONTENIDO --- */
.tool-content-panel {
    position: absolute; 
    top: 15px; 
    right: 75px; 
    width: 280px; 
    max-height: calc(100vh - 30px);
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
    z-index: 1999;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.2s ease-out;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

.tool-header {
    padding: 12px 15px; background: #f8fafc; 
    font-size: 0.8rem; font-weight: 700; color: var(--dark);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-tool-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 24px;
    height: 24px;
    display: none;
}

/* --- ESTILOS CONTROL PANEL --- */
.scrollable-panel-body { overflow-y: auto; flex: 1; }
.full-width { width: 100%; box-sizing: border-box; }
.form-select { padding: 6px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 0.75rem; color: #475569; background-color: #fff; }
.control-group { margin-bottom: 10px; }
.lbl-sm { font-size: 0.7rem; font-weight: 600; color: #64748b; display: block; margin-bottom: 4px; }
.btn-primary { background: var(--primary); color: white; border: none; padding: 6px; border-radius: 4px; font-size: 0.75rem; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: #0284c7; }
.btn-icon { background: #f1f5f9; border: 1px solid #cbd5e1; padding: 6px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }
.btn-icon:hover { background: #e2e8f0; }

.style-subpanel { background: #f8fafc; padding: 10px; border-radius: 6px; border: 1px solid #e2e8f0; margin-top: 8px; }
.col-dir { flex-direction: column !important; align-items: flex-start !important; gap: 5px; }
.flex-bw { display: flex; justify-content: space-between; width: 100%; }
.val-txt { font-size: 0.7rem; font-weight: bold; color: var(--primary); }
.divider { border: 0; border-top: 1px solid #e2e8f0; margin: 15px 0; }

.disabled-controls { opacity: 0.5; pointer-events: none; filter: grayscale(1); }
.style-toggle-row { margin-bottom: 8px; background: #eef2ff; padding: 8px; border-radius: 6px; border: 1px solid #e0e7ff; }

.classes-list-container { margin-top: 12px; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.class-item { background: white; padding: 8px; border: 1px solid #e2e8f0; border-radius: 4px; display: flex; align-items: center; gap: 8px; }
.class-color { width: 24px; height: 24px; border-radius: 4px; border: 1px solid #cbd5e1; cursor: pointer; flex-shrink: 0; }
.class-label { flex: 1; font-size: 0.7rem; color: #475569; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Estilos Generales */
.shadow { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.hidden { display: none !important; }
.p-10 { padding: 10px; }
.p-15 { padding: 15px; }
.empty-msg { font-size: 0.7rem; color: #94a3b8; text-align: center; font-style: italic; }

/* --- PANEL FLOTANTE BÚSQUEDA --- */
.floating-panel {
    position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
    width: 600px; max-width: 95vw; background: white; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); z-index: 3000;
    display: flex; flex-direction: column; max-height: 80vh; border: 1px solid #cbd5e1;
}

.panel-header { 
    padding: 12px 15px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border-radius: 12px 12px 0 0; 
    cursor: move; user-select: none;
}
.panel-header h3 { margin: 0; font-size: 0.9rem; color: #1e293b; }
.close-panel-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b; }
.panel-tabs { display: flex; border-bottom: 1px solid #e2e8f0; }
.tab-btn { flex: 1; padding: 10px; background: white; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; font-size: 0.8rem; color: #64748b; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: #f0f9ff; }
.panel-body { padding: 0; flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.tab-content { display: none; height: 100%; flex-direction: column; overflow: hidden; }
.tab-content.active { display: flex; }

/* Búsqueda Dirección */
.search-bar-container { display: flex; padding: 15px; gap: 10px; border-bottom: 1px solid #f1f5f9; }
.search-bar-container input { flex: 1; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; }
.search-bar-container button { padding: 0 15px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; }
.results-list { overflow-y: auto; max-height: 300px; padding: 0; }
.search-result { padding: 10px 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: 0.2s; }
.search-result:hover { background: #f0f9ff; }

/* --- ESTILOS TABLA ATRIBUTOS --- */
.layer-selector-container { padding: 15px; border-bottom: 1px solid #f1f5f9; }
.table-container { 
    flex: 1; 
    overflow-x: auto; 
    overflow-y: auto;
    position: relative; 
    background: #fff; 
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar visible */
.table-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
#attribute-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.75rem; white-space: nowrap; }
#attribute-table th { background: #f1f5f9; position: sticky; top: 0; padding: 8px; text-align: left; border-bottom: 2px solid #cbd5e1; border-right: 1px solid #e2e8f0; z-index: 10; font-weight: 700; color: #334155; min-width: 160px; vertical-align: top; }
.th-container { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.input-wrapper-relative { position: relative; width: 100%; }
.filter-input-dual { width: 100%; box-sizing: border-box; padding: 4px 20px 4px 4px; font-size: 0.7rem; border: 1px solid #cbd5e1; border-radius: 4px; margin-bottom: 0; display: block; }
.filter-input-dual.active-filter { background-color: #f0f9ff; border-color: var(--primary); }
.filter-clear-dual { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); cursor: pointer; color: #94a3b8; font-weight: bold; font-size: 10px; display: none; z-index: 5; }
.filter-clear-dual:hover { color: #ef4444; }
.filter-select-dual { width: 100%; box-sizing: border-box; padding: 4px; font-size: 0.65rem; border: 1px solid #cbd5e1; border-radius: 4px; background-color: white; cursor: pointer; color: #64748b; display: block; }
#attribute-table td { padding: 6px 8px; border-bottom: 1px solid #e2e8f0; border-right: 1px solid #f1f5f9; color: #475569; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.table-footer { padding: 5px 10px; font-size: 0.7rem; background: #f8fafc; border-top: 1px solid #e2e8f0; color: #64748b; text-align: right; }

/* Ocultar controles por defecto de Leaflet */
.leaflet-control-zoom {
    display: none !important;
}

.leaflet-bottom.leaflet-right {
    display: none !important;
}

.leaflet-bar {
    display: none !important;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* POPUP */
.popup-container { font-family: 'Inter', sans-serif; min-width: 200px; }
.popup-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; color: #1e293b; }
.popup-sub { font-size: 12px; color: #64748b; margin-bottom: 2px; }
.popup-mun { font-size: 11px; color: #94a3b8; margin-bottom: 8px; }
.popup-btn { background: #0ea5e9; color: white; border: none; padding: 6px 10px; border-radius: 4px; width: 100%; cursor: pointer; margin-bottom: 8px; font-weight: 600; font-size: 12px; }
.popup-btn:hover { background: #0284c7; }
.popup-nav { display: flex; gap: 5px; margin-top: 5px; }
.nav-link { flex: 1; text-align: center; background: #f1f5f9; padding: 5px; border-radius: 4px; text-decoration: none; color: #475569; font-size: 11px; font-weight: 600; border: 1px solid #e2e8f0; }
.nav-link:hover { background: #e2e8f0; }

/* Simbologia y Capas */
.legend-item { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; font-size: 0.75rem; font-weight: 600; color: #1e293b; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); flex-shrink: 0; }
.legend-line { min-width: 35px; width: 35px; height: 4px; border-radius: 2px; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.legend-border { width: 30px; height: 12px; border-radius: 1px; flex-shrink: 0; }
.menu-section { border: 1px solid var(--border); border-radius: 12px; background: white; margin-bottom: 10px; overflow: hidden; }
.section-trigger { padding: 12px 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 0.7rem; color: var(--dark); }
.section-content.collapsed { max-height: 0; overflow: hidden; }
.basemap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 5px; }
.basemap-card { cursor: pointer; border-radius: 8px; border: 2.5px solid transparent; text-align: center; background: #fff; transition: 0.2s; overflow: hidden; }
.basemap-card img { width: 100%; height: 50px; object-fit: cover; display: block; }
.basemap-card span { font-size: 0.65rem; font-weight: 700; display: block; padding: 5px; color: #475569; }
.basemap-card.active { border-color: var(--primary); background: #f0f9ff; }
.switch { position: relative; display: inline-block; width: 30px; height: 16px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 12px; width: 12px; left: 2px; bottom: 2px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(14px); }
.slider.round { border-radius: 16px; }
.slider.round:before { border-radius: 50%; }
.layer-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid #f8fafc; }
.layer-label { font-size: 0.7rem; font-weight: 700; color: #475569; display: flex; align-items: center; gap: 6px; }
.label-control-card { background: #f8fafc; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 8px; overflow: hidden; }
.label-control-header { padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; background: #fff; border-bottom: 1px solid #f1f5f9; }
.label-control-body { padding: 10px; display: grid; gap: 8px; }
.control-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.7rem; color: #475569; font-weight: 600; }
.range-sm { width: 80px; }
.select-sm { font-size: 0.65rem; padding: 2px; border-radius: 4px; border: 1px solid #cbd5e1; }
input[type="color"] { width: 25px; height: 25px; border: none; padding: 0; background: none; cursor: pointer; }
.gis-label { background: transparent !important; border: none !important; box-shadow: none !important; font-weight: 700; text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff; white-space: nowrap; text-transform: uppercase; }

/* Media Queries */
@media print {
    .leaflet-control-container, .esri-toolbar, #sidebar-left, .floating-panel, .toolbar-toggle-btn, .sidebar-toggle-btn { display: none !important; }
    #map { width: 100%; height: 100%; position: relative; }
}

@media screen and (max-width: 768px) {

    :root {
        --sidebar-width: 280px;
    }

    #sidebar-left {
        width: var(--sidebar-width);
        left: 0;
        top: 0;
        bottom: 80px;  /* ← MISMO ESPACIO EN MÓVIL */
        border-radius: 0;
        transform: translateX(0);
        box-shadow: 10px 0 25px rgba(0,0,0,0.3);
    }
    
    #sidebar-left.collapsed {
        transform: translateX(calc(-100%));
    }

    /* Botones a la misma altura en móvil */
    .sidebar-toggle-btn {
        bottom: 15px;  /* ← MISMA ALTURA */
        left: 10px;
        z-index: 2600;
    }

    .toolbar-toggle-btn {
        bottom: 15px;  /* ← MISMA ALTURA */
        right: 10px;
        z-index: 2600;
    }

    /* Mapas base en una sola columna en móvil */
    .basemap-grid {
        grid-template-columns: 1fr;
    }

    /* Ocultar controles de zoom y pantalla completa en móvil */
    .zoom-controls-group {
        display: none !important;
    }

    .floating-panel {
        width: 94vw !important;
        max-width: none;
        top: 10px !important;
        left: 50% !important;
        transform: translateX(-50%) !important; 
        margin: 0 !important;
        height: auto;
        max-height: 85vh;
    }
    
    .panel-header {
        cursor: default;
    }

    .search-result {
        padding: 15px;
        font-size: 0.85rem;
    }

    .esri-toolbar {
        position: fixed;
        top: auto;
        bottom: 80px;  /* ← MÁS ARRIBA PARA NO TAPAR BOTÓN */
        right: 10px;
        left: auto;
        height: auto;
        width: 50px;
        border-radius: 12px;
        padding: 8px 0;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        border: 1px solid var(--border);
        flex-direction: column;
        gap: 0;
        z-index: 2500;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .esri-toolbar.hidden-toolbar {
        transform: translateY(0) !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }

    .toolbar-group {
        flex-direction: column;
        gap: 3px;
        padding: 3px 0;
    }

    .map-controls-group {
        display: flex !important;
        flex-direction: column;
        gap: 3px;
        padding-bottom: 4px;
        border-bottom: 1px solid #e2e8f0;
        margin-bottom: 4px;
        width: 100%;
        align-items: center;
    }

    .map-control-btn {
        width: 36px;
        height: 36px;
    }

    .map-control-btn svg {
        width: 21px;
        height: 21px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
    }

    .tool-btn svg {
        width: 21px;
        height: 21px;
    }

    .tool-content-panel {
        position: fixed !important; 
        top: auto !important;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 60vh;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
        z-index: 5000;
        animation: slideUp 0.3s ease-out;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.3);
    }

    @keyframes slideUp { 
        from { transform: translateY(100%); } 
        to { transform: translateY(0); } 
    }

    .tool-header {
        padding: 15px;
        font-size: 1rem;
        text-align: left;
        background: white;
    }

    .close-tool-btn {
        display: block;
    }
    
    .scrollable-panel-body {
        padding-bottom: 40px; 
    }

    .table-container {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Scrollbar visible en móvil */
    .table-container::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    .table-container::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 4px;
    }
    
    .table-container::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
    
    .table-container::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
    
    #attribute-table {
        min-width: 100%;
    }
    
    #attribute-table th {
        min-width: 120px;
        font-size: 0.7rem;
    }

    #attribute-table td {
        font-size: 0.7rem;
        min-width: 120px;
    }

    .routing-widget {
        top: 10px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 90vw;
        max-width: none;
    }

    body { font-size: 16px; }
    .input-wrapper-relative input { font-size: 16px; }
    .form-select { font-size: 0.85rem !important; } 
}

/* Widget Ruta */
.routing-widget {
    position: absolute; top: 15px; right: 80px; width: 280px; background: white;
    border-radius: 8px; border: 1px solid var(--border); z-index: 1990;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.routing-header {
    padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 0.75rem; color: var(--dark);
    border-radius: 8px 8px 0 0;
}
.close-btn-mini {
    background: none; border: none; font-size: 1rem; cursor: pointer; color: #64748b;
}
.routing-body {
    padding: 10px; font-size: 0.7rem; color: #475569; max-height: 200px; overflow-y: auto;
}

/* ============================================================================
   ESTILOS PARA FUNCIONALIDAD DE POLÍGONO
   ============================================================================ */

/* Estilos para resultados de polígono */
.result-layer-section {
    animation: fadeIn 0.3s ease-in-out;
}

.result-card {
    transition: all 0.2s ease;
}

.result-card:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Botón activo para dibujo de polígono */
.tool-btn.active {
    background: #0ea5e9 !important;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.3);
}

.btn-icon {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   ESTILOS PARA AYUDA DE DIBUJO
   ============================================================================ */

#drawing-help {
    animation: slideDown 0.3s ease-out;
    min-width: 350px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#btn-finish-polygon {
    transition: all 0.2s ease !important;
}

#btn-finish-polygon:active {
    transform: scale(0.95) !important;
}

#btn-cancel-polygon {
    transition: all 0.2s ease !important;
}

#btn-cancel-polygon:active {
    transform: scale(0.95) !important;
}

#point-counter {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: monospace;
}

/* Responsive para mensaje de ayuda */
@media (max-width: 768px) {
    #drawing-help {
        top: 70px;
        left: 10px;
        right: 10px;
        transform: none;
        min-width: auto;
        padding: 12px 15px;
        gap: 10px;
    }
    
    #drawing-help > div:first-child {
        font-size: 14px;
    }
    
    #btn-finish-polygon {
        font-size: 14px !important;
        padding: 10px 15px !important;
    }
    
    #btn-cancel-polygon {
        padding: 10px 12px !important;
    }
}

/* Mejorar visibilidad de los puntos de dibujo */
.leaflet-editing-icon {
    background-color: white !important;
    border: 4px solid #0ea5e9 !important;
    border-radius: 50% !important;
    box-shadow: 0 3px 12px rgba(0,0,0,0.4) !important;
    width: 14px !important;
    height: 14px !important;
}

/* Primer punto más visible */
.leaflet-editing-icon:first-child {
    border-color: #10b981 !important;
    border-width: 5px !important;
    width: 18px !important;
    height: 18px !important;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3), 0 3px 12px rgba(0,0,0,0.4) !important;
}

.leaflet-touch-icon {
    width: 24px !important;
    height: 24px !important;
}

/* Tooltip de Leaflet Draw mejorado */
.leaflet-draw-tooltip {
    background: #0f172a !important;
    border: 2px solid #0ea5e9 !important;
    color: white !important;
    font-weight: 600 !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
    font-size: 13px !important;
}

.leaflet-draw-tooltip:before {
    border-right-color: #0ea5e9 !important;
}

/* Animación del polígono mientras se dibuja */
.leaflet-interactive.leaflet-pane-polygon {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 0.3;
    }
}

/* ============================================================================
   ANIMACIONES PARA MODALES Y NOTIFICACIONES
   ============================================================================ */

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Estilos para scroll en modales */
#modal-detalles > div:last-child::-webkit-scrollbar,
#modal-ruta-detalle > div:nth-child(2)::-webkit-scrollbar {
    width: 8px;
}

#modal-detalles > div:last-child::-webkit-scrollbar-track,
#modal-ruta-detalle > div:nth-child(2)::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

#modal-detalles > div:last-child::-webkit-scrollbar-thumb,
#modal-ruta-detalle > div:nth-child(2)::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

#modal-detalles > div:last-child::-webkit-scrollbar-thumb:hover,
#modal-ruta-detalle > div:nth-child(2)::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive para notificación */
@media (max-width: 768px) {
    #notif-ruta {
        top: 70px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    #modal-ruta-detalle,
    #modal-detalles,
    #modal-rutas {
        width: 95vw !important;
        max-width: none !important;
    }
}

/* ============================================================================
   BOTÓN FLOTANTE LIMPIAR POLÍGONO
   ============================================================================ */

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#btn-limpiar-poligono-float {
    animation: slideUpFade 0.4s ease-out;
}

/* Responsive para botón flotante */
@media (max-width: 768px) {
    #btn-limpiar-poligono-float {
        bottom: 20px;
        padding: 12px 25px;
        font-size: 0.95rem;
    }
}

/* ============================================================================
   ANIMACIONES PARA EXPORTACIÓN Y NOTIFICACIONES
   ============================================================================ */

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   ELEMENTOS DE LAYOUT CARTOGRÁFICO (ocultos por defecto)
   ============================================================================ */

#cartographic-layout {
    display: none;
}

/* Los estilos de impresión se inyectan dinámicamente en <head> al imprimir */

/* ============================================================================
   SELECCIÓN MÚLTIPLE EN TABLA
   ============================================================================ */

/* Barra de selección */
.selection-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    padding: 12px 15px;
    border-top: 2px solid #0284c7;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: slideUpFade 0.3s ease-out;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botones de acción de selección */
.btn-selection {
    background: white;
    color: #0ea5e9;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-selection:hover {
    background: #f0f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-selection:active {
    transform: translateY(0);
}

.btn-selection.btn-clear {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 12px;
}

.btn-selection.btn-clear:hover {
    background: rgba(255,255,255,0.3);
}

/* Checkbox en tabla */
.row-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #0ea5e9;
}

#select-all-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #0ea5e9;
}

/* Responsive para barra de selección */
@media (max-width: 768px) {
    .selection-bar {
        padding: 10px;
    }
    
    .btn-selection {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}
