/* ============================================
   Civic Map Dashboard - New UI/UX Design
   ============================================ */

:root {
    --cm-primary: #1E489B;
    --cm-primary-light: #E3F2FD;
    --cm-primary-dark: #001F59;
    --cm-green: #74C465;
    --cm-green-light: #E8F5E9;
	--cm-green-dark: #74C465;
    --cm-Tint: #00A79D;
    --cm-Tint-light: #00A79D;
    --cm-Tint-dark: #00A79D;
    --cm-orange: #FF6B35;
    --cm-orange-light: #FFAC1C;
	--cm-orange-dark: #E97451;
    --cm-gray-50: #FAFAFA;
    --cm-gray-100: #F5F5F5;
    --cm-gray-200: #EEEEEE;
    --cm-gray-300: #E0E0E0;
    --cm-gray-400: #BDBDBD;
    --cm-gray-500: #9E9E9E;
    --cm-gray-600: #757575;
    --cm-gray-700: #616161;
    --cm-gray-800: #424242;
    --cm-gray-900: #212121;
    --cm-white: #FFFFFF;
    --cm-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --cm-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --cm-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --cm-radius-sm: 6px;
    --cm-radius-md: 10px;
    --cm-radius-lg: 16px;
    --cm-radius-full: 9999px;
    --cm-transition: 0.2s ease;
    --cm-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --cm-header-height: 0px; /* Adjust based on WP header */
    --cm-body-font-size: 15px;
    --cm-secondary-font-size: 13px;
    --cm-muted: #6b7280;
    --cm-card-bg: #ffffff;
} --cm-card-bg: #ffffff;

/* ============================================
   Astra theme full-width override for Collabora page template.
   WordPress adds body class  page-template-{filename-no-ext}  for
   custom page templates; the file is collabora_template_code_OLD.php.
   ============================================ */
body.page-template-collabora_template_code_old .ast-container,
body.page-template-collabora_template_code_old #primary,
body.page-template-collabora_template_code_old .content-area,
body.page-template-collabora_template_code_old .site-content,
body.page-template-collabora_template_code_old .entry-content,
body.page-template-collabora_template_code_old .ast-article-post {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    float: none !important;
}

/* Reset for dashboard area */
.civic-map-dashboard *,
.civic-map-dashboard *::before,
.civic-map-dashboard *::after {
    box-sizing: border-box;
}

.civic-map-dashboard {
    font-family: var(--cm-font);
    color: var(--cm-gray-900);
    line-height: 1.5;
    background: var(--cm-gray-50);
    display: flex;
    flex-direction: column;
    height: 75vh; /* Adjust this to make the dashboard taller or shorter */
    min-height: 600px;
    width: 100%;
    max-width: 1240px;
    margin: 22px auto;
    padding: 12px;
    box-shadow: 0 12px 40px rgba(14,30,37,0.08);
    background: #f8f9fa; /* Matches your grey background */
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    overflow: hidden;
}

/* Override Bootstrap/WP container constraints */
.civic-map-dashboard,
.civic-map-dashboard .cm-main-content,
.civic-map-dashboard .cm-right-panel {
    max-width: none !important;
}

/* ============================================
   Search Bar (inside top tabs, .cm-search-bar-inline)
   ============================================ */
.cm-search-bar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cm-search-input-wrapper {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.cm-search-input-wrapper .cm-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cm-gray-500);
    font-size: 18px;
    pointer-events: none;
}

.cm-search-input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--cm-gray-300);
    border-radius: var(--cm-radius-full);
    font-size: 14px;
    font-family: var(--cm-font);
    color: var(--cm-gray-800);
    background: var(--cm-gray-50);
    transition: border-color var(--cm-transition), box-shadow var(--cm-transition);
    outline: none;
}

.cm-search-input:focus {
    border-color: var(--cm-primary);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
    background: var(--cm-white);
}

.cm-search-input::placeholder {
    color: var(--cm-gray-400);
}

.cm-filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid var(--cm-gray-300);
    border-radius: var(--cm-radius-full);
    background: var(--cm-white);
    font-size: 14px;
    font-family: var(--cm-font);
    color: var(--cm-gray-700);
    cursor: pointer;
    transition: all var(--cm-transition);
}

.cm-filter-btn:hover {
    border-color: var(--cm-primary);
    color: var(--cm-primary);
    background: var(--cm-primary-light);
}

.cm-filter-btn .cm-icon {
    font-size: 16px;
}

.cm-search-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.cm-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--cm-gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background var(--cm-transition);
}

.cm-action-btn:hover {
    background: var(--cm-gray-100);
}

.cm-action-btn .cm-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #E53935;
    border-radius: 50%;
}

/* ============================================
   Category Tabs  (defined fully at bottom of file)
   ============================================ */

.cm-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: var(--cm-radius-full);
    border: 2px solid transparent;
    background: var(--cm-gray-100);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--cm-font);
    color: var(--cm-gray-700);
    cursor: pointer;
    transition: all var(--cm-transition);
    white-space: nowrap;
    user-select: none;
}

.cm-tab:hover {
    background: var(--cm-gray-200);
}

