/* ════════════════════════════
   RESET
════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ════════════════════════════
   TOKENS / VARIABLES
════════════════════════════ */
:root {
    --bg:            #0b0c10;
    --surface:       rgba(11, 13, 20, 0.90);
    --surface-solid: #0d0f17;
    --border:        rgba(255, 255, 255, 0.07);
    --accent:        #38bdf8;
    --accent-hover:  #7dd3fc;
    --accent-dim:    rgba(56, 189, 248, 0.13);
    --text-primary:  #f1f5f9;
    --text-secondary:#94a3b8;
    --text-muted:    #4b5563;
    --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ════════════════════════════
   BASE
════════════════════════════ */
html, body {
    width: 100%;
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ════════════════════════════
   SHELL
════════════════════════════ */
#shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

/* ════════════════════════════
   HEADER
════════════════════════════ */
#header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--surface-solid);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    background: var(--accent);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
    color: #000;
    letter-spacing: -0.5px;
}

.brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
    white-space: nowrap;
}

.brand-name span {
    color: var(--accent);
}

.hd-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    flex-shrink: 0;
}

.header-subtitle {
    font-size: 12.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Live badge ── */
.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px 3px 9px;
    border-radius: 99px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.22);
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: blink 2.2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ── Botón volver ── */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    border-radius: 7px;
    background: var(--accent);
    color: #000;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.1px;
    transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
}

.btn-back:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(56, 189, 248, 0.28);
}

.btn-back:active {
    transform: translateY(0);
}

/* ════════════════════════════
   MAP WRAPPER
════════════════════════════ */
#map-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* ════════════════════════════
   INFO CARD — colapsable
════════════════════════════ */
#info-card {
    position: absolute;
    bottom: 28px;
    left: 18px;
    z-index: 900;
    width: 272px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04);
    transition: box-shadow 0.2s ease;
}

/* ── Cabecera siempre visible ── */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px 20px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.card-header:hover .card-chevron {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
}

.card-eyebrow {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.1px;
    color: var(--accent);
    margin-bottom: 0;   /* override antiguo */
}

.card-eyebrow::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--accent);
    border-radius: 99px;
}

/* ── Botón chevron ── */
.card-chevron {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    padding: 0;
}

.card-chevron:hover {
    color: var(--accent);
}

#chevron-icon {
    transition: transform 0.25s ease;
}

/* Estado colapsado: gira el chevron 180° */
#info-card.collapsed #chevron-icon {
    transform: rotate(180deg);
}

/* ── Cuerpo colapsable ── */
.card-body {
    padding: 0 20px 16px;
    overflow: hidden;
    max-height: 400px;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.25s ease;
    opacity: 1;
}

#info-card.collapsed .card-body {
    max-height: 0;
    opacity: 0;
    padding-bottom: 0;
}

.card-title {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 14px;
}

.card-divider {
    height: 1px;
    background: var(--border);
    margin-bottom: 12px;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 11.5px;
}

.meta-label {
    color: var(--text-muted);
    flex-shrink: 0;
}

.meta-value {
    color: var(--text-secondary);
    font-weight: 500;
    text-align: right;
}

/* ════════════════════════════
   MARCADORES DE EDIFICIOS
   Estructura:
     bm-wrapper  →  caja + línea   (L.divIcon)
     circleMarker → punto exacto   (L.circleMarker)
════════════════════════════ */

/* ── Contenedor general ── */
.bm-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
    /* Centra horizontalmente sin depender de un ancho fijo.
       iconAnchor X = 0, así que el origen está a la izquierda;
       translateX(-50%) lo centra sobre la coordenada. */
    transform: translateX(-50%);
    cursor: default;
    pointer-events: auto;
    transition: filter 0.15s ease;
}

.bm-wrapper:hover {
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.45));
}

/* ── Caja de texto ── */
.bm-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(11, 13, 20, 0.90);
    border: 1px solid rgba(56, 189, 248, 0.40);
    border-radius: 8px;
    padding: 6px 14px 7px;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.bm-wrapper:hover .bm-box {
    border-color: rgba(56, 189, 248, 0.75);
    background: rgba(11, 13, 20, 0.97);
}

.bm-name {
    font-size: 13px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: 0.2px;
    text-align: center;
    line-height: 1.3;
}

.bm-sub {
    font-size: 10.5px;
    color: #38bdf8;
    letter-spacing: 0.3px;
    margin-top: 2px;
    text-align: center;
    line-height: 1.3;
}

/* ── Línea conectora ── */
.bm-line {
    width: 1.5px;
    height: 22px;
    background: linear-gradient(to bottom, rgba(56, 189, 248, 0.5), rgba(56, 189, 248, 1));
    flex-shrink: 0;
}

/* ════════════════════════════
   COORDENADAS (debug)
   Muestra lat/lng al hacer clic
════════════════════════════ */
#coords-toast {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 900;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 11.5px;
    color: var(--text-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    display: none;  /* se muestra al primer clic */
    font-family: 'Consolas', 'Courier New', monospace;
}

#coords-toast b { color: var(--accent); }

/* ════════════════════════════
   LEAFLET OVERRIDES
════════════════════════════ */
.leaflet-control-attribution {
    background: rgba(11, 13, 20, 0.82) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
    border-radius: 6px 0 0 0;
    backdrop-filter: blur(8px);
    padding: 3px 8px !important;
}

.leaflet-control-attribution a {
    color: var(--accent) !important;
}

.leaflet-control-zoom {
    border: 1px solid var(--border) !important;
    border-radius: 9px !important;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45) !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    background: var(--surface-solid) !important;
    color: var(--text-secondary) !important;
    border-bottom: 1px solid var(--border) !important;
    font-size: 17px !important;
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    transition: background 0.15s, color 0.15s;
}

.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    background: #151822 !important;
    color: var(--accent) !important;
}

.leaflet-bar a {
    border-radius: 0 !important;
}

/* ── Popup personalizado ── */
.leaflet-popup-content-wrapper {
    background: rgba(13, 15, 23, 0.95) !important;
    border: 1px solid rgba(56, 189, 248, 0.25) !important;
    border-radius: 9px !important;
    box-shadow: 0 8px 28px rgba(0,0,0,0.55) !important;
    backdrop-filter: blur(16px);
    color: var(--text-primary) !important;
    font-family: var(--font) !important;
    font-size: 12.5px !important;
}

.leaflet-popup-tip-container { display: none; }

.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

/* ════════════════════════════
   RESPONSIVE
════════════════════════════ */
@media (max-width: 620px) {
    #header {
        padding: 0 14px;
        height: 50px;
    }

    .header-subtitle,
    .hd-sep,
    .badge-live {
        display: none;
    }

    .brand-name {
        font-size: 15px;
    }

    .btn-back {
        font-size: 12px;
        padding: 6px 13px;
    }

    #info-card {
        width: calc(100% - 32px);
        bottom: 16px;
        left: 16px;
    }

    /* En móvil la card arranca colapsada */
    #info-card .card-body {
        max-height: 0;
        opacity: 0;
        padding-bottom: 0;
    }

    #info-card #chevron-icon {
        transform: rotate(180deg);
    }
}