:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #637381;
    --primary: #2f80ed;
    --primary-dark: #1f68c7;
    --border: #d9e2ec;
    --danger: #d64545;
    --success: #219653;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header,
.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.site-header h1,
.admin-topbar h1 {
    margin: 0 0 .25rem;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.site-header p { margin: 0; color: var(--muted); }

.admin-link,
.button,
.button-secondary,
.button-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    border: 0;
    border-radius: .7rem;
    padding: .65rem .9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.admin-link,
.button {
    background: var(--primary);
    color: #fff;
}

.button:hover,
.admin-link:hover { background: var(--primary-dark); text-decoration: none; }

.button-secondary {
    background: #e8eef5;
    color: var(--text);
}

.button-danger {
    background: var(--danger);
    color: #fff;
}

.layout-map {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 92px);
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 1.25rem;
    overflow-y: auto;
}

.sidebar h2 { margin-top: 0; }

.map-wrapper { min-height: 65vh; }
.map { width: 100%; height: 100%; min-height: calc(100vh - 92px); }

.category-filters {
    display: grid;
    gap: .55rem;
}

.category-filter {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: .7rem;
    background: #fbfdff;
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.12);
    flex: 0 0 auto;
}

.search-label,
.form-card label {
    display: grid;
    gap: .35rem;
    font-weight: 700;
    margin-bottom: .85rem;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: .65rem;
    padding: .65rem .75rem;
    font: inherit;
    background: #fff;
}

textarea { min-height: 110px; resize: vertical; }

.small { font-size: .9rem; }
.muted { color: var(--muted); }

