.map-page {
    height: 100vh;        /* fallback per browser vecchi */
    height: 100dvh;       /* dynamic viewport height: si adatta quando la barra URL appare/scompare */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ── Logo ─────────────────────────────────────────── */
.map-logo {
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    flex-shrink: 0;
    /* background: #ffffffba;
    border-radius: var(--radius-xl); */
    padding: 7px 12px;
    /* box-shadow: var(--shadow-md);
    line-height: 1;
    border: 1px solid #ffffff;
    width: 48px;
    height: 51px; */
}

.map-logo-icon {
    font-size: 18px;
    line-height: 1;
    width: 32px;
}

.map-logo-text {
    font-size: var(--font-size-sm);
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.01em;
}

/* ── Top bar ──────────────────────────────────────── */
.map-topbar {
    position: absolute;
    top: var(--space-md);
    left: var(--space-md);
    right: var(--space-md);
    z-index: 500;
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

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

.map-search-input {
    width: 100%;
    padding: 11px 40px 11px 40px;
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    font-family: var(--font-sans);
    font-size: var(--font-size-md);
    color: var(--color-text);
    background: var(--color-surface);
    outline: none;
    transition: box-shadow var(--transition);
}

.map-search-input:focus { box-shadow: var(--shadow-lg); }
.map-search-input::placeholder { color: var(--color-text-secondary); opacity: 0.7; }

.map-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    pointer-events: none;
    opacity: 0.5;
}

.map-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.4;
    padding: 2px;
    line-height: 1;
    color: var(--color-text);
}

.map-search-clear:hover { opacity: 0.8; }

.map-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-primary-trasp);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-md);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    font-family: var(--font-sans);
    width: 48px;
    height: 51px;
}

/* Autocomplete dropdown */
.map-autocomplete {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 600;
}

.map-autocomplete.hidden { display: none; }

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 11px var(--space-md);
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--color-bg); }

.autocomplete-item-icon { font-size: 16px; flex-shrink: 0; opacity: 0.6; }

.autocomplete-item-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.autocomplete-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-sub {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Map container ────────────────────────────────── */
#js-map {
    flex: 1;
    width: 100%;
    z-index: 1;
}

/* Override Leaflet defaults */
.leaflet-container { font-family: var(--font-sans); }
.leaflet-popup-content-wrapper { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; }
.leaflet-popup-content { margin: var(--space-md) !important; }
.leaflet-popup-tip-container { display: none; }
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow-md) !important; border-radius: var(--radius-md) !important; }
.leaflet-control-zoom a { border-radius: 0 !important; font-size: 18px !important; color: var(--color-text) !important; }

/* ── Side controls ────────────────────────────────── */
.map-controls {
    position: absolute;
    right: var(--space-md);
    bottom: calc(120px + var(--map-footer-h) + var(--map-route-panel-h));
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* ── FAB ──────────────────────────────────────────── */
.map-fab {
    position: absolute;
    right: var(--space-md);
    bottom: calc(var(--space-xl) + var(--map-footer-h) + var(--map-route-panel-h));
    z-index: 500;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: #000000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 16px rgb(0 0 0 / 50%);
    transition: transform var(--transition), box-shadow var(--transition);
    font-size: 40px;
    font-weight: bold;
}

.map-fab:hover { transform: scale(1.08); box-shadow: 0 4px 16px rgb(0 0 0 / 50%); }
.map-fab:active { transform: scale(0.96); }

/* pick-location mode */
.map-fab.picking { background: var(--color-danger); box-shadow: 0 4px 16px rgba(220, 38, 38, 0.5); }

/* ── Pick-location banner ─────────────────────────── */
.map-pick-banner {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: var(--color-text);
    color: #fff;
    border-radius: var(--radius-xl);
    padding: 8px 18px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
    animation: fadeIn 0.2s ease;
}

.map-pick-banner.hidden { display: none; }

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

/* ── Bottom route panel ───────────────────────────── */
.map-route-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: var(--color-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-md) var(--space-lg) var(--space-lg);
    box-shadow: 0 -4px 20px var(--color-shadow-md);
    animation: sheetUp 0.3s ease;
}

