/* =========================================================
   Mapa Interactivo — Estilos
   ========================================================= */

/* Tabs
---------------------------------------------------------- */
.mi-tabs {
    display: flex;
    gap: 10px;
    width: 100%;
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.mi-tabs button {
    flex: 1;
    width: 100%;
    text-align: center;
    padding: 8px 10px;
    border-radius: 25px;
    border: 1px solid #000;
    background: #1a1a1a;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: .2s;
}

.mi-tabs button:hover,
.mi-tabs button.active {
    background: #575757;
    border-color: #575757;
}

/* Layout principal
---------------------------------------------------------- */
.mi-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

#filters {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    background: #fff;
    border-right: 1px solid #ddd;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
}

#filters h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
}

#filters p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

#filters select {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ccc;
}

#filters input[type="text"] {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

#filters .filters-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

#filters .filters-actions button {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 25px;
    transition: .2s;
}

#clearFilters {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

#clearFilters:hover {
    background: #575757;
}

#exportData {
    background: #18a957;
    color: #fff;
    border: 1px solid #18a957;
}

#exportData:hover {
    background: #39c46f;
    border-color: #39c46f;
}

/* Vistas
---------------------------------------------------------- */
.mi-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
    pointer-events: none;
}

.view.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Mapa
---------------------------------------------------------- */
#map {
    width: 100%;
    height: 100%;
}



/* Marcadores
---------------------------------------------------------- */
.cluster-circle {
    width: 36px;
    height: 36px;
    background: #ff0000;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Popups
---------------------------------------------------------- */
.leaflet-popup { max-width: 320px !important; }

.project-popup .leaflet-popup-content-wrapper {
    border-radius: 25px;
    width: 350px !important;
    padding: 0 !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden !important;
}

.project-popup .leaflet-popup-content {
    width: 350px !important;
    margin: 0 !important;
    padding: 10px !important;
    box-sizing: border-box;
    overflow: hidden !important;
}

.project-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    overflow: hidden;
}

.project-card .img {
    width: 100%;
    height: 160px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    background: #eee;
}

