body {
    margin: 0;
    padding: 0;
    font-family: 'Exo 2', sans-serif;
    background-color: #0d1520;
    color: white;
}

#app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

#sidebar {
    width: 300px;
    background-color: #0a121c;
    border-right: 1px solid #1a2a3a;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 1000;
}

#map {
    flex-grow: 1;
    height: 100vh;
    height: 100dvh;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

/* Dark Theme Adjustments for MapLibre */
.maplibregl-ctrl-attrib {
    background: rgba(10, 18, 28, 0.8) !important;
    color: rgba(255, 255, 255, 0.5) !important;
}

.maplibregl-ctrl-attrib a {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: #0d1520;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    transition: opacity 0.5s;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}



/* Sidebar Toggle for Mobile */
#sidebar-toggle {
    display: none;
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 2000;
    background: #0a121c;
    color: white;
    border: 1px solid #1a2a3a;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
}

/* Reset View Button */
#reset-view {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    background: #0a121c;
    color: white;
    border: 1px solid #1a2a3a;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: background 0.2s;
}

#reset-view:hover {
    background: #1a2a3a;
}

#reset-view::after {
    content: "Reset";
    position: absolute;
    right: 120%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(10, 18, 28, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border: 1px solid #1a2a3a;
}

#reset-view:hover::after {
    opacity: 1;
}

/* Sidebar Internals */
.sidebar-header {
    text-align: center;
}

.sidebar-header h2 {
    margin: 0 0 5px 0;
    font-size: 24px;
}

.sidebar-header .subtitle {
    margin: 0 0 20px 0;
    color: #8a9ba8;
    font-size: 14px;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.filters input,
.filters select {
    background: #1a2a3a;
    border: 1px solid #2a3a4a;
    color: white;
    padding: 10px;
    border-radius: 6px;
    font-family: inherit;
}

#community-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#community-list li {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #1a2a3a;
    cursor: pointer;
    transition: background-color 0.2s;
}

#community-list li:hover {
    background-color: #1a2a3a;
}

.li-badge {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

.li-info {
    display: flex;
    flex-direction: column;
}

.li-info strong {
    font-size: 15px;
    margin-bottom: 4px;
}

.li-info span {
    font-size: 12px;
    color: #8a9ba8;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    #sidebar-toggle {
        display: block;
    }

    #sidebar {
        position: absolute;
        left: -300px;
        transition: left 0.3s ease;
        height: 100vh;
        height: 100dvh;
    }

    #sidebar.open {
        left: 0;
    }

    #map {
        border-radius: 0;
    }
}

/* Floating Detail Card */
#detail-panel {
    position: absolute;
    bottom: -150%;
    /* Hidden */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    background-color: #0a121c;
    border-radius: 16px;
    z-index: 1000;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    box-sizing: border-box;
}

#detail-panel.open {
    bottom: 30px;
    /* Floating above the bottom edge */
}

/* On desktop, keep it floating relative to the center but considering the sidebar */
@media (min-width: 769px) {
    #detail-panel {
        transform: translateX(-150px);
        margin-left: 150px;
        width: 500px;
    }
}

.panel-top-bar {
    width: 100%;
    height: 8px;
    background-color: var(--community-accent-color, #ffffff);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.panel-content {
    padding: 24px;
}

#close-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    color: #8a9ba8;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
}

#close-panel:hover {
    color: white;
}

/* Header Area */
.panel-header {
    margin-bottom: 20px;
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-right: 20px;
    /* space for close button */
}

.pnombre {
    margin: 0;
    font-size: 22px;
    color: white;
    font-weight: 700;
    line-height: 1.2;
}

.telecom-icon {
    width: 24px;
    height: 24px;
    color: white;
    flex-shrink: 0;
    margin-left: 12px;
}

.pdesc {
    color: #a0aec0;
    font-size: 14px;
    line-height: 1.5;
    margin: 12px 0 0 0;
}

