/* ============================================================
   Mapa Ruta del Cacao – Stylesheet
   Fuente: Lato (cargada por el plugin, coincide con el tema)
   Paleta: azul marino #1B2A6B, amarillo #F5C800, blanco #fff
   ============================================================ */

/* ── VARIABLES ────────────────────────────────────────────── */
.mrc-wrap {
    --mrc-navy: #1B2A6B;
    --mrc-gold: #F5C800;
    --mrc-gold2: #D4A800;
    --mrc-teal: #00A896;
    --mrc-white: #ffffff;
    --mrc-light: #F7F9FC;
    --mrc-border: #E2E8F0;
    --mrc-text: #1A2340;
    --mrc-muted: #6B7A9A;
    --mrc-radius: 10px;
    --mrc-shadow: 0 4px 20px rgba(27, 42, 107, 0.10);
    font-family: 'Lato', sans-serif;
    font-size: 15px;
    box-sizing: border-box;
    line-height: 1.5;
}

.mrc-wrap *,
.mrc-wrap *::before,
.mrc-wrap *::after {
    box-sizing: inherit;
}

/* ── LAYOUT ───────────────────────────────────────────────── */
.mrc-wrap {
    display: flex;
    align-items: stretch;
    /* sidebar y mapa siempre la misma altura */
    width: 100%;
    border-radius: var(--mrc-radius);
    overflow: hidden;
    box-shadow: var(--mrc-shadow);
    border: 1px solid var(--mrc-border);
    background: var(--mrc-white);
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.mrc-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--mrc-white);
    border-right: 1px solid var(--mrc-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mrc-sb-header {
    padding: 18px 16px 14px;
    background: var(--mrc-navy);
    color: var(--mrc-white);
}

.mrc-eyebrow {
    display: inline-block;
    background: var(--mrc-gold);
    color: var(--mrc-navy);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.mrc-sb-title {
    font-size: 20px !important;
    font-weight: 900 !important;
    color: var(--mrc-white) !important;
    margin: 0 0 4px !important;
    padding: 0 !important;
    line-height: 1.15 !important;
}

.mrc-sb-title span {
    color: var(--mrc-gold);
}

.mrc-sb-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 300;
    margin: 0;
}

/* Stats row */
.mrc-stats {
    display: flex;
    border-bottom: 1px solid var(--mrc-border);
}

.mrc-stat {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
    border-right: 1px solid var(--mrc-border);
}

.mrc-stat:last-child {
    border-right: none;
}

.mrc-stat strong {
    display: block;
    font-size: 20px;
    font-weight: 900;
    color: var(--mrc-navy);
    line-height: 1;
}

.mrc-stat span {
    font-size: 10px;
    color: var(--mrc-muted);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filter nav */
.mrc-filter {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--mrc-border);
    padding: 6px 8px;
    background: var(--mrc-light);
}

.mrc-filter-btn {
    flex: 1;
    padding: 5px 4px;
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 700;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--mrc-muted);
    cursor: pointer;
    transition: all .15s;
    text-align: center;
}

.mrc-filter-btn:hover {
    color: var(--mrc-navy);
    background: var(--mrc-white);
}

.mrc-filter-btn.active {
    background: var(--mrc-navy);
    color: var(--mrc-white);
    border-color: var(--mrc-navy);
}

/* UF list */
.mrc-uf-list {
    list-style: none;
    margin: 0;
    padding: 8px !important;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--mrc-border) transparent;
}

.mrc-uf-list::-webkit-scrollbar {
    width: 4px;
}

.mrc-uf-list::-webkit-scrollbar-thumb {
    background: var(--mrc-border);
    border-radius: 4px;
}

.mrc-uf-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    border: 1px solid transparent;
    margin-bottom: 3px;
}

.mrc-uf-item:hover {
    background: var(--mrc-light);
    border-color: var(--mrc-border);
}

.mrc-uf-item.active {
    background: #EEF2FF;
    border-color: var(--mrc-navy);
    border-left-width: 3px;
    transform: translateX(2px);
}

.mrc-uf-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    border: 2px solid rgba(0, 0, 0, .1);
}

.mrc-uf-info {
    flex: 1;
    min-width: 0;
}

.mrc-uf-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--mrc-navy);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mrc-uf-sub {
    font-size: 11px;
    color: var(--mrc-muted);
    margin-top: 2px;
    display: block;
}

/* Progress bar */
.mrc-prog-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
}

.mrc-prog-bar {
    flex: 1;
    height: 4px;
    background: var(--mrc-border);
    border-radius: 2px;
    overflow: hidden;
}