.installer-body,
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.installer-card,
.login-card,
.admin-card {
    width: min(100%, 980px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.login-card { max-width: 460px; }

.alert {
    padding: .85rem 1rem;
    border-radius: .7rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-error { color: #842029; background: #f8d7da; border-color: #f5c2c7; }
.alert-success { color: #0f5132; background: #d1e7dd; border-color: #badbcc; }
.alert-info { color: #084298; background: #cfe2ff; border-color: #b6d4fe; }

.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 84px);
}

.admin-sidebar {
    background: #17212b;
    color: #fff;
    padding: 1rem;
}

.admin-sidebar a {
    display: block;
    color: #fff;
    padding: .75rem .8rem;
    border-radius: .65rem;
    margin-bottom: .35rem;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
    background: rgba(255,255,255,.12);
    text-decoration: none;
}

.admin-content { padding: 1.5rem; }

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: .85rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th { background: #f8fafc; }
tr:last-child td { border-bottom: 0; }

.actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.form-grid .full { grid-column: 1 / -1; }

.admin-map-picker {
    width: 100%;
    height: 360px;
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    margin-top: .25rem;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: .15rem .55rem;
    font-size: .85rem;
    background: #eef2f7;
}

@media (max-width: 860px) {
    .layout-map,
    .admin-layout { grid-template-columns: 1fr; }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
    .map { min-height: 70vh; }
    .admin-sidebar { display: flex; gap: .35rem; overflow-x: auto; }
    .admin-sidebar a { white-space: nowrap; }
    .form-grid { grid-template-columns: 1fr; }
}


/*
 * v0.1.3 - Rendering MapLibre / OpenFreeMap
 * ------------------------------------------------------------------
 * La mappa usa tile vettoriali: questo permette di mantenere i nomi
 * delle vie e nascondere i layer POI del provider, lasciando visibili
 * solo i marker gestiti dal nostro backoffice.
 */
.layout-map {
    height: calc(100vh - 92px);
    min-height: 520px;
}

.map-wrapper {
    position: relative;
    height: 100%;
    min-height: 520px;
    overflow: hidden;
}

.map {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 520px;
    overflow: hidden;
}

.admin-map-picker {
    position: relative;
    background: #dde5ec;
}

.maplibregl-map {
    font: 12px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.maplibregl-popup-content h3,
.map-popup h3 {
    margin: .2rem 0 .35rem;
}

.maplibregl-popup-content p,
.map-popup p {
    margin: .35rem 0;
}

.maplibregl-popup-content {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .24);
}

.poi-map-marker {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 3px solid #fff;
    background: var(--marker-color, var(--primary));
    box-shadow: 0 4px 12px rgba(0,0,0,.35);
    cursor: pointer;
    padding: 0;
}

.poi-map-marker:hover,
.poi-map-marker:focus {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(47, 128, 237, .22), 0 4px 12px rgba(0,0,0,.35);
}

.poi-admin-pin {
    display: block;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--primary);
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.35);
    cursor: grab;
}

.maplibregl-marker:active .poi-admin-pin {
    cursor: grabbing;
}

@media (max-width: 860px) {
    .layout-map {
        height: auto;
        min-height: 0;
    }

    .map-wrapper,
    .map {
        min-height: 70vh;
        height: 70vh;
    }
}

/*
 * v0.1.2 - Mappa pubblica pulita e POI caricati solo su selezione categoria
 */
.map-status {
    position: absolute;
    left: 50%;
    top: 1.25rem;
    transform: translateX(-50%);
    z-index: 700;
    max-width: min(92%, 520px);
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: .9rem;
    background: rgba(255, 255, 255, .94);
    box-shadow: var(--shadow);
    color: var(--text);
    font-weight: 700;
    text-align: center;
    pointer-events: none;
}

.map-status[hidden] {
    display: none;
}

.category-filter {
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.category-filter:has(input:checked) {
    border-color: var(--primary);
    background: #eef6ff;
    box-shadow: 0 0 0 2px rgba(47, 128, 237, .12);
}

.category-filter-empty {
    color: var(--muted);
}

.color-dot-empty {
    background: #fff;
}

/*
 * v0.1.4 - Risultati ricerca POI AJAX
 */
.poi-results {
    margin: .75rem 0 1rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: .9rem;
    background: #fbfdff;
}

.poi-results[hidden] {
    display: none;
}

.poi-results h3 {
    margin: 0 0 .6rem;
    font-size: 1rem;
}

.poi-results-list {
    display: grid;
    gap: .45rem;
}

.poi-result {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .55rem;
    align-items: start;
    width: 100%;
    padding: .6rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: #fff;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.poi-result:hover,
.poi-result:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(47, 128, 237, .12);
}

.poi-result strong,
.poi-result small {
    display: block;
}

.poi-result small {
    margin-top: .15rem;
    color: var(--muted);
    line-height: 1.35;
}

/*
 * v0.1.6 - Log operazioni backoffice
 */
.admin-card-wide {
    width: min(100%, 1320px);
}

.logs-table th,
.logs-table td {
    white-space: nowrap;
}

.logs-table td:last-child {
    white-space: normal;
    min-width: 260px;
}

.log-details {
    max-width: 560px;
    max-height: 260px;
    overflow: auto;
    margin: .6rem 0 0;
    padding: .75rem;
    border-radius: .65rem;
    background: #101828;
    color: #f8fafc;
    font-size: .82rem;
}

/* v0.1.7 - Ricerca POI esterna, versione e footer applicazione */
.version-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-left: .35rem;
    padding: .14rem .48rem;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--muted);
    font-size: .72em;
    font-weight: 700;
    line-height: 1.2;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    flex-wrap: wrap;
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted);
    font-size: .86rem;
    text-align: center;
}

.app-footer a {
    font-weight: 700;
}

.admin-app-footer {
    position: relative;
    z-index: 2;
}

.login-body {
    grid-template-rows: 1fr auto;
}

.login-footer {
    width: 100%;
}

.external-poi-search {
    margin: 0 0 1.25rem;
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: #f8fbff;
}

.external-poi-search h3 {
    margin: 0 0 .25rem;
}

.external-poi-search-heading p {
    margin: 0 0 1rem;
}

.external-poi-search-form label {
    display: block;
    margin-bottom: .4rem;
    font-weight: 700;
}

.external-poi-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .6rem;
    align-items: stretch;
}