.project-card .img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.project-card .id    { font-size: 12px; color: #333333; }
.project-card .title { font-size: 16px; font-weight: 700; color: #000; line-height: 1.2; }

.project-card .resumen,
.project-card .resultado { font-size: 14px; color: #000; line-height: 1.3; }

.project-card .vermas { font-size: 14px; color: #18a957; text-decoration: underline; }

.leaflet-popup-close-button {
    width: 28px !important;
    height: 28px !important;
    line-height: 28px !important;
    top: 10px !important;
    right: -25px !important;
    background: #000 !important;
    color: #fff !important;
    border-radius: 50% !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    text-align: center !important;
    opacity: 1 !important;
    filter: none !important;
    text-shadow: none !important;
    z-index: 9999 !important;
}

.leaflet-popup-close-button:hover { background: #333333 !important; opacity: 1 !important; }
.leaflet-popup-close-button:after { display: none !important; }

/* Listado
---------------------------------------------------------- */
.view[data-view="listado"] {
    padding: 25px;
    background: #fafafa;
    box-sizing: border-box;
}

table { width: 100%; border-collapse: collapse; }

th, td { padding: 8px; border-bottom: 1px solid #eee; font-size: 13px; }

.view[data-view="listado"] table {
    background: #ffffff;
    color: #000000;
    font-size: 13px;
}

.view[data-view="listado"] thead th {
    background: #cccccc;
    font-weight: 700;
    color: #000000;
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #bbb;
}

.view[data-view="listado"] td {
    padding: 10px;
    color: #000000;
    border-bottom: 1px solid #e5e5e5;
}

.view[data-view="listado"] tbody tr:nth-child(odd)  { background: #ffffff; }
.view[data-view="listado"] tbody tr:nth-child(even) { background: #f5f5f5; }
.view[data-view="listado"] tbody tr:hover           { background: #eaeaea; }

/* Paginación
---------------------------------------------------------- */
.mi-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.mi-pagination button {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: #999;
    cursor: pointer;
}

.mi-pagination button:hover,
.mi-pagination button.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* Scroll tabla
---------------------------------------------------------- */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll table { min-width: 900px; width: 100%; }

.table-scroll::-webkit-scrollbar        { height: 8px; }
.table-scroll::-webkit-scrollbar-track  { background: #eee; border-radius: 10px; }
.table-scroll::-webkit-scrollbar-thumb  { background: #999; border-radius: 10px; }

/* Toggle filtros (mobile)
---------------------------------------------------------- */
.filters-toggle {
    display: none;
    width: 100%;
    padding: 12px 14px;
    background: #fff;
    color: #000;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    transition: .2s ease;
}

.filters-toggle:hover { background: #f5f5f5; }

.filters-icon { transition: transform .25s ease; }

.filters-toggle.active .filters-icon { transform: rotate(180deg); }

.filters-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Modal
---------------------------------------------------------- */
.mi-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.mi-modal {
    width: 900px;
    max-width: 95%;
    height: 700px;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    position: relative;
}

.mi-left {
    width: 100%;
    height: 250px;
    position: relative;
    color: #fff;
}

.mi-left img { width: 100%; height: 100%; object-fit: cover; }

.mi-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.2));
}

.mi-left-content {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
}

.mi-tag {
    display: inline-block;
    background: #ff7a00;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 12px;
    margin-bottom: 10px;
}

.mi-title  { font-size: 20px; font-weight: bold; line-height: 1.3; }
.mi-text   { font-size: 16px; line-height: 1.4; color: #333; }
.mi-inst   { font-size: 14px; opacity: 0.8; margin-top: 5px; }
.mi-label  { font-size: 11px; color: #999; }

.mi-badge {
    display: inline-block;
    background: #ffe8b3;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: bold;
}

.mi-right {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
    max-height: 450px;
}

.mi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mi-item          { font-size: 16px; word-break: break-word; }
.mi-section-title { font-weight: bold; color: #003366; margin-top: 10px; }

.mi-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

.mi-btn {
    flex: 1;
    border-radius: 25px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
}

.mi-btn.secondary {
    border: 2px solid #ff0077;
    background: #fff;
    color: #ff0077;
}

.mi-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    z-index: 20;
    transition: .2s;
}

.mi-close:hover { background: #333; }

.mi-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

.mi-nav button {
    border: none;
    background: #eee;
    padding: 6px 10px;
    cursor: pointer;
}

.mi-print-header { display: none; }

/* Responsive
---------------------------------------------------------- */
@media (max-width: 768px) {

    .mi-wrapper {
        flex-direction: column;
        height: auto;
    }

    .mi-tabs { box-sizing: border-box; }

    .mi-tabs button { font-size: 13px; padding: 10px; }

    #filters {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        box-sizing: border-box;
        flex-wrap: wrap;
    }

    #filters h2, #filters p { width: 100%; margin: 0; }

    #filters select { width: 100%; box-sizing: border-box; }

    #filters .filters-actions {
        width: 100%;
        margin-top: 5px;
        flex-direction: column;
    }

    #filters .filters-actions button { flex: 1; border-radius: 25px; }

    .mi-content  { height: calc(100vh - 320px); min-height: 400px; }
    #map         { width: 100%; height: 100%; }

    .filters-toggle { display: flex; }

    .filters-inner { display: none; width: 100%; flex-direction: column; gap: 10px; }
    .filters-inner.open { display: flex; }

    #filters select,
    #filters .filters-actions button { width: 100%; }

    .mi-modal { flex-direction: column; height: auto; }
    .mi-left  { height: 200px; width: 100%; }
    .mi-grid  { grid-template-columns: 1fr; }
}

/* Impresión
---------------------------------------------------------- */
@media print {

    body { margin: 0; }

    body > *:not(.mi-modal-overlay) { display: none !important; }

    .mi-modal-overlay { position: static; background: none; }

    .mi-modal {
        position: static;
        width: 100%;
        height: auto;
        box-shadow: none;
        display: block;
    }

    .mi-left, .mi-right { width: 100% !important; display: block; }

    .mi-left img    { height: auto; max-height: 400px; object-fit: cover; }
    .mi-overlay     { display: none !important; }
    .mi-left-content { display: none !important; }
    .mi-right       { margin-top: 10px; }

    .mi-close, .mi-nav, .mi-actions { display: none !important; }

    .mi-print-header { display: block !important; margin: 15px 0; }

    .mi-print-tag {
        display: inline-block;
        background: #ff7a00;
        color: #fff;
        padding: 5px 10px;
        border-radius: 20px;
        font-size: 12px;
        margin-bottom: 10px;
    }

    .mi-print-title { font-size: 22px; font-weight: bold; margin-bottom: 5px; }
    .mi-print-inst  { font-size: 14px; color: #555; margin-bottom: 10px; }
}
