/* Control de Leaflet MapTable */
.leaflet-control-maptable {
    background: transparent;
    border: none;
    box-shadow: none;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    /* Asegurar que el control mantenga su posición */
    top: auto !important;
    bottom: auto !important;
}

/* Contenedor de la tabla dentro del control */
.leaflet-control-maptable .flyup-table {
    max-width: calc(100vw - 70px);
    width: calc(100vw - 70px);
    margin: 0 auto;
}

/* Contenedor absoluto en la parte inferior (para compatibilidad) */
.table-flyup-container {
    position: fixed;
    left: 50%;
    bottom: 0px;
    transform: translateX(-50%);
    z-index: 1000;
    display: none;
}

/* Barra inferior flotante */
.flyup-header {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}

/* Estilos específicos para el control de Leaflet */
.leaflet-control-maptable .flyup-header {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.05);
    font-weight: 600;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.flyup-toggle-btn {
    all: unset;   
    background: none;
    border: none;
    font-size: 1rem;
    color: #5f6163;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.flyup-toggle-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.flyup-toggle-btn i {
    font-size: 14px;
    transition: transform 0.3s ease;
}

/* Clase para rotación */
.rotated i {
    transform: rotate(180deg) !important;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Contenido de la tabla, altura máxima y scroll */
.flyup-table-content {
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    max-height: 0;
    overflow: auto;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.flyup-table-content-individual {
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    max-height: 0px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Panel principal abierto */
#flyupTable.open #flyupContent {
    max-height: var(--table-max-height, 400px);
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

/* Tabla con tamaño reducido */
#flyupTable.resized-small #flyupContent {   
    max-height: var(--table-small-height, 200px);
    overflow-y: auto;
}

/* Asegurar que el contenedor siempre esté en la parte inferior */
.table-flyup-container.resized-small {
    top: auto !important;
}

/* Asegurar que el control de Leaflet no se mueva */
.leaflet-control-maptable.resized-small {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
}

/* Tablas individuales abiertas */
.individual-table.open .flyup-table-content-individual {
    max-height: 300px;
    overflow-y: auto;
}

/* Tabla responsive tipo Bootstrap */
.flyup-table-content table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    margin: 0 0;
}

.flyup-table-content table thead {
    background: #e9ecef;
}

.flyup-table-content table thead th {
    font-weight: bold;
    padding: 0.25rem 1rem;
    border-bottom: 2px solid #dee2e6;
    text-align: center;
    color: #343a40;
    position: sticky;
    top: 0;
    background: #e9ecef;
    font-size: 12px;
    z-index: 2;
}

.flyup-table-content table tbody td {
    padding: 0.25rem 1rem;
    border-top: 1px solid #dee2e6;
    color: #495057;
    background: white;
    font-size: 12px;
}

.flyup-table-content table tbody tr {
    cursor: pointer;
}

.flyup-table-content table tbody tr:hover {
    background: #333;
}

.download-csv-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.download-csv-btn i {
    font-size: 14px;
}

.download-csv-btn.visible {
    display: block;
    opacity: 1;
    visibility: visible;
}

.download-csv-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.series-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.series-btn i {
    font-size: 14px;
}

.series-btn.visible {
    display: block;
    opacity: 1;
    visibility: visible;
}

.series-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* Estilos para el badge de contador de features */
.feature-badge {
    background: #007bff;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 14px;
    font-weight: bold;
    margin-left: 8px;
}

/* Estilos para el control de búsqueda */
.search-container {
    display: none;
    align-items: center;
    margin-left: 8px;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
}

.search-container.visible {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.search-input-wrapper {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.search-input-wrapper .search-input {
    padding: 4px 28px 4px 8px; /* espacio para el botón clear */
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    width: 150px;
    height: 32px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.search-btn {
    all: unset;
    background: none;
    border: 0px solid #ccc;
    color: #666;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-btn:hover {
    background-color: #f0f0f0;
    color: #333;
    border-color: #007bff;
}

.search-input-wrapper .search-btn:active {
    background-color: #e9ecef;
}

.individual-table {
    margin-bottom: 2px;

}

.clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    font-size: 14px;
    cursor: pointer;
    display: none; /* oculto por defecto */
    width: 20px;
    height: 20px;
    padding: 0;
    line-height: 1;
    color: #666;
    z-index: 10;
}

.clear-btn.visible {
    display: block;
}

.clear-btn:hover {
    color: #333;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
}

/* Estilo para fila seleccionada */
.selected-row {
    background-color: #007bff !important;
    color: white !important;
}

.selected-row td {
    background-color: #007bff !important;
    color: white !important;
}

/* Estilo para celda seleccionada en búsqueda */
.selected-cell {
    background-color: #ffeb3b !important;
    color: #333 !important;
    font-weight: bold !important;
    border: 2px solid #ffc107 !important;
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.5) !important;
}

/* Cuando la celda seleccionada está en una fila seleccionada */
.selected-row .selected-cell {
    background-color: #ffeb3b !important;
    color: #333 !important;
    font-weight: bold !important;
    border: 2px solid #ffc107 !important;
    box-shadow: 0 0 8px rgba(255, 193, 7, 0.5) !important;
}

.go-map-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.go-map-btn i {
    font-size: 14px;
}

.go-map-btn.visible {
    display: block;
    opacity: 1;
    visibility: visible;
}

.go-map-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.go-records-table-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.go-records-table-btn i {
    font-size: 14px;
}

.go-records-table-btn.visible {
    display: block;
    opacity: 1;
    visibility: visible;
}

.go-records-table-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* --- Ajustes responsivos para móvil --- */
@media (max-width: 576px) {
    .flyup-header {
        flex-wrap: wrap;
        align-items: center;
        gap: 4px;
    }

    .header-buttons {
        justify-content: flex-end;
        row-gap: 4px;
        flex-wrap: wrap;
    }

    /* El contenedor de búsqueda ocupa toda la fila */
    #searchContainer.search-container {
        order: 2;
        flex: 1 1 100%;
        margin-left: 0;
    }

    .search-input-wrapper {
        display: flex;
        align-items: center;
        width: 100%;
    }

    .search-input-wrapper .search-input {
        width: 100%;
        min-width: 0;
        font-size: 12px;
    }

    .go-records-table-btn,
    .go-map-btn,
    .series-btn,
    .download-csv-btn,
    .flyup-toggle-btn,
    .clear-btn,
    .search-btn {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .go-records-table-btn i,
    .go-map-btn i,
    .series-btn i,
    .download-csv-btn i,
    .flyup-toggle-btn i,
    .clear-btn i,
    .search-btn i {
        font-size: 12px;
    }
}