.cm-tab.active {
    border-color: var(--cm-primary);
    background: var(--cm-primary-light);
    color: var(--cm-primary-dark);
}


.cm-tab-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--cm-white);
}

.cm-tab[data-category="all"] .cm-tab-icon,
.cm-tab[data-category="trasporto_pubblico"] .cm-tab-icon,
.cm-tab[data-category="trasporto_privato"] .cm-tab-icon,
.cm-tab[data-category="trasporto_merci"] .cm-tab-icon,
.cm-tab[data-category="accessibilita"] .cm-tab-icon,
.cm-tab[data-category="tecnologie_telematiche"] .cm-tab-icon {
    background: var(--cm-primary);
}

.cm-tab[data-category="mobilita-ciclistica"] .cm-tab-icon,
.cm-tab[data-category="mobilita_pedonale"] .cm-tab-icon {
    background: var(--cm-green);
}

.cm-tab[data-category="sicurezza_stradale"] .cm-tab-icon {
    background: var(--cm-orange);
}

.cm-tab[data-category="parcheggi"] .cm-tab-icon {
    background: #6c6cff;
}

.cm-tab[data-category="altro"] .cm-tab-icon {
    background: #9e9e9e;
}

.cm-tab-count {
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--cm-radius-full);
    background: var(--cm-gray-300);
    color: var(--cm-gray-700);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-tab.active .cm-tab-count {
    background: rgba(25, 118, 210, 0.2);
    color: var(--cm-primary-dark);
}

.cm-tab[data-category="biodiversity"].active .cm-tab-count {
    background: rgba(56, 142, 60, 0.2);
    color: var(--cm-green);
}

.cm-tab[data-category="contributions"].active .cm-tab-count {
    background: rgba(245, 124, 0, 0.2);
    color: var(--cm-orange);
}

/* ============================================
   Main Content Area (Split View)
   ============================================ */
.cm-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ============================================
   Left Panel (Cards List)
   ============================================ */
.cm-left-panel {
    width: 340px;
    min-width: 340px;
    display: flex;
    flex-direction: column;
    background: var(--cm-white);
    border-right: 1px solid var(--cm-gray-200);
    overflow: hidden;
    min-height: 0;
}

.cm-panel-search {
    padding: 14px 16px;
    border-bottom: 1px solid var(--cm-gray-200);
    background: var(--cm-white);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-panel-search-input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    border: 1px solid var(--cm-gray-300);
    border-radius: var(--cm-radius-sm);
    font-size: 13px;
    font-family: var(--cm-font);
    color: var(--cm-gray-800);
    background: var(--cm-gray-50);
    outline: none;
    transition: border-color var(--cm-transition);
}

.cm-panel-search-input:focus {
    border-color: var(--cm-primary);
}

.cm-panel-search-wrapper {
    position: relative;
    flex: 1;
}

.cm-panel-search-wrapper .cm-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cm-gray-400);
    font-size: 18px;
    pointer-events: none;
}

.cm-panel-search-wrapper .cm-panel-search-input {
    padding-left: 42px;
    border-radius: 12px;
    border-color: rgba(148, 163, 184, 0.28);
    background: #ffffff;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

/* Sub-category chips */
.cm-subcategory-chips {
    padding: 8px 16px 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--cm-gray-200);
}

.cm-chip {
    padding: 5px 14px;
    border-radius: var(--cm-radius-full);
    border: 1px solid var(--cm-gray-300);
    font-size: 12px;
    font-family: var(--cm-font);
    color: var(--cm-gray-600);
    background: var(--cm-white);
    cursor: pointer;
    transition: all var(--cm-transition);
    user-select: none;
}

.cm-chip:hover {
    border-color: var(--cm-primary);
    color: var(--cm-primary);
}

.cm-chip.active {
    background: var(--cm-primary);
    border-color: var(--cm-primary);
    color: var(--cm-white);
}

/* Proposal Cards List */
.cm-cards-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cm-cards-list::-webkit-scrollbar {
    width: 6px;
}

.cm-cards-list::-webkit-scrollbar-track {
    background: transparent;
}

.cm-cards-list::-webkit-scrollbar-thumb {
    background: var(--cm-gray-300);
    border-radius: 3px;
}

/* Individual Proposal Card */

.cm-card {
    border: 2px solid var(--cm-gray-200);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: all var(--cm-transition);
    background: var(--cm-white);
    position: relative;
    box-shadow: 0 6px 18px rgba(14,30,37,0.04);
}

.cm-card:hover {
    border-color: var(--cm-primary);
    box-shadow: 0 10px 30px rgba(14,30,37,0.06);
}

.cm-card.active {
    border-color: var(--cm-primary);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
    background: var(--cm-primary-light);
}

.cm-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.cm-card-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: var(--cm-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--cm-white);
}

.cm-card-icon.mobility {
    background: var(--cm-primary);
}

.cm-card-icon.biodiversity {
    background: var(--cm-green);
}

.cm-card-icon.contributions {
    background: var(--cm-orange);
}

.cm-card-title-section {
    flex: 1;
    min-width: 0;
}

.cm-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--cm-gray-900);
    margin: 0 0 2px;
    line-height: 1.3;
}