.mrc-prog-fill {
    height: 100%;
    border-radius: 2px;
    transition: width .4s ease;
}

.mrc-prog-pct {
    font-size: 10px;
    font-weight: 700;
    color: var(--mrc-navy);
    flex-shrink: 0;
    min-width: 26px;
    text-align: right;
}

/* Footer */
.mrc-sb-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--mrc-border);
    display: flex;
    gap: 8px;
    background: var(--mrc-light);
}

.mrc-btn {
    flex: 1;
    padding: 8px 10px;
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    font-weight: 700;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1;
}

.mrc-btn-primary {
    background: var(--mrc-navy);
    color: var(--mrc-white);
}

.mrc-btn-primary:hover {
    background: #243580;
}

.mrc-btn-outline {
    background: var(--mrc-white);
    color: var(--mrc-navy);
    border: 1px solid var(--mrc-border);
}

.mrc-btn-outline:hover {
    border-color: var(--mrc-navy);
}

/* ── MAP CONTAINER ────────────────────────────────────────── */
.mrc-map-container {
    flex: 1;
    /* ocupa todo el espacio restante */
    position: relative;
    min-height: 400px;
    /* La altura la hereda del wrapper (align-items: stretch) */
    height: auto;
}

/* El mapa Leaflet ocupa el 100% del contenedor absoluto */
.mrc-leaflet-map {
    position: absolute;
    inset: 0;
    /* top:0 right:0 bottom:0 left:0 */
    width: 100%;
    height: 100%;
}

/* ── LEGEND ───────────────────────────────────────────────── */
.mrc-legend {
    position: absolute;
    bottom: 20px;
    right: 12px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--mrc-border);
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: var(--mrc-shadow);
    font-size: 12px;
    max-width: 160px;
}

.mrc-legend strong {
    display: block;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--mrc-navy);
    margin-bottom: 7px;
}

.mrc-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 4px;
    color: var(--mrc-text);
    font-size: 11px;
}

.mrc-legend-item:last-child {
    margin-bottom: 0;
}

.mrc-legend-line {
    width: 18px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Float controls (sin sidebar) */
.mrc-float-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mrc-float-btn {
    flex: none;
    padding: 8px 12px;
    font-size: 13px;
}

/* ── POPUP ────────────────────────────────────────────────── */
.mrc-wrap .leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    padding: 0 !important;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(27, 42, 107, 0.18) !important;
    border: 1px solid var(--mrc-border) !important;
    font-family: 'Lato', sans-serif !important;
    min-width: 220px;
}

.mrc-wrap .leaflet-popup-content {
    margin: 0 !important;
    font-family: 'Lato', sans-serif;
}

.mrc-wrap .leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    font-size: 16px !important;
    color: var(--mrc-muted) !important;
    z-index: 2;
}

.mrc-popup-head {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--mrc-border);
}

.mrc-popup-uf {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--mrc-muted);
    margin-bottom: 3px;
}

.mrc-popup-title {
    font-size: 15px;
    font-weight: 900;
    color: var(--mrc-navy);
    line-height: 1.2;
}

.mrc-popup-body {
    padding: 8px 14px 12px;
}

.mrc-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid #F0F4F8;
    font-size: 13px;
}

.mrc-popup-row:last-child {
    border: none;
}

.mrc-popup-key {
    color: var(--mrc-muted);
}

.mrc-popup-val {
    font-weight: 700;
    color: var(--mrc-navy);
}

.mrc-popup-prog {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #F0F4F8;
}

.mrc-popup-prog-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--mrc-muted);
    margin-bottom: 4px;
}

.mrc-popup-prog-label strong {
    color: var(--mrc-navy);
}

.mrc-popup-bar {
    height: 6px;
    background: var(--mrc-border);
    border-radius: 3px;
    overflow: hidden;
}

.mrc-popup-fill {
    height: 100%;
    border-radius: 3px;
}

/* ── STATUS BADGES ────────────────────────────────────────── */
.mrc-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
}

.mrc-badge-op {
    background: #DCFCE7;
    color: #166534;
}

.mrc-badge-pend {
    background: #FEF9C3;
    color: #854D0E;
}