/* Inner Grid Layout */
.panel-inner-container {
    background: #111b27;
    border: 1px solid #2d3748;
    border-radius: 12px;
    display: flex;
    position: relative;
    min-height: 90px;
}

.panel-data-area {
    flex: 1;
    padding: 16px;
    padding-right: 80px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 4px auto;
    row-gap: 0;
    column-gap: 12px;
    z-index: 2;
    transition: padding-right 0.3s;
}

.panel-inner-container.no-image .panel-data-area {
    padding-right: 16px;
}

.panel-inner-container.no-image .image-placeholder {
    display: none;
}

.data-row {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.estado-row {
    grid-column: 1;
    grid-row: 1;
}

.pueblo-row {
    grid-column: 2;
    grid-row: 1;
}

.tech-row {
    grid-column: 1 / 3;
    grid-row: 3;
}

.data-icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    color: white;
}

.data-label {
    color: #a0aec0;
    margin-right: 6px;
}

.data-value {
    color: white;
    font-weight: 600;
}

.tech-icon,
.tech-value {
    color: var(--community-accent-color, #ffffff);
}

/* Image Placeholder Circle */
.image-placeholder {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 100px;
    height: 100px;
    background-color: white;
    border-radius: 50%;
    z-index: 3;
    overflow: hidden;
}

/* Ensure future img child behaves */
.image-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* CTA Section */
.panel-cta-section {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.panel-cta-section.hidden {
    display: none;
}

.cta-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--community-accent-color, #ffffff);
    color: var(--community-accent-color, #ffffff);
    border-radius: 12px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.cta-button:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cta-button.hidden {
    display: none;
}

.cta-icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}


.cursor-pointer {
    cursor: pointer;
}

/* State tooltip popup styling */
.state-tooltip .maplibregl-popup-content {
    background: rgba(10, 18, 28, 0.9);
    color: white;
    border: 1px solid #1a2a3a;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.state-tooltip .maplibregl-popup-tip {
    border-top-color: rgba(10, 18, 28, 0.9) !important;
    border-bottom-color: rgba(10, 18, 28, 0.9) !important;
}

/* Active Filters UI */
#active-filters-container {
    margin-bottom: 20px;
    padding-top: 10px;
    border-top: 1px solid #1a2a3a;
}

#active-filters-container.hidden {
    display: none;
}

.active-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.active-filters-label {
    font-size: 11px;
    font-weight: bold;
    color: #8a9ba8;
    letter-spacing: 0.05em;
}

#clear-filters {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

#clear-filters:hover {
    text-decoration: underline;
}

#active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    background: #1a2a3a;
    color: white;
    border: 1px solid #2a3a4a;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-chip:hover {
    background: #2a3a4a;
}

.filter-chip-close {
    margin-left: 6px;
    color: #8a9ba8;
    font-weight: bold;
}

.filter-chip:hover .filter-chip-close {
    color: white;
}

#results-count {
    font-size: 13px;
    color: #8a9ba8;
    margin-bottom: 10px;
    font-weight: 600;
}

#community-list li.selected {
    background-color: #1a2a3a;
    border-left: 3px solid #3b82f6;
}

/* Detail Panel Responsive Adjustments */
@media (max-width: 460px) {
    #detail-panel {
        width: 95%;
    }

    .image-placeholder {
        display: none;
    }

    .panel-data-area {
        padding-right: 16px;
        /* Remove extra padding for image */
    }

    .pnombre {
        font-size: 18px;
        /* Smaller title font */
    }

    .pdesc {
        font-size: 13px;
        /* Smaller description font */
    }
}

@media (max-width: 260px) {
    .panel-data-area {
        grid-template-columns: 1fr;
        /* Stack vertically */
        grid-template-rows: auto auto auto;
        row-gap: 8px;
    }

    .estado-row {
        grid-column: 1;
        grid-row: 1;
    }

    .pueblo-row {
        grid-column: 1;
        grid-row: 2;
    }

    .tech-row {
        grid-column: 1;
        grid-row: 3;
    }
}