.cm-card-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--cm-radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.cm-card-status.planned {
    background: var(--cm-primary-light);
    color: var(--cm-primary);
}

.cm-card-status.in-progress {
    background: #FFF8E1;
    color: #F9A825;
}

.cm-card-status.protected {
    background: var(--cm-green-light);
    color: var(--cm-green);
}

.cm-card-status.under-review {
    background: var(--cm-orange-light);
    color: var(--cm-orange);
}

.cm-card-status.completed {
    background: #E8F5E9;
    color: #2E7D32;
}

.cm-card-description {
    font-size: 13px;
    color: var(--cm-gray-600);
    margin: 0 0 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cm-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cm-card-category-tag {
    padding: 3px 10px;
    border-radius: var(--cm-radius-full);
    font-size: 11px;
    font-weight: 500;
    background: var(--cm-primary-light);
    color: var(--cm-primary);
}

.cm-card[data-category="biodiversity"] .cm-card-category-tag {
    background: var(--cm-green-light);
    color: var(--cm-green);
}

.cm-card[data-category="contributions"] .cm-card-category-tag {
    background: var(--cm-orange-light);
    color: var(--cm-orange);
}

.cm-card-date {
    font-size: 11px;
    color: var(--cm-gray-500);
}

/* ============================================
   Right Panel (Map)
   ============================================ */
.cm-right-panel {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.cm-map-container {
    flex: 1;
    position: relative;
    background: #fff;
    min-height: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: none;
    border: 1px solid rgba(224,224,224,0.6);
}

.cm-map-container #cm-map,
.cm-map-container #mappa {
    width: 100% !important;
    height: 100% !important;
    position: absolute;
    top: 0;
    left: 0;
}

/* Ensure the map's tile layer respects rounded corners */
.cm-map-container > div,
.cm-map-container iframe,
.cm-map-container img {
    border-radius: 12px;
}

/* Fix for the top filters wrapping weirdly */
.cm-filters-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto; /* Allows scrolling if on small screen */
    gap: 10px;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

/* Map controls */
.cm-map-controls {
    position: absolute;
    right: 16px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.cm-map-control-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--cm-radius-sm);
    border: none;
    background: var(--cm-white);
    box-shadow: var(--cm-shadow-md);
    color: var(--cm-gray-700);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--cm-transition);
}

.cm-map-control-btn:hover {
    background: var(--cm-gray-100);
}

/* ============================================
   Map Popup (Info Window)
   ============================================ */
.cm-map-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 340px;
    background: var(--cm-white);
    border-radius: var(--cm-radius-lg);
    box-shadow: var(--cm-shadow-lg);
    z-index: 50;
    display: none;
    overflow: hidden;
    animation: cm-popup-in 0.25s ease;
}

@keyframes cm-popup-in {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.cm-map-popup.visible {
    display: block;
}

.cm-popup-header {
    padding: 16px 20px;
    padding-right: 44px;
    border-bottom: 1px solid var(--cm-gray-200);
}

.cm-popup-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--cm-gray-900);
    margin: 0 0 4px;
}

.cm-popup-description {
    font-size: 13px;
    color: var(--cm-gray-600);
    margin: 0;
    line-height: 1.4;
}

.cm-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--cm-gray-100);
    color: var(--cm-gray-600);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--cm-transition);
}

.cm-popup-close:hover {
    background: var(--cm-gray-200);
}

.cm-popup-details {
    padding: 16px 20px;
}

.cm-popup-detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.cm-popup-detail-row:not(:last-child) {
    border-bottom: 1px solid var(--cm-gray-100);
}

.cm-popup-detail-icon {
    width: 20px;
    color: var(--cm-gray-500);
    font-size: 16px;
    text-align: center;
}

.cm-popup-detail-label {
    font-size: 12px;
    color: var(--cm-gray-500);
    min-width: 80px;
}

.cm-popup-detail-value {
    font-size: 13px;
    color: var(--cm-gray-800);
    font-weight: 500;
}

.cm-popup-footer {
    padding: 12px 20px 16px;
}

.cm-popup-view-btn {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--cm-radius-sm);
    background: var(--cm-primary);
    color: var(--cm-white);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--cm-font);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background var(--cm-transition);
}