/* ── CITY LABELS ──────────────────────────────────────────── */
.mrc-city-label {
    color: var(--mrc-navy);
    font-family: 'Lato', sans-serif;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── MAINTENANCE ALERTS ───────────────────────────────────── */
.mrc-maint-icon {
    width: 28px;
    height: 28px;
    background: #FEF2F2;
    border: 2px solid #EF4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: mrcPulse 2s infinite;
}

@keyframes mrcPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        transform: scale(1.08);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.mrc-maintenance-popup .leaflet-popup-content-wrapper {
    border-top: 4px solid #EF4444 !important;
    border-radius: 10px !important;
    overflow: hidden;
}

.mrc-maint-popup-head {
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    color: #EF4444;
    padding: 10px 12px 6px;
    border-bottom: 1px solid #F3F4F6;
}

.mrc-maint-popup-body {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    color: #374151;
    padding: 10px 12px;
    line-height: 1.4;
}

.mrc-maint-line {
    animation: mrcDash 25s linear infinite;
}

@keyframes mrcDash {
    to {
        stroke-dashoffset: -1000;
    }
}

/* ── TOGGLE & OVERLAY (DESKTOP) ───────────────────────────── */
.mrc-toggle {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1010;
    background: var(--mrc-navy);
    color: var(--mrc-white);
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-family: 'Lato', sans-serif;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(27, 42, 107, .35);
    min-height: 44px;
    transition: background .15s;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.mrc-toggle:hover {
    background: #243580;
}

.mrc-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1015;
    cursor: pointer;
}

.mrc-overlay.open {
    display: block;
}

/* ── RESPONSIVE — TABLET  ≤ 900px ─────────────────────────── */
@media (max-width: 900px) {
    .mrc-wrap {
        overflow: visible;
        border-radius: 10px;
    }

    .mrc-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 82vw;
        z-index: 1020;
        transform: translateX(-105%);
        visibility: hidden;
        opacity: 0;
        transition: transform .28s ease, visibility .28s ease, opacity .28s ease;
        box-shadow: 4px 0 20px rgba(27, 42, 107, .2);
        border-radius: 10px 0 0 10px;
        border-right: 1px solid var(--mrc-border);
        overflow: hidden;
    }

    .mrc-sidebar.open {
        transform: translateX(0);
        visibility: visible;
        opacity: 1;
    }

    .mrc-map-container {
        flex: 1;
        width: 100%;
        border-radius: 10px;
        overflow: hidden;
        height: 100% !important;
    }

    .mrc-overlay {
        position: fixed;
        inset: 0;
        z-index: 1015;
    }

    .mrc-overlay.open {
        display: block;
    }

    .mrc-toggle {
        display: flex;
        z-index: 1010;
    }

    .mrc-legend {
        top: 12px;
        bottom: auto;
        right: 12px;
        left: auto;
    }

    .mrc-wrap .leaflet-popup-content-wrapper {
        min-width: 200px !important;
        max-width: min(280px, 70vw) !important;
    }
}

/* ── RESPONSIVE — MÓVIL  ≤ 600px ──────────────────────────── */
@media (max-width: 600px) {
    .mrc-wrap {
        border-radius: 8px;
        overflow: visible;
        height: auto !important;
    }

    .mrc-map-container {
        border-radius: 8px;
        overflow: hidden;
        height: 480px !important;
        min-height: 480px;
    }

    .mrc-sidebar {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100%;
        height: 62vh !important;
        max-height: 62vh;
        transform: translateY(110%);
        visibility: hidden;
        opacity: 0;
        transition: transform .28s ease, visibility .28s ease, opacity .28s ease;
        border-top: 1px solid var(--mrc-border);
        border-right: none;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -6px 24px rgba(27, 42, 107, .18);
        overflow: hidden;
        z-index: 1020;
    }

    .mrc-sidebar.open {
        transform: translateY(0);
        visibility: visible;
        opacity: 1;
    }

    /* Handle drag */
    .mrc-sb-header::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, .4);
        border-radius: 2px;
        margin: 0 auto 10px;
    }

    .mrc-toggle {
        top: auto;
        bottom: 14px;
        left: 50%;
        transform: translateX(-50%);
    }

    .mrc-toggle.sidebar-open {
        bottom: calc(62vh + 10px);
        transform: translateX(-50%);
        z-index: 1025;
    }

    .mrc-legend {
        display: none;
    }

    .mrc-wrap .leaflet-popup-content-wrapper {
        min-width: min(260px, 80vw) !important;
        max-width: min(320px, 88vw) !important;
    }
}

/* ── XS  ≤ 400px ─────────────────────────────────────────── */
@media (max-width: 400px) {
    .mrc-sb-title {
        font-size: 17px !important;
    }

    .mrc-uf-label {
        font-size: 12px;
    }

    .mrc-btn {
        font-size: 12px;
        padding: 8px 6px;
    }

    .mrc-toggle {
        font-size: 13px;
        padding: 9px 14px;
    }
}