.external-poi-search-row .button:disabled {
    opacity: .6;
    cursor: wait;
}

.external-poi-status {
    margin-top: .75rem;
    padding: .7rem .8rem;
    border-radius: .65rem;
    font-size: .92rem;
}

.external-poi-status.info {
    background: #eaf3ff;
    color: #174a7e;
}

.external-poi-status.success {
    background: #dff4e8;
    color: #17653a;
}

.external-poi-status.error {
    background: #f8d7da;
    color: #842029;
}

.external-poi-results {
    display: grid;
    gap: .65rem;
    margin-top: .75rem;
}

.external-poi-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .8rem;
    align-items: center;
    padding: .8rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: var(--panel);
}

.external-poi-result-content {
    min-width: 0;
    display: grid;
    gap: .2rem;
}

.external-poi-result-content .small {
    overflow-wrap: anywhere;
}

.external-poi-attribution {
    margin: .8rem 0 0;
}

@media (max-width: 640px) {
    .external-poi-search-row,
    .external-poi-result {
        grid-template-columns: 1fr;
    }

    .external-poi-result .button {
        width: 100%;
    }
}

.external-poi-status[hidden],
.external-poi-results[hidden] {
    display: none !important;
}


/* v0.1.8 - Selezione multipla categorie e categorie predefinite */
.category-filter input[type="checkbox"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
}

/* v0.1.9 - Frontend mobile-first verticale e navigazione pedonale */
.mobile-filters-toggle {
    display: none;
}

.poi-popup {
    min-width: 210px;
}

.poi-navigate-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    width: 100%;
    min-height: 44px;
    margin-top: .75rem;
    padding: .7rem .9rem;
    border-radius: .75rem;
    background: var(--primary);
    color: #fff !important;
    font-size: .95rem;
    font-weight: 800;
    line-height: 1.2;
    text-decoration: none !important;
}

.poi-navigate-button:hover,
.poi-navigate-button:focus {
    background: var(--primary-dark);
    text-decoration: none;
}