.cm-popup-view-btn:hover {
    background: var(--cm-primary-dark);
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
    .cm-left-panel {
        width: 320px;
        min-width: 320px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .cm-search-bar {
        padding: 10px 16px;
        gap: 10px;
    }

    .cm-filter-btn span:not(.cm-icon) {
        display: none;
    }

    .cm-search-actions {
        gap: 4px;
    }

    .cm-category-tabs {
        padding: 10px 16px;
        gap: 8px;
    }

    .cm-tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    .cm-tab span:not(.cm-tab-icon):not(.cm-tab-count) {
        display: none;
    }

    .cm-main-content {
        flex-direction: column-reverse;
        height: auto;
    }

    .cm-left-panel {
        width: 100%;
        min-width: 100%;
        max-height: 50vh;
        border-right: none;
        border-top: 1px solid var(--cm-gray-200);
        border-radius: var(--cm-radius-lg) var(--cm-radius-lg) 0 0;
        position: relative;
        z-index: 20;
    }

    .cm-right-panel {
        height: 50vh;
    }


    .cm-map-popup {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        transform: none;
        border-radius: var(--cm-radius-lg) var(--cm-radius-lg) 0 0;
        max-height: 60vh;
        overflow-y: auto;
    }

    .cm-map-popup.visible {
        animation: cm-popup-slide-up 0.3s ease;
    }

    @keyframes cm-popup-slide-up {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

@media (max-width: 480px) {
    .cm-search-bar {
        padding: 8px 12px;
    }

    .cm-category-tabs {
        padding: 8px 12px;
    }

    .cm-cards-list {
        padding: 8px;
    }

    .cm-card {
        padding: 12px;
    }
}

/* ============================================
   Loading States
   ============================================ */
.cm-skeleton {
    background: linear-gradient(90deg, var(--cm-gray-200) 25%, var(--cm-gray-100) 50%, var(--cm-gray-200) 75%);
    background-size: 200% 100%;
    animation: cm-shimmer 1.5s infinite;
    border-radius: var(--cm-radius-sm);
}

@keyframes cm-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.cm-card-skeleton {
    height: 120px;
    border-radius: var(--cm-radius-md);
}

/* ============================================
   Empty State
   ============================================ */
.cm-empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--cm-gray-500);
}

.cm-empty-state-icon {
    font-size: 48px;
    color: var(--cm-gray-300);
    margin-bottom: 12px;
}

.cm-empty-state-text {
    font-size: 14px;
    margin: 0;
}

/* ============================================
   Layers Panel (Sidebar overlay on right panel)
   ============================================ */
.cm-layers-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: var(--cm-white);
    box-shadow: -4px 0 16px rgba(0,0,0,0.1);
    z-index: 60;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.cm-layers-panel.visible {
    display: flex;
}

.cm-layers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cm-gray-200);
}

.cm-layers-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--cm-gray-900);
}

.cm-popup-footer .cm-popup-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(180deg, var(--cm-primary), var(--cm-primary-dark));
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(25,118,210,0.14);
}

/* Popup pointer (triangle) */
.cm-map-popup::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -12px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--cm-white);
    filter: drop-shadow(0 -2px 2px rgba(0,0,0,0.04));
}

/* subtle pointer animation and visible state */
.cm-map-popup.visible {
    animation: cm-popup-bounce 340ms cubic-bezier(.2,.8,.2,1);
}

@keyframes cm-popup-bounce {
    0% { transform: translate(-50%, -52%) scale(.98); opacity: 0; }
    60% { transform: translate(-50%, -49%) scale(1.02); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* InfoBubble wrapper animation (for third-party popup) */
.map-popup-wrapper.cm-popup-animate {
    animation: cm-popup-bounce 420ms cubic-bezier(.2,.8,.2,1);
}


.cm-layers-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--cm-gray-100);
    color: var(--cm-gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-layers-close:hover {
    background: var(--cm-gray-200);
}

.cm-layers-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.cm-layers-content #interventi_sidebar {
    font-size: 13px;
}

.cm-layers-content .sidebar.mapcontrols {
    border: none;
    padding: 0;
    margin: 0;
}

/* ============================================
   Propose Overlay (Modal)
   ============================================ */
.cm-propose-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.cm-propose-overlay.visible {
    display: flex;
}

.cm-propose-panel {
    background: var(--cm-white);
    border-radius: var(--cm-radius-lg);
    box-shadow: var(--cm-shadow-lg);
    width: 460px;
    max-width: 90vw;
    overflow: hidden;
}

.cm-propose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--cm-gray-200);
}

.cm-propose-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.cm-propose-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--cm-gray-100);
    color: var(--cm-gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cm-propose-close:hover {
    background: var(--cm-gray-200);
}

.cm-propose-body {
    padding: 24px;
}

.cm-propose-info {
    font-size: 14px;
    color: var(--cm-gray-700);
    margin: 0 0 16px;
}

.cm-propose-address {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cm-propose-address input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--cm-gray-300);
    border-radius: var(--cm-radius-sm);
    font-size: 14px;
    font-family: var(--cm-font);
    outline: none;
}

.cm-propose-address input:focus {
    border-color: var(--cm-primary);
}

.cm-propose-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--cm-radius-sm);
    background: var(--cm-primary);
    color: var(--cm-white);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--cm-font);
    cursor: pointer;
    transition: background var(--cm-transition);
}

.cm-propose-btn:hover {
    background: var(--cm-primary-dark);
}

.cm-propose-hint {
    font-size: 13px;
    color: var(--cm-gray-500);
    margin: 0;
    font-style: italic;
}

/* ============================================
   Comments Section
   ============================================ */
.cm-comments-section {
    background: var(--cm-white);
    border-top: 1px solid var(--cm-gray-200);
    padding: 24px;
}

.cm-comments-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--cm-gray-900);
    margin: 0 0 16px;
}

/* ============================================
   Pagination
   ============================================ */
.cm-pagination {
    padding: 12px 16px;
    border-top: 1px solid var(--cm-gray-200);
    text-align: center;
    font-size: 13px;
}