.map-route-panel.hidden { display: none; }

.map-route-panel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.map-route-info {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.map-route-stat {
    display: flex;
    flex-direction: column;
}

.map-route-stat-value {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.map-route-stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.map-route-close {
    background: var(--color-bg);
    border: none;
    border-radius: var(--radius-full);
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.map-route-alerts {
    margin-top: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-warning);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* ── User location dot (fallback) ─────────────────── */
.user-dot {
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    position: relative;
}

.user-dot::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.2);
    animation: pulse 2s infinite;
}

/* ── User location icon (emoji personalizzata) ────── */
.user-icon-marker {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border: 2.5px solid var(--color-primary);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    position: relative;
}

.user-icon-pulse {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.15);
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50%       { transform: scale(1.5); opacity: 0; }
}

/* ── Report marker ────────────────────────────────── */
.report-marker {
    width: 34px;
    height: 34px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    border: 2px solid rgba(255,255,255,0.8);
}

.report-marker-inner {
    transform: rotate(45deg);
    font-size: 16px;
    line-height: 1;
}

/* ── OSM marker (POI da OpenStreetMap) ─────────────── */
.osm-marker {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.osm-marker-inner {
    font-size: 16px;
    line-height: 1;
}
.osm-popup-name {
    font-size: var(--font-size-sm);
    color: var(--color-text);
    margin-top: var(--space-xs);
}
.osm-popup-source {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    font-style: italic;
    margin: var(--space-xs) 0;
}

/* ── Nearby user marker ───────────────────────────── */
.nearby-user-marker {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border: 2.5px solid var(--color-primary);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

/* Cursor crosshair when picking */
#js-map.picking-mode { cursor: crosshair !important; }

/* ── Footer ───────────────────────────────────────── */
:root {
    --map-footer-h: 76px;
    --map-route-panel-h: 50px;
}

/* Hide default Leaflet attribution (replaced by our footer) */
.leaflet-control-attribution { display: none !important; }

.map-footer {
position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--map-footer-h);
    z-index: 400;
    background: rgba(255, 255, 255, 0.92); 
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-top: 1px solid var(--color-border);
    padding: 8px var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* gap: 3px; */
    text-align: center;
    height: 60px;
}

.map-footer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex-wrap: wrap;
    font-family: var(--font-sans);
}

.map-footer-brand {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.02em;
}

.map-footer-links a,
.map-footer-attr a {
    font-size: 10px;
    color: var(--color-text-secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition);
}

.map-footer-links a:hover,
.map-footer-attr a:hover { color: var(--color-primary); }

.map-footer-copy span {
    font-size: 10px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.map-footer-sep {
    font-size: 10px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

/* ── Toast override (map page only) ───────────────── */
#js-toast-container {
    bottom: calc(var(--map-footer-h) + var(--map-route-panel-h) + var(--space-xl));
}

/* User menu dropdown */
.user-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 600;
    min-width: 180px;
}

.user-menu.hidden { display: none; }

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-md);
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: background var(--transition);
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font-sans);
    color: var(--color-text);
    text-align: left;
}

.user-menu-item:hover { background: var(--color-bg); }
.user-menu-item.danger { color: var(--color-danger); }

.user-menu-header {
    padding: 12px var(--space-md) 8px;
    border-bottom: 1px solid var(--color-border);
}

.user-menu-name { font-weight: 700; font-size: var(--font-size-sm); }
.user-menu-email { font-size: var(--font-size-xs); color: var(--color-text-secondary); }

.user-menu-guest {
    display: flex;
    flex-direction: column;
}

.user-menu-guest.hidden { display: none; }

/* link signin/signup nel menu trattati come bottoni */
.user-menu-guest .user-menu-item {
    text-decoration: none;
    display: flex;
}
