:root {
    --popover-bg-color: white;
}

.full-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── Fullscreen map container ──────────────────────────── */
.map-outer {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* ── Map area (fills remaining height) ─────────────────── */
.map-area {
    position: relative;
    flex: 1;
    overflow: hidden;
}

#map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ── Government attribution logo ─────────────────────────── */
.map-gov-logo {
    position: absolute;
    bottom: 2rem;
    right: 1rem;
    z-index: 1050;
    pointer-events: none;
}

.map-gov-logo img {
    height: 62px;
    width: auto;
    display: block;
    opacity: 0.9;
}

/* ── Left rail + contextual toolbars ─────────────────────── */
.map-left-rail-stack {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 48px;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.map-left-rail {
    width: 48px;
    background: #121417;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.55rem 0.4rem;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}

.rail-btn.map-add-equipamiento-btn {
    width: 48px;
    height: 48px;
    background: #121417;
    border-radius: 16px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
}

.rail-btn {
    border: none;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    background: transparent;
    color: #9ba3af;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

.rail-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.rail-btn.active {
    background: #1f6feb;
    color: #ffffff;
}

.map-left-toolbar {
    position: absolute;
    top: 1rem;
    left: 4.6rem;
    z-index: 1090;
    max-width: min(26rem, calc(100vw - 6rem));
    max-height: calc(100% - 2rem);
    overflow: auto;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #dfe3e8;
    border-radius: 16px;
    padding: 0.8rem;
    box-shadow: 0 14px 32px rgba(9, 12, 17, 0.2);
}

.map-toolbar-panel {
    display: none;
}

.map-toolbar-panel.active {
    display: block;
}

.toolbar-title {
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #606b78;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.toolbar-hint {
    font-size: 0.76rem;
    color: #748091;
    margin-bottom: 0.6rem;
}

/* Category pills stack */
.category-pills-stack {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding-bottom: 0.25rem;
}

.category-pill {
    display: inline-flex;
    align-items: stretch;
    height: 28px;
    border-radius: 999px;
    flex-shrink: 0;
}

.pill-toggle {
    border: 1.5px solid var(--pill-color, #999);
    border-right: none;
    border-radius: 999px 0 0 999px;
    padding: 0 10px;
    background: white;

    font-size: 0.73rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    display: flex;
    align-items: center;
}

.pill-toggle:hover {
    background: color-mix(in oklab, var(--pill-color, #999) 12%, white);
}

.category-pill.active .pill-toggle {
    background: var(--pill-color, #999);
    color: white;
}

.category-pill.partial .pill-toggle {
    background: color-mix(in oklab, var(--pill-color, #999) 30%, white);
    color: color-mix(in oklab, var(--pill-color, #999) 90%, black);
}

.pill-dropdown-btn {
    border: 1.5px solid var(--pill-color, #999);
    border-left: none;
    border-radius: 0 999px 999px 0;
    background: var(--pill-color, #999);
    color: white;
    font-size: 0.7rem;
    padding: 0 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: opacity 0.15s;
}

.pill-dropdown-btn:hover {
    opacity: 0.85;
}

.pill-info-btn {
    margin-left: 3px;
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--pill-color, #999);
    border-radius: 50%;
    background: white;
    color: var(--pill-color, #666);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.pill-info-btn:hover {
    background: color-mix(in oklab, var(--pill-color, #999) 12%, white);
    color: color-mix(in oklab, var(--pill-color, #999) 80%, black);
}

/* Navbar search */
.topbar-search {
    position: relative;
    width: 100%;
}

.topbar-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
    font-size: 0.78rem;
    z-index: 1;
}

.topbar-search input.form-control {
    border-radius: 999px;
    padding-left: 30px;
    padding-right: 28px;
    font-size: 0.85rem;
    height: 34px;
    border-color: #dee2e6;
    background: #f8f9fa;
    transition: background 0.15s, box-shadow 0.15s;
}

.topbar-search input.form-control:focus {
    background: white;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
}

.topbar-search .search-clear-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 1rem;
    line-height: 1;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: 50%;
}

.topbar-search .search-clear-btn:hover {
    background: rgba(0, 0, 0, 0.07);
}

.search-results {
    position: absolute;
    z-index: 9999;
    max-height: 300px;
    overflow-y: auto;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.search-results .list-group-item-header {
    background: #f8f9fa;
    cursor: default;
    pointer-events: none;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: .7rem !important;
}

/* ── Floating layer controls ─────────────────────────────── */
.map-layer-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.map-list-toggle {
    position: absolute;
    left: 50%;
    bottom: 1.25rem;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1.15rem;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.98);
    color: #263445;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, 0.5rem) scale(0.88);
    transform-origin: center bottom;
    transition:
        opacity 180ms ease,
        transform 220ms cubic-bezier(0.2, 0.75, 0.3, 1.2),
        visibility 220ms;
}

.map-list-toggle.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0) scale(1);
}

.map-list-toggle.is-visible:hover {
    background: #fff;
    color: #111827;
    transform: translate(-50%, -2px) scale(1.03);
}

.map-list-toggle.is-visible:focus,
.map-list-toggle.is-visible:active {
    background: #f1f3f5;
    color: #263445;
    opacity: 1;
}

.map-list-toggle:focus-visible {
    outline: 3px solid rgba(31, 111, 235, 0.4);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .map-list-toggle {
        transition: none;
    }
}

.equipamiento-list-sidebar {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1110;
    display: flex;
    flex-direction: column;
    width: min(23rem, calc(100vw - 2rem));
    max-height: calc(100% - 2rem);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #dfe3e8;
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(9, 12, 17, 0.2);
}

.equipamiento-list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0.9rem 0.6rem;
}

.equipamiento-list-order {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0 0.9rem 0.7rem;
    border-bottom: 1px solid #e6e9ed;
}

.equipamiento-list-order .btn.active {
    color: #fff;
    background: #1f6feb;
    border-color: #1f6feb;
}

.equipamiento-list-items {
    overflow-y: auto;
}

.equipamiento-list-group-title {
    margin: 0;
    padding: 0.65rem 0.9rem 0.4rem;
    border-bottom: 2px solid var(--clase1-color, #808080);
    color: var(--clase1-color, #4b5563);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.equipamiento-list-item {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 0;
    border-bottom: 1px solid #edf0f2;
    background: transparent;
    text-align: left;
}

.equipamiento-list-item:hover {
    background: #f5f8fc;
}

.equipamiento-list-item:hover .equipamiento-list-item-name {
    color: #1f6feb;
}

.equipamiento-list-item-name {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1.3;
}

.equipamiento-list-item-meta {
    display: block;
    margin-top: 0.2rem;
    color: #667085;
    font-size: 0.75rem;
    line-height: 1.3;
}

.layer-btn {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.2);
    background: rgba(255, 255, 255, 0.97);
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.02rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    transition: all 0.2s ease;
}

.layer-btn:hover {
    transform: translateY(-1px);
    color: #111827;
}

.layer-btn.active {
    border-color: #1f6feb;
    background: #1f6feb;
    color: #fff;
}

.choropleth-floating-panel {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #d5dbe3;
    border-radius: 12px;
    padding: 0.55rem 0.6rem;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.17);
}

.escala-drawer .escala-btn,
.escala-drawer .titularidad-btn {
    padding: 4px 14px;
    font-size: 0.82rem;
}

.titularidad-btn {
    white-space: normal;
    overflow-wrap: anywhere;
}

.mapboxgl-popup-content {
    max-width: 340px;
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.mapboxgl-popup-content.location-photo-popup {
    padding: 0;
    overflow: hidden;
}

.location-details-popup-has-photo {
    width: min(340px, calc(100vw - 40px));
}

.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
    border-top-color: white;
}

.mapboxgl-popup-anchor-top .mapboxgl-popup-tip {
    border-bottom-color: white;
}

.mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
    border-right-color: white;
}

.mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
    border-left-color: white;
}

.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip {
    border-bottom-color: white;
}

.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
    border-bottom-color: white;
}

.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip {
    border-top-color: white;
}

.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
    border-top-color: white;
}

.mapboxgl-popup-close-button {
    border-radius: 3px;
    right: 12px;
    top: 12px;
}

.popup-loading,
.popup-error {
    text-align: center;
    padding: 10px;
}

.popup-error {
    color: #d32f2f;
}

.location-info {
    padding: 12px 4px 4px;
}

.location-address {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 16px;
}

.location-address i {
    color: var(--popover-bg-color);
    flex: 0 0 auto;
    font-size: 1.1rem;
}


.location-contact-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 6px 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    color: inherit;
    font-size: 0.8rem;
    text-decoration: none;
    background: #fff;
}

.location-contact-btn i {
    color: var(--popover-bg-color);
    font-size: 1.1rem;
}

.location-contact-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.location-year {
    margin-bottom: 14px;
    font-size: 0.85rem;

    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.location-year i {
    color: var(--popover-bg-color);
}

.location-metadata-item {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.location-metadata-item strong {
    flex: 0 0 auto;
}

.location-feedback-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: inherit;
    font-size: 0.85rem;
}

.location-feedback-link i {
    color: var(--popover-bg-color);
}

.location-updated-at {
    display: block;
    margin-top: 12px;
    color: #6c757d;
    font-size: 0.75rem;
    font-style: italic;
}

.location-name {
    font-weight: bold;
    font-size: 1.3em;
    line-height: 1.2;
    margin: 8px 0 6px;
}

.location-category {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.location-category-accent {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border-radius: 5px;
}

.location-header {
    padding: 4px;
}

.location-class {
    font-weight: normal;
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.35;
}

/* Photo hero */
.location-photo-hero {
    position: relative;
    height: 210px;
    overflow: hidden;
    background-color: #f6f7f9;
}

.location-photo-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-photo-effects {
    position: absolute;
    z-index: 1;
    inset: 0;
    pointer-events: none;
}

.location-photo-effects::before,
.location-photo-effects::after {
    position: absolute;
    inset: 24% 0 0;
    content: "";
}

.location-photo-effects::before {
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.72));
}

.location-photo-effects::after {
    -webkit-backdrop-filter: blur(24px);
    backdrop-filter: blur(24px);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 72%);
    mask-image: linear-gradient(to bottom, transparent, #000 72%);
}

.foto-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(0, 0, 0, 0.08);
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.foto-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.location-header-overlay {
    position: absolute;
    z-index: 2;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 48px 16px 16px;
    color: white;
}

.location-header-overlay .location-name {
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.location-header-overlay .location-class {
    color: rgba(255, 255, 255, 0.88);
}

/* ── Floating pill menu ──────────────────────────────── */
.pill-floating-menu {
    display: none;
    position: fixed;
    z-index: 3000;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 6px 4px;
    min-width: 190px;
    max-height: 320px;
    overflow-y: auto;
}

.pill-definition-popover {
    --bs-popover-max-width: min(280px, calc(100vw - 16px));
    --bs-popover-border-width: 0;
    --bs-popover-border-radius: 8px;
    --bs-popover-bg: white;
    --bs-popover-box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    --bs-popover-header-bg: white;
    --bs-popover-header-color: #2f3742;
    --bs-popover-body-color: #4e5a68;
    box-shadow: var(--bs-popover-box-shadow);
}

.pill-definition-popover .popover-header {
    border-bottom: 0;
    padding: 10px 12px 4px;
    font-size: 0.82rem;
    font-weight: 700;
}

.pill-definition-popover .popover-body {
    max-height: 220px;
    overflow-y: auto;
    padding: 0 12px 10px;
    white-space: pre-wrap;
    font-size: 0.8rem;
    line-height: 1.35;
}

/* ── Utility helpers ─────────────────────────────────────── */
.pill-menu-label {
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
}

.pill-dropdown-chevron {
    font-size: 0.6rem;
}

.cursor-pointer {
    cursor: pointer;
}

.region-badge-text {
    max-width: 150px;
}

.input-w-90 {
    width: 90px;
}

.input-w-180 {
    width: 180px;
}

@media (max-width: 575.98px) {
    .map-left-rail-stack {
        top: auto;
        bottom: 0.75rem;
        left: 0.75rem;
        width: auto;
        flex-direction: row;
        align-items: center;
    }

    .map-left-rail {
        width: auto;
        flex-direction: row;
        padding: 0.35rem;
        border-radius: 999px;
    }

    .rail-btn {
        width: 36px;
        aspect-ratio: 1;
        border-radius: 999px;
        font-size: 0.9rem;
    }

    .rail-btn.map-add-equipamiento-btn {
        width: 43px;
        height: 43px;
        border-radius: 999px;
    }

    .map-left-toolbar {
        left: 0.75rem;
        right: 0.75rem;
        top: auto;
        bottom: 3.9rem;
        width: auto;
        max-width: none;
        max-height: min(62vh, 430px);
    }

    .map-gov-logo {
        display: none;
    }

    .map-list-toggle {
        left: auto;
        right: 0.75rem;
        bottom: 0.75rem;
        height: 47px;
        padding: 0 0.85rem;
        font-size: 0.82rem;
        transform: translateY(0.5rem) scale(0.88);
    }

    .map-list-toggle.is-visible {
        transform: translateY(0) scale(1);
    }

    .map-list-toggle.is-visible:hover {
        transform: translateY(-2px) scale(1.03);
    }

    .equipamiento-list-sidebar {
        top: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        width: min(23rem, calc(100vw - 1.5rem));
        max-height: none;
    }
}

/* ── Choropleth legend ─────────────────────────────────────── */
.choropleth-legend {
    margin-top: 1rem;
    padding: 7px 10px 6px;
}

.choropleth-level-switcher {
    display: flex;
    gap: 3px;
    margin-bottom: 5px;
}

.choropleth-level-btn {
    flex: 1;
    padding: 2px 5px;
    font-size: 0.68rem;
    font-weight: 600;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    cursor: pointer;
    text-align: center;
}

.choropleth-level-btn:hover:not(.disabled):not(.active) {
    background: var(--bs-secondary-bg);
}

.choropleth-level-btn.active {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

.choropleth-level-btn.disabled {
    opacity: 0.4;
    cursor: default;
}

.choropleth-legend-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.choropleth-legend-bar {
    display: flex;
    height: 12px;
    border-radius: var(--bs-border-radius-sm);
    overflow: hidden;
    margin-bottom: 3px;
}

.choropleth-swatch {
    flex: 1;
}

.choropleth-legend-note,
.choropleth-legend-labels {
    font-size: 0.68rem;
    color: var(--bs-secondary-color);
}

.choropleth-legend-labels {
    display: flex;
    justify-content: space-between;
}

/* ── Choropleth popups ─────────────────────────────────────── */
.choropleth-popup {
    --popover-bg-color: white;
}

.choropleth-popup .mapboxgl-popup-content {
    padding: 8px 12px;
    min-width: 120px;
}

.choropleth-popup-name {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.choropleth-popup-value {
    font-size: 0.85rem;
    color: var(--bs-primary);
    font-weight: 700;
}

#choropleth-density-filter-note {
    width: 0;
    min-width: 100%;
}