.cm-pagination a,
.cm-pagination span {
    display: inline-block;
    padding: 6px 12px;
    margin: 0 3px;
    border-radius: var(--cm-radius-sm);
    text-decoration: none;
    color: var(--cm-gray-700);
    transition: all var(--cm-transition);
}

.cm-pagination a:hover {
    background: var(--cm-primary-light);
    color: var(--cm-primary);
}

.cm-pagination .current {
    background: var(--cm-primary);
    color: var(--cm-white);
    font-weight: 600;
}

/* ============================================
   Utility classes
   ============================================ */
.cm-hidden {
    display: none !important;
}

.cm-fade-in {
    animation: cm-fadeIn 0.3s ease;
}

@keyframes cm-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   Override existing sidebar styles inside layers panel
   ============================================ */
.cm-layers-content .mapcontrols {
    width: 100% !important;
    position: static !important;
    border: none !important;
    box-shadow: none !important;
}

.cm-layers-content .mapcontrols h2 {
    font-size: 14px;
    margin: 0 0 8px;
}

/* ============================================
   Mobile: Layers panel full-width
   ============================================ */
@media (max-width: 768px) {
    .cm-layers-panel {
        width: 100%;
    }

    .cm-propose-panel {
        width: 100%;
        max-width: 100%;
        border-radius: var(--cm-radius-lg) var(--cm-radius-lg) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
    }

    .cm-propose-overlay {
        align-items: flex-end;
    }
}

/* ============================================
   Top 3-tab bar
   ============================================ */
.cm-top-tabs {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,250,252,0.98));
    border-bottom: 1px solid rgba(224,224,224,0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    position: sticky;
    top: var(--cm-header-height);
    z-index: 120;
    gap: 12px;
    backdrop-filter: blur(4px);
    border-radius: 10px 10px 0 0;
    flex-shrink: 0;
}

.cm-top-tabs-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-top-tab {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 28px;
    border: none;
    background: rgba(250,250,252,0.6);
    font-family: var(--cm-font);
    font-size: 15px;
    font-weight: 600;
    color: var(--cm-gray-700);
    cursor: pointer;
    transition: all 220ms cubic-bezier(.2,.9,.3,1);
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(14,30,37,0.04) inset;
}

.cm-top-tab .material-icons {
    font-size: 18px;
    opacity: 0.9;
}

.cm-top-tab:hover {
    color: var(--cm-primary);
    background: rgba(25,118,210,0.06);
}

.cm-top-tab.active {
    color: var(--cm-white);
    background: linear-gradient(180deg, var(--cm-primary), var(--cm-primary-dark));
    box-shadow: 0 8px 24px rgba(25,118,210,0.14);
    transform: translateY(-1px);
}

.cm-top-tab.cm-tab-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: transparent;
}

.cm-search-bar-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 520px;
    margin-left: auto;
}

.cm-search-bar-inline .cm-search-input-wrapper {
    flex: 1;
}

/* ============================================
   View containers
   ============================================ */
.cm-view {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* Hide inactive tabs securely without breaking flex */
.cm-view.cm-hidden {
    display: none !important;
}

/* 3. Constrain the sidebar */
.cm-sidebar {
    width: 350px;
    min-width: 350px;
    height: 100%;
    overflow-y: auto; /* Adds scrollbar only to the list */
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    padding: 15px;
}


/* ============================================
   Naviga: category chips row above split
   ============================================ */
.cm-category-tabs {
    background: var(--cm-white);
    border-bottom: 1px solid var(--cm-gray-200);
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: start;
	display:inline-block;
    gap: 8px;
    width: 100%;
    flex: 0 0 auto;
    overflow-x: auto;
    flex-shrink: 0;
    overflow-y: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.cm-category-tabs .cm-tab {
    flex: 0 0 auto;
}

/* When category tabs are placed in the left sidebar, display as horizontal scrollable chips */
.cm-left-panel .cm-category-tabs {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--cm-gray-200);
    overflow-x: auto;
    flex-shrink: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.cm-left-panel .cm-category-tabs::-webkit-scrollbar {
    display: none;
}

.cm-left-panel .cm-category-tabs .cm-tab {
    display: inline-flex;
    align-items: center;
    width: auto;
    flex-shrink: 0;
    padding: 5px 10px;
    margin-top: 2px;
    gap: 5px;
    background: var(--cm-gray-100);
    border: 1.5px solid transparent;
    border-radius: 99px;
    transition: all 180ms ease;
    font-size: 12px;
    font-weight: 500;
}

.cm-left-panel .cm-category-tabs .cm-tab .cm-tab-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
    /* color: #e40942; */
}

.cm-left-panel .cm-category-tabs .cm-tab span.cm-tab-label {
    flex: unset;
    text-align: left;
    color: var(--cm-primary-dark);
    font-weight: 500;
    white-space: nowrap;
}

.cm-left-panel .cm-category-tabs .cm-tab .cm-tab-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(16,24,32,0.08);
    color: var(--cm-gray-600);
    font-weight: 600;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cm-left-panel .cm-category-tabs .cm-tab:hover {
    background: var(--cm-gray-200);
    border-color: var(--cm-gray-300);
}

.cm-left-panel .cm-category-tabs .cm-tab.active {
    background: var(--cm-primary-light);
    border: 1.5px solid rgba(25,118,210,0.3);
    color: var(--cm-primary-dark);
}

.cm-left-panel .cm-category-tabs .cm-tab.active .cm-tab-count {
    background: var(--cm-primary);
    color: #fff;
}

.cm-category-tabs::-webkit-scrollbar { display: none; }

/* ============================================
   Propose view: form panel
   ============================================ */
.cm-propose-form-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

/* ============================================
   Proposta view: all small-screen overrides.
   Uses #view-proposta selectors (ID specificity)
   so these beat every plain .cm-left-panel rule
   regardless of CSS order or media-query size.
   ============================================ */
@media (max-width: 1024px) {
    /* Column layout: compact form on top, map fills the rest */
    #view-proposta .cm-main-content {
        flex-direction: column;
        height: 100%;
    }

    /* Form panel: back in document flow, auto height */
    #view-proposta .cm-left-panel {
        position: relative;
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 0;
        max-height: none;
        transform: none;
        flex-shrink: 0;
        border-radius: 0;
        box-shadow: none;
        border-right: none;
        border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    }

    /* Hide the CSS-generated ::before handle bar */
    #view-proposta .cm-left-panel::before {
        display: none;
    }

    /* Map fills all remaining height */
    #view-proposta .cm-right-panel {
        flex: 1;
        height: auto;
        min-height: 200px;
    }

    /* Compact form panel */
    #view-proposta .cm-propose-form-panel {
        gap: 0;
        height: auto;
        padding: 12px 16px;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* Hide non-essential text */
    #view-proposta .cm-propose-form-header p,
    #view-proposta .cm-propose-info,
    #view-proposta .cm-propose-hint {
        display: none;
    }

    /* One-line header: icon + title inline */
    #view-proposta .cm-propose-form-header {
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
    }

    #view-proposta .cm-propose-form-icon {
        font-size: 20px;
    }

    #view-proposta .cm-propose-form-header h3 {
        font-size: 14px;
        margin: 0;
    }

    #view-proposta .cm-propose-form-body {
        gap: 0;
    }
}