@media (max-width: 860px) {
    .site-header {
        gap: .65rem;
        padding: .7rem .8rem;
    }

    .site-header > div {
        min-width: 0;
    }

    .site-header h1 {
        margin: 0;
        font-size: clamp(1rem, 4.6vw, 1.3rem);
        line-height: 1.15;
    }

    .site-header p {
        display: none;
    }

    .site-header .version-badge {
        margin-left: .2rem;
        padding: .1rem .35rem;
        font-size: .64em;
    }

    .admin-link {
        flex: 0 0 auto;
        padding: .5rem .65rem;
        border-radius: .6rem;
        font-size: .78rem;
    }

    .layout-map {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .sidebar {
        order: 0;
        position: relative;
        z-index: 800;
        padding: .55rem .7rem;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        background: var(--panel);
        box-shadow: 0 6px 18px rgba(15, 23, 42, .07);
    }

    .mobile-filters-toggle {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "title chevron"
            "summary chevron";
        align-items: center;
        gap: .1rem .7rem;
        width: 100%;
        min-height: 48px;
        padding: .15rem .1rem;
        border: 0;
        background: transparent;
        color: var(--text);
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .mobile-filters-toggle-title {
        grid-area: title;
        font-size: .98rem;
        font-weight: 800;
    }

    .mobile-filter-summary {
        grid-area: summary;
        color: var(--muted);
        font-size: .78rem;
        line-height: 1.2;
    }

    .mobile-filter-chevron {
        grid-area: chevron;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        font-size: 1.45rem;
        transform: rotate(0deg);
        transition: transform .2s ease;
    }

    .sidebar.mobile-panel-open .mobile-filter-chevron {
        transform: rotate(180deg);
    }

    .mobile-filters-panel {
        display: none;
        max-height: 46dvh;
        overflow-y: auto;
        padding: .55rem 0 .2rem;
        overscroll-behavior: contain;
    }

    .sidebar.mobile-panel-open .mobile-filters-panel {
        display: block;
    }

    .sidebar h2 {
        margin: 0 0 .5rem;
        font-size: .92rem;
    }

    .category-filters {
        display: flex;
        gap: .45rem;
        overflow-x: auto;
        padding: .1rem .05rem .45rem;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .category-filter {
        flex: 0 0 auto;
        min-height: 42px;
        padding: .5rem .65rem;
        border-radius: 999px;
        white-space: nowrap;
        scroll-snap-align: start;
    }

    .category-filter input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .sidebar hr {
        margin: .55rem 0 .65rem;
        border: 0;
        border-top: 1px solid var(--border);
    }

    .search-label {
        margin-bottom: .45rem;
        font-size: .9rem;
    }

    .search-label input {
        min-height: 44px;
        padding: .7rem .8rem;
        font-size: 16px;
    }

    .sidebar-help {
        display: none;
    }

    .poi-results {
        margin: .55rem 0 0;
        max-height: 180px;
        overflow-y: auto;
    }

    .map-wrapper {
        order: 1;
        height: calc(100dvh - 145px);
        min-height: 520px;
        max-height: 900px;
    }

    .map {
        height: 100%;
        min-height: 520px;
    }

    .map-status {
        top: .7rem;
        width: calc(100% - 90px);
        max-width: 430px;
        padding: .6rem .7rem;
        border-radius: .75rem;
        font-size: .82rem;
        line-height: 1.3;
    }

    .poi-map-marker {
        width: 26px;
        height: 26px;
    }

    .maplibregl-popup {
        max-width: calc(100vw - 32px) !important;
    }

    .maplibregl-popup-content {
        max-height: 58dvh;
        overflow-y: auto;
        padding: 14px 14px 12px;
        font-size: .9rem;
    }

    .maplibregl-popup-content h3 {
        padding-right: 1rem;
        font-size: 1.05rem;
    }

    .poi-navigate-button {
        min-height: 48px;
        font-size: 1rem;
    }

    .site-app-footer {
        padding: .55rem .7rem;
        font-size: .76rem;
    }
}

@media (max-width: 420px) {
    .map-wrapper,
    .map {
        min-height: 500px;
    }

    .map-wrapper {
        height: calc(100dvh - 142px);
    }
}

@media (min-width: 861px) {
    .mobile-filters-panel {
        display: block !important;
    }
}

/* v0.1.10 - Overlay filtri mobile, ricerca globale e posizione GPS */
.user-location-marker {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 3px solid #2563eb;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 5px 16px rgba(15, 23, 42, .38);
    cursor: pointer;
    isolation: isolate;
}

.user-location-pulse {
    position: absolute;
    inset: -8px;
    z-index: -1;
    border-radius: 999px;
    background: rgba(37, 99, 235, .22);
    animation: user-location-pulse 2s ease-out infinite;
}

.user-location-walker {
    display: block;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-size: 24px;
    line-height: 1;
    transform: translateY(-1px);
}

.user-location-popup {
    min-width: 105px;
    text-align: center;
}

@keyframes user-location-pulse {
    0% { transform: scale(.78); opacity: .95; }
    70%, 100% { transform: scale(1.45); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .user-location-pulse { animation: none; }
}

@media (max-width: 860px) {
    /* Il pannello compatto galleggia sopra la mappa; aprendolo occupa
       l'intera area mappa senza spostarla o ridurne l'altezza. */
    .layout-map {
        position: relative;
        display: block;
        height: calc(100dvh - 96px);
        min-height: 520px;
        overflow: hidden;
    }

    .map-wrapper,
    .map {
        width: 100%;
        height: 100%;
        min-height: 520px;
        max-height: none;
    }

    .sidebar {
        position: absolute;
        inset: .7rem .7rem auto .7rem;
        z-index: 1000;
        width: auto;
        padding: .5rem .65rem;
        overflow: visible;
        border: 1px solid rgba(217, 226, 236, .95);
        border-radius: .9rem;
        background: rgba(255, 255, 255, .97);
        box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
        backdrop-filter: blur(8px);
    }

    .sidebar.mobile-panel-open {
        inset: 0;
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: .65rem .8rem .8rem;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: var(--panel);
        box-shadow: none;
        backdrop-filter: none;
    }

    .sidebar.mobile-panel-open .mobile-filters-toggle {
        flex: 0 0 auto;
        padding: .1rem 0 .55rem;
        border-bottom: 1px solid var(--border);
    }

    .sidebar.mobile-panel-open .mobile-filters-panel {
        display: block;
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        padding: .75rem 0 .25rem;
        overscroll-behavior: contain;
    }

    .sidebar.mobile-panel-open .poi-results {
        max-height: none;
        overflow: visible;
    }

    .map-status {
        top: 4.65rem;
    }

    .maplibregl-ctrl-top-right {
        top: 3.75rem;
    }

    .user-location-marker {
        width: 44px;
        height: 44px;
    }

    .user-location-walker {
        font-size: 25px;
    }
}

@media (max-width: 420px) {
    .layout-map,
    .map-wrapper,
    .map {
        min-height: 500px;
    }

    .layout-map {
        height: calc(100dvh - 92px);
    }
}


/* v0.1.11 - Drawer filtri a scomparsa e GPS attivabile su richiesta */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.layout-map {
    position: relative;
    display: block;
    overflow: hidden;
}

.layout-map .map-wrapper,
.layout-map .map {
    width: 100%;
    height: 100%;
}

.map-filter-drawer.sidebar {
    position: absolute;
    z-index: 1100;
    top: 0;
    left: 0;
    width: 360px;
    max-width: calc(100% - 46px);
    height: 100%;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    transform: translateX(-100%);
    transition: transform .22s ease;
}

.map-filter-drawer.sidebar.mobile-panel-open {
    transform: translateX(0);
}

.map-filter-drawer .mobile-filters-panel {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    padding: 1.15rem 1.1rem 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, .985);
    box-shadow: 10px 0 28px rgba(15, 23, 42, .18);
    backdrop-filter: blur(10px);
}

.map-filter-drawer .mobile-filters-panel > h2 {
    margin: 0 0 1rem;
    padding-right: 2rem;
    font-size: 1.15rem;
}

.map-filter-drawer .mobile-filters-panel > h3 {
    margin: 0 0 .55rem;
    font-size: .95rem;
}

.filters-edge-toggle {
    position: absolute;
    z-index: 2;
    top: 50%;
    right: -44px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 68px;
    padding: 0;
    transform: translateY(-50%);
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 14px 14px 0;
    background: rgba(255, 255, 255, .96);
    color: var(--primary);
    box-shadow: 5px 4px 16px rgba(15, 23, 42, .18);
    font: inherit;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.filters-edge-toggle:hover,
.filters-edge-toggle:focus-visible {
    background: #fff;
    outline: 0;
    color: var(--primary-dark);
}

.filters-edge-chevron {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.map-filter-drawer .category-filters {
    display: grid;
    gap: .55rem;
    overflow: visible;
    padding: 0;
}

.map-filter-drawer .category-filter {
    width: 100%;
    min-height: 44px;
    border-radius: .7rem;
    white-space: normal;
}

.map-filter-drawer .poi-results {
    max-height: none;
    overflow: visible;
}

.geolocation-button {
    position: absolute;
    z-index: 900;
    right: 12px;
    bottom: 46px;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 999px;
    background: rgba(255, 255, 255, .97);
    color: #2563eb;
    box-shadow: 0 5px 18px rgba(15, 23, 42, .32);
    font: inherit;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.geolocation-button:hover,
.geolocation-button:focus-visible {
    outline: 0;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .18), 0 5px 18px rgba(15, 23, 42, .32);
}

.geolocation-button.is-active {
    background: #2563eb;
    color: #fff;
}

.geolocation-button.is-loading .geolocation-button-icon {
    animation: gps-button-pulse 1s ease-in-out infinite;
}

.geolocation-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.geolocation-button-icon {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
}

@keyframes gps-button-pulse {
    0%, 100% { transform: scale(.85); opacity: .65; }
    50% { transform: scale(1.12); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .map-filter-drawer.sidebar { transition: none; }
    .geolocation-button.is-loading .geolocation-button-icon { animation: none; }
}

@media (max-width: 860px) {
    .layout-map {
        height: calc(100dvh - 96px);
        min-height: 520px;
    }

    .map-filter-drawer.sidebar {
        inset: 0 auto 0 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
        transform: translateX(-100%);
    }

    .map-filter-drawer.sidebar.mobile-panel-open {
        inset: 0 auto 0 0;
        display: block;
        height: 100%;
        padding: 0;
        overflow: visible;
        background: transparent;
    }

    .map-filter-drawer .mobile-filters-panel,
    .map-filter-drawer.sidebar.mobile-panel-open .mobile-filters-panel {
        display: block;
        width: 100%;
        height: 100%;
        max-height: none;
        padding: 1rem 1rem 1.25rem;
        overflow-y: auto;
        border: 0;
        background: var(--panel);
        box-shadow: none;
        backdrop-filter: none;
    }

    .map-filter-drawer .category-filters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .55rem;
        overflow: visible;
        padding: 0;
    }

    .map-filter-drawer .category-filter {
        min-width: 0;
        padding: .6rem .65rem;
        border-radius: .75rem;
        white-space: normal;
    }

    .map-filter-drawer .poi-results,
    .map-filter-drawer.sidebar.mobile-panel-open .poi-results {
        max-height: none;
        overflow: visible;
    }

    .filters-edge-toggle {
        top: 50%;
        right: -46px;
        width: 46px;
        height: 72px;
    }

    .map-filter-drawer.sidebar.mobile-panel-open .filters-edge-toggle {
        top: .75rem;
        right: .75rem;
        width: 44px;
        height: 44px;
        transform: none;
        border: 1px solid var(--border);
        border-radius: 999px;
        box-shadow: 0 4px 14px rgba(15, 23, 42, .15);
    }

    .map-status {
        top: .7rem;
    }

    .maplibregl-ctrl-top-right {
        top: 0;
    }

    .geolocation-button {
        right: 12px;
        bottom: 46px;
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .map-filter-drawer .category-filters {
        grid-template-columns: 1fr;
    }
}

/* v0.1.12 - Geocodifica automatica indirizzo nel form POI */
.poi-geocode-status {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.88rem;
    line-height: 1.35;
}
.poi-geocode-status.info {
    background: #eef4ff;
    color: #29466f;
}
.poi-geocode-status.success {
    background: #eaf8ef;
    color: #176c37;
}
.poi-geocode-status.error {
    background: #fff0f0;
    color: #a32929;
}
.poi-geocode-status[hidden] {
    display: none;
}


/* v0.1.13 - Colori categorie a campo pieno nel backoffice */
.category-color-input {
    display: block;
    width: 100%;
    height: 48px;
    min-height: 48px;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: .65rem;
}

.category-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.category-color-input::-webkit-color-swatch {
    border: 0;
    border-radius: .55rem;
}

.category-color-input::-moz-color-swatch {
    border: 0;
    border-radius: .55rem;
}

.category-color-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 112px;
    min-height: 38px;
    padding: .45rem .7rem;
    border-radius: .6rem;
    border: 1px solid rgba(15, 23, 42, .16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-weight: 800;
    letter-spacing: .02em;
    text-align: center;
}

/* v0.1.14 - Colore categoria a campo pieno anche nell'elenco POI */
.category-color-name {
    min-width: 130px;
    font-family: inherit;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.2;
    white-space: normal;
}


/* v0.1.15 - Categoria a sfondo pieno nel popup POI pubblico */
.poi-popup-category {
    margin: .35rem 0 .65rem;
}

.poi-category-badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 30px;
    padding: .35rem .65rem;
    border-radius: .55rem;
    font-size: .82rem;
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

/* v0.1.16 - Logo applicazione e header frontend compatto */
.site-brand {
    min-width: 0;
}

.site-brand-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.site-brand-row h1 {
    min-width: 0;
    margin: 0;
}

.site-logo {
    display: block;
    flex: 0 0 auto;
    width: auto;
    max-width: 112px;
    height: 48px;
    object-fit: contain;
}

.settings-logo-field {
    display: grid;
    gap: .55rem;
    margin-bottom: .85rem;
}

.settings-field-label {
    font-weight: 700;
}

.settings-logo-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: .8rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: #fbfdff;
}

.settings-logo-preview img {
    display: block;
    width: auto;
    max-width: 220px;
    height: 72px;
    object-fit: contain;
}

.settings-logo-remove {
    display: inline-flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: .5rem !important;
    margin: 0 !important;
    font-weight: 600 !important;
}

.settings-logo-remove input[type="checkbox"] {
    width: auto;
    margin: 0;
}

@media (max-width: 860px) {
    .site-header {
        min-height: 54px;
        padding: .5rem .65rem;
    }

    .site-brand-row {
        gap: .5rem;
    }

    .site-logo {
        max-width: 72px;
        height: 34px;
    }

    .site-brand-row h1 {
        overflow: hidden;
        font-size: clamp(.98rem, 4.4vw, 1.22rem);
        line-height: 1.08;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .site-header p {
        display: none;
    }

    .admin-link {
        min-height: 36px;
        padding: .45rem .6rem;
    }
}

@media (max-width: 420px) {
    .site-logo {
        max-width: 58px;
        height: 30px;
    }

    .site-brand-row h1 {
        font-size: .98rem;
    }
}


/* v0.1.18 - Privacy & Cookie Policy */
.settings-privacy-field {
    margin-top: .25rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: .9rem;
    background: #f8fbff;
}

.settings-privacy-field h3 {
    margin: 0 0 .8rem;
}

.settings-privacy-grid {
    margin-bottom: .35rem;
}

.privacy-body {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: #f5f7fa;
}

.privacy-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

.privacy-layout {
    width: min(960px, calc(100% - 2rem));
    margin: 1.5rem auto;
}

.privacy-card {
    padding: clamp(1.1rem, 3vw, 2rem);
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--panel);
    box-shadow: 0 12px 35px rgba(16, 24, 40, .08);
    line-height: 1.65;
}

.privacy-card > h1 {
    margin: 0 0 .25rem;
}

.privacy-updated {
    margin: 0 0 1.4rem;
    color: var(--muted);
    font-size: .9rem;
}

.privacy-card section {
    margin-top: 1.65rem;
}

.privacy-card section h2 {
    margin: 0 0 .5rem;
    font-size: 1.2rem;
}

.privacy-card p,
.privacy-card ul {
    margin-top: .55rem;
    margin-bottom: .55rem;
}

.privacy-card a {
    overflow-wrap: anywhere;
}

.privacy-note {
    margin-top: 1.75rem !important;
    padding: .85rem 1rem;
    border-left: 4px solid var(--primary);
    border-radius: .45rem;
    background: #f8fbff;
    color: var(--muted);
    font-size: .9rem;
}

@media (max-width: 700px) {
    .privacy-layout {
        width: min(100% - 1rem, 960px);
        margin: .5rem auto;
    }

    .privacy-card {
        border-radius: .75rem;
        padding: 1rem;
    }

    .privacy-header .admin-link {
        white-space: nowrap;
    }
}