/* On very small screens hide the header too — address bar only */
@media (max-width: 480px) {
    #view-proposta .cm-propose-form-header {
        display: none;
    }
}

.cm-propose-form-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.cm-propose-form-icon {
    font-size: 36px;
    color: var(--cm-primary);
    margin-top: 4px;
}

.cm-propose-form-header h3 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
}

.cm-propose-form-header p {
    margin: 0;
    font-size: 14px;
    color: var(--cm-gray-600);
}

.cm-propose-form-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cm-propose-address-row {
    display: flex;
    gap: 8px;
}

.cm-address-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--cm-gray-300);
    border-radius: var(--cm-radius-sm);
    font-size: 14px;
    font-family: var(--cm-font);
    outline: none;
    transition: border-color var(--cm-transition);
}

.cm-address-input:focus {
    border-color: var(--cm-primary);
}

.cm-map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--cm-gray-500);
    gap: 12px;
    font-size: 14px;
    text-align: center;
}

/* ============================================
   Elenco view
   ============================================ */
.cm-elenco-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--cm-white);
    border-bottom: 1px solid var(--cm-gray-200);
    gap: 16px;
    flex-wrap: wrap;
}

.cm-elenco-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.cm-elenco-header h2 .material-icons {
    color: var(--cm-primary);
}

.cm-elenco-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 360px;
}

.cm-elenco-search-wrapper .cm-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cm-gray-400);
    font-size: 16px;
    pointer-events: none;
}

.cm-elenco-search-wrapper .cm-panel-search-input {
    padding-left: 36px;
}

.cm-elenco-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    align-content: start;
}

.cm-elenco-card {
    background: var(--cm-white);
    border: 1px solid var(--cm-gray-200);
    border-radius: var(--cm-radius-md);
    overflow: hidden;
    position: relative;
    transition: box-shadow var(--cm-transition), transform var(--cm-transition);
    cursor: pointer;
}

.cm-elenco-card:hover {
    box-shadow: var(--cm-shadow-md);
    transform: translateY(-2px);
}

/* Overlay link: stretches the title <a> to cover the whole card */
.cm-elenco-card-title a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}


.cm-elenco-card-img {
    height: 160px;
    overflow: hidden;
}

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

.cm-elenco-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cm-elenco-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cm-elenco-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.cm-elenco-card-title a {
    color: var(--cm-gray-900);
    text-decoration: none;
}

.cm-elenco-card-title a:hover {
    color: var(--cm-primary);
}

.cm-elenco-card-desc {
    font-size: 13px;
    color: var(--cm-gray-600);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cm-elenco-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--cm-gray-100);
    margin-top: auto;
    position: relative;
    z-index: 2;
}

.cm-elenco-comment-count {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--cm-gray-500);
}

.cm-elenco-read-more {
    font-size: 13px;
    font-weight: 600;
    color: var(--cm-primary);
    text-decoration: none;
}

.cm-elenco-read-more:hover {
    text-decoration: underline;
}

.cm-comments-placeholder {
    color: var(--cm-gray-500);
    font-size: 14px;
}

/* ============================================
   Mobile: top tabs collapse
   ============================================ */
@media (max-width: 768px) {
    .cm-top-tabs {
        flex-wrap: wrap;
        padding: 0 12px;
        gap: 8px;
    }

    .cm-top-tab {
        padding: 12px 14px;
        font-size: 13px;
    }

    .cm-top-tab span:not(.material-icons):not(.cm-top-tab-count) {
        display: none;
    }

    .cm-search-bar-inline {
        width: 100%;
        max-width: 100%;
        padding: 8px 0;
        margin-left: 0;
    }

    .cm-elenco-grid {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
    }

    .cm-elenco-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cm-elenco-search-wrapper {
        max-width: 100%;
        width: 100%;
    }

}

/* Horizontal card layout for tablets and mobile (up to 960px) */
@media (max-width: 960px) {
    .cm-elenco-grid {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 12px;
    }

    .cm-elenco-card {
        display: flex;
        flex-direction: row;
        align-items: stretch;
        min-height: 120px;
    }

    .cm-elenco-card-img {
        width: 130px;
        min-width: 130px;
        height: auto;
        flex-shrink: 0;
    }

    .cm-elenco-card-body {
        flex: 1;
        min-width: 0;
        padding: 10px 14px;
    }

    .cm-elenco-card-title {
        font-size: 14px;
        line-height: 1.35;
    }

    .cm-elenco-card-desc {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}


/* Ensure the popups overlay standard CMS headers */
.cm-map-popup {
    z-index: 9999 !important; 
}

.cm-propose-overlay {
    z-index: 10000 !important; 
}

/* Dashboard must clip its children — inner panels have their own overflow-y: auto */
.civic-map-dashboard {
    overflow: hidden !important;
}

/* Ensure map tiles render correctly and don't get squished by theme flexboxes */
.cm-map-container #cm-map,
.cm-map-container #mappa {
    max-width: none !important;
}

/* ============================================
   Reference-inspired visual polish
   ============================================ */
.civic-map-dashboard {
    height: min(88vh, 980px);
    width: min(95vw, 1640px) !important;
    width: 100%;
    min-height: 760px;
    border-radius: 28px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background:
        radial-gradient(circle at top left, rgba(25, 118, 210, 0.10), transparent 28%),
        radial-gradient(circle at top right, rgba(245, 124, 0, 0.08), transparent 24%),
        linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.12);
}

.cm-top-tabs {
    padding: 18px 22px 14px;
    border-bottom: none;
    background: transparent;
    gap: 14px;
}

.cm-top-tabs-inner {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    flex: 1;
}

.cm-top-tab {
    justify-content: center;
    border-radius: 20px;
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.cm-top-tab.active {
    border-color: transparent;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

.cm-top-tab[data-view="naviga"].active {
    color: #fff;
    background: linear-gradient(135deg, var(--cm-primary) 0%, var(--cm-primary-dark) 100%);
}

.cm-top-tab[data-view="proposta"].active {
    color: #fff;
    background: linear-gradient(135deg, var(--cm-Tint) 0%, var(--cm-Tint-dark) 100%);
}

.cm-top-tab[data-view="elenco"].active {
    color: #fff;
    background: linear-gradient(135deg, var(--cm-green-dark) 0%, var(--cm-green-dark) 100%);
}

.cm-top-tab[data-view="naviga"] .material-icons,
.cm-top-tab[data-view="proposta"] .material-icons,
.cm-top-tab[data-view="elenco"] .material-icons {
    font-size: 20px;
}

.cm-search-bar-inline {
    max-width: 240px;
}

.cm-main-content {
    gap: 18px;
    padding: 0 18px 18px;
}

.cm-left-panel,
.cm-right-panel {
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.10);
}

.cm-left-panel {
    border-right: none;
}

.cm-panel-search {
    padding: 18px 18px 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
}

.cm-panel-search-input,
.cm-elenco-search-wrapper .cm-panel-search-input,
.cm-address-input {
    border-radius: 16px;
    border-color: rgba(148, 163, 184, 0.28);
    background: #ffffff;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.cm-card {
    border-radius: 18px;
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.cm-card:hover,
.cm-card.active {
    transform: translateY(-1px);
}

.cm-map-container {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(241, 245, 249, 0.88));
}

.cm-map-popup {
    border-radius: 24px;
    width: 360px;
}

.cm-map-popup.visible {
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
}

.cm-propose-form-panel {
    margin: 18px;
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.cm-propose-btn {
    border-radius: 16px;
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.20);
}

.cm-propose-btn:hover {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
}

.cm-elenco-header {
    padding: 22px 24px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.cm-elenco-grid {
    padding: 20px 24px 24px;
    gap: 18px;
}

.cm-elenco-card {
    border-radius: 20px;
    border-color: rgba(148, 163, 184, 0.16);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.cm-comments-section {
    padding: 0 24px 24px;
}

.cm-comments-section #commenti {
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.16);
    padding: 20px;
}

/* ============================================
    Top tab count badge
   ============================================ */
.cm-top-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 22px;
    padding: 0 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.25);
    color: inherit;
    margin-left: 2px;
    line-height: 1;
}

.cm-top-tab:not(.active) .cm-top-tab-count {
    background: rgba(0, 0, 0, 0.07);
    color: var(--cm-gray-700);
}

/* ============================================
    Desktop Default: Hide mobile bottom sheet handle
   ============================================ */
.cm-left-panel-handle {
    display: none;
}

/* ============================================
    ---- Tablet (1024px) ----
   ============================================ */

@media (max-width: 1024px) {
    .cm-main-content {
        flex-direction: column;
    }

    .cm-left-panel {
        width: 100%;
        min-width: 0;
        max-height: 42vh;   /* Limit height so the map stays visible below */
        flex-shrink: 0;
    }

    .cm-right-panel {
        min-height: 280px;   /* Always show some map on tablet */
    }
}

/* ==========================================================================================================
    Mobile (768px) — keep fixed height so the map has something to fill
   ========================================================================================================== */

@media (max-width: 768px) {
    .civic-map-dashboard {
        border-radius: 14px;
        margin: 6px auto;
        /* Use svh/dvh with vh fallback */
        height: 96vh;
        height: 96svh;
        min-height: 500px;
        padding: 8px;
    }

    /* 3 tabs in one row on mobile — icons only (text is hidden at this breakpoint) */
    .cm-top-tabs-inner {
        grid-template-columns: repeat(1, 1fr);
    }

    .cm-top-tab {
        padding: 10px 8px;
        font-size: 12px;
        gap: 6px;
        border-radius: 14px;
    }

    .cm-top-tabs {
        padding: 10px 12px 8px;
        gap: 8px;
    }
    .cm-top-tab-count {
        min-width: 22px;
        height: 20px;
        font-size: 11px;
        padding: 0 6px;
    }

    .cm-elenco-grid,
    .cm-comments-section {
        padding-left: 12px;
        padding-right: 12px;
    }

    .cm-map-popup {
        width: calc(100vw - 24px);
        max-width: 360px;
    }
    .cm-left-panel .cm-category-tabs .cm-tab .cm-tab-icon {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        min-height: 20px !important;

        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;

        flex: 0 0 20px !important;

        border-radius: 50%;
        color: #ffffff !important;

        overflow: hidden;
    }

    .cm-left-panel .cm-category-tabs .cm-tab .cm-tab-icon .material-icons {
        font-family: 'Material Icons' !important;
        font-size: 16px !important;
        line-height: 1 !important;

        width: auto !important;
        height: auto !important;

        display: inline-block !important;

        color: #ffffff !important;

        font-weight: normal !important;
        font-style: normal !important;

        letter-spacing: normal !important;
        text-transform: none !important;
        white-space: nowrap !important;
        word-wrap: normal !important;
        direction: ltr !important;

        -webkit-font-feature-settings: 'liga';
        -webkit-font-smoothing: antialiased;
        font-feature-settings: 'liga';
    }
    .cm-comments-section #commenti {
    display:none;
    }
    /* Main left panel transformed into fixed bottom sheet */
    .cm-left-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 60vh;
        max-height: 80vh;
        min-height: 220px;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -12px 40px rgba(14, 30, 37, 0.15);
        z-index: 800;
        overflow: visible;
        transition: transform 280ms cubic-bezier(0.2, 0.9, 0.2, 1);
        will-change: transform;
    }

    /* Retract panel, exposing only the 40px handle bar at bottom */
    .cm-left-panel.sheet-hidden {
        transform: translateY(calc(100% - 40px)) !important;
        pointer-events: none;
    }

    /* Expand panel to full height */
    .cm-left-panel.sheet-open {
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    /* Tappable handle area */
    .cm-left-panel-handle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 40px;
        padding: 8px 0;
        cursor: pointer;
        -webkit-user-select: none;
        user-select: none;
        z-index: 900;
        touch-action: manipulation;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.10);
        flex-shrink: 0;
    }

    /* When sheet is hidden: pin the handle to the viewport bottom independently.
       This ensures it shows even if position:fixed on the panel is captured by a
       transformed WordPress/theme ancestor. */
    .cm-left-panel.sheet-hidden .cm-left-panel-handle {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 850 !important;
        pointer-events: auto !important;
        background: #ffffff;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.14);
        border-radius: 16px 16px 0 0;
    }

    /* The visual bar inside the handle */
    .cm-left-panel-handle .cm-handle-bar {
        width: 48px;
        height: 5px;
        border-radius: 99px;
        background: rgba(0, 0, 0, 0.25);
        display: block;
        transition: background 0.2s, width 0.2s;
    }

    .cm-left-panel.sheet-hidden .cm-handle-bar {
        background: rgba(25, 118, 210, 0.75);
        width: 56px;
    }
}

/* ============================================
    ---- Mobile bottom-sheet mode (760px) ----
   ============================================ */
/*    The left panel is position:fixed (bottom sheet), so the document-flow
   main-content only contains the right panel. Revert to row/full-height. */
@media (max-width: 760px) {
    .cm-main-content {
        flex-direction: row;
        padding: 0 6px 6px;
    }

    .cm-left-panel {
        max-height: none;
    }

    .cm-right-panel {
        width: 100%;
        height: 100%;
        min-height: 0;
    }
}