/* ==========================================================================
   MADRID EXPLORER 2.0 - PREMIUM DESIGN SYSTEM
   ========================================================================== */

/* 1. VARIABILI & CONFIGURAZIONE TEMI */
:root {
    /* Font Families */
    --font-primary: 'Outfit', 'Poppins', sans-serif;
    --font-secondary: 'Poppins', sans-serif;

    /* Light Theme Palette (Premium Slate & Sunset Warmth) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-sidebar: rgba(255, 255, 255, 0.82);
    --bg-drawer: rgba(255, 255, 255, 0.9);
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    --border-color: rgba(226, 232, 240, 0.7);
    --border-glow: rgba(226, 232, 240, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 8px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 30px -4px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
    
    /* Branding Accent Colors */
    --accent-red: #e63946;
    --accent-gold: #ffb703;
    --accent-gold-rgb: 255, 183, 3;
    --glass-blur: blur(16px);
    --sidebar-width: 380px;

    /* Category Specific Colors */
    --cat-hotel: #1e293b;
    --cat-austrias: #e63946;
    --cat-moderno: #1d3557;
    --cat-barrios: #8338ec;
    --cat-default: #2a9d8f;
}

[data-theme="dark"] {
    /* Dark Theme Palette (Obsidian Deep & Vibrant Accents) */
    --bg-primary: #090b11;
    --bg-secondary: #0f111a;
    --bg-sidebar: rgba(15, 17, 26, 0.85);
    --bg-drawer: rgba(15, 17, 26, 0.9);
    --bg-card: #141722;
    --bg-hover: #1e2234;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    
    --border-color: rgba(51, 65, 85, 0.6);
    --border-glow: rgba(99, 102, 241, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 24px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.6);
    
    --accent-red: #ff4d6d;
    --accent-gold: #ffc300;
    --accent-gold-rgb: 255, 195, 0;

    --cat-hotel: #cbd5e1;
    --cat-austrias: #ff4d6d;
    --cat-moderno: #4cc9f0;
    --cat-barrios: #b5179e;
}

/* 2. RESET GENERALE */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: var(--font-primary);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* 3. SIDEBAR GLASSMORPHIC */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s;
}

/* Sidebar Header */
.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 2px;
}

.sidebar h1 span {
    background: linear-gradient(135deg, var(--accent-red), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Theme Toggle Button */
.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent-gold);
    box-shadow: 0 4px 12px rgba(var(--accent-gold-rgb), 0.25);
    color: var(--accent-gold);
}

.icon-btn span {
    font-size: 20px;
}

/* 4. WEATHER WIDGET */
.weather-widget {
    background: linear-gradient(135deg, rgba(230, 57, 70, 0.08), rgba(255, 183, 3, 0.08));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.weather-icon {
    font-size: 28px;
    color: var(--accent-gold);
    animation: pulse-weather 4s ease-in-out infinite alternate;
}

@keyframes pulse-weather {
    0% { transform: scale(1); filter: drop-shadow(0 0 1px rgba(var(--accent-gold-rgb), 0.2)); }
    100% { transform: scale(1.1); filter: drop-shadow(0 0 6px rgba(var(--accent-gold-rgb), 0.6)); }
}

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

.weather-temp {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.weather-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* 5. SEARCH & FILTERS */
.search-container {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 20px;
    pointer-events: none;
}

.search-container input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    background: var(--bg-hover);
    padding: 4px;
    border-radius: 10px;
    gap: 2px;
    margin-top: 4px;
}

.filter-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-family: var(--font-primary);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.filter-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* 6. LISTA ITINERARI E ACCORDION */
.itinerary-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Accordion Card */
.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
}

.category-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-color: var(--border-glow);
}

.category-card.expanded {
    border-color: var(--border-glow);
}

/* Header Accordion */
.category-header-btn {
    width: 100%;
    background: none;
    border: none;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
    outline: none;
}

.category-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-card-title {
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.category-progress-badge {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.category-arrow {
    color: var(--text-secondary);
    font-size: 22px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.category-card.expanded .category-arrow {
    transform: rotate(180deg);
}

/* Contenuto Accordion */
.category-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s cubic-bezier(0.16, 1, 0.3, 1), border-top 0.35s;
    overflow: hidden;
    border-top: 0 solid var(--border-color);
    background: var(--bg-primary);
}

.category-card.expanded .category-content {
    grid-template-rows: 1fr;
    border-top: 1px solid var(--border-color);
}

.category-content-inner {
    min-height: 0;
}

/* Navigazione percorsi */
.category-nav {
    padding: 10px 14px;
    display: flex;
    gap: 8px;
    border-bottom: 1px dashed var(--border-color);
    background: var(--bg-secondary);
}

.nav-link {
    flex: 1;
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--bg-hover);
    padding: 6px 8px;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.nav-link:hover {
    background: var(--accent-red);
    color: #ffffff;
    border-color: var(--accent-red);
}

/* Elemento Singola Posizione */
.location-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.location-item:last-child {
    border-bottom: none;
}

.location-item:hover {
    background: var(--bg-hover);
}

.location-item.active {
    background: linear-gradient(90deg, rgba(255, 183, 3, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    border-left-color: var(--accent-gold);
    font-weight: 600;
}

[data-theme="dark"] .location-item.active {
    background: linear-gradient(90deg, rgba(255, 195, 0, 0.12) 0%, rgba(15, 17, 26, 0) 100%);
}

.location-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.location-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Checkbox Personalizzato */
.custom-checkbox-container {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    user-select: none;
    min-height: 20px;
}

/* Modificatore per la Sidebar (allineamento perfetto della checkbox) */
.location-item .custom-checkbox-container {
    width: 20px;
    height: 20px;
    padding-left: 0;
    margin-right: 12px;
    flex-shrink: 0;
}

.custom-checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: var(--bg-primary);
    border: 2px solid var(--text-tertiary);
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-checkbox-container:hover input ~ .checkmark {
    border-color: var(--accent-red);
}

.custom-checkbox-container input:checked ~ .checkmark {
    background-color: var(--accent-red);
    border-color: var(--accent-red);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox-container .checkmark:after {
    left: 5px;
    top: 0.5px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Stato visitato */
.location-item.visited .location-name {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

/* 7. SIDEBAR FOOTER E AVANZAMENTO */
.sidebar-footer {
    padding: 16px 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.progress-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-hover);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-red), var(--accent-gold));
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Pulsanti Generici */
.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.btn-icon {
    font-size: 18px !important;
}

/* 8. CONTENUTO PRINCIPALE (MAPPA) */
.main-content {
    flex: 1;
    position: relative;
    height: 100%;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

.menu-toggle {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 999;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    color: var(--text-primary);
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.menu-toggle:hover {
    color: var(--accent-red);
    transform: scale(1.05);
}

.menu-toggle span {
    font-size: 24px;
}

/* 9. DETTAGLI DRAWER (SLIDE PANELS) */
.details-drawer {
    position: absolute;
    top: 16px;
    right: 16px;
    bottom: 16px;
    width: 380px;
    background: var(--bg-drawer);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transform: translateX(calc(100% + 32px));
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.details-drawer.open {
    transform: translateX(0);
}

.drawer-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 10px auto 0;
    display: none; /* Solo per mobile bottom sheet */
}

.drawer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    transition: all 0.2s;
}

.drawer-close:hover {
    background: var(--accent-red);
    color: #ffffff;
    border-color: var(--accent-red);
    transform: rotate(90deg);
}

.drawer-close span {
    font-size: 18px;
}

.drawer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.drawer-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 56px; /* Spazio per pulsante chiusura */
}

.category-badge {
    align-self: flex-start;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

#detail-title {
    font-family: var(--font-primary);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.25;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-description {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.detail-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.meta-item span {
    font-size: 16px;
}

/* User interaction Box inside Drawer */
.user-interaction-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.user-interaction-box h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.visit-status-row {
    display: flex;
    align-items: center;
}

.rating-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.stars {
    display: flex;
    gap: 2px;
}

.star-btn {
    cursor: pointer;
    font-size: 22px !important;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
}

.star-btn.active, .star-btn:hover {
    color: var(--accent-gold);
    font-variation-settings: 'FILL' 1;
}

.notes-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notes-container label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.notes-container textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-family: var(--font-primary);
    font-size: 0.82rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.notes-container textarea:focus {
    outline: none;
    border-color: var(--accent-red);
    background: var(--bg-secondary);
}

.notes-status {
    align-self: flex-end;
    font-size: 0.65rem;
    color: var(--text-tertiary);
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.notes-status.visible {
    opacity: 1;
}

.actions-container {
    margin-top: auto;
    padding-top: 8px;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-red), #e63946);
    color: #ffffff !important;
    border: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.2);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(230, 57, 70, 0.35);
}

.btn-primary span {
    font-size: 20px;
}

/* 10. LEAFLET PERSONALIZZAZIONI */
.leaflet-popup-content-wrapper {
    background: var(--bg-drawer) !important;
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 14px !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--text-primary) !important;
    padding: 4px;
}

.leaflet-popup-tip {
    background: var(--bg-drawer) !important;
    border-left: 1px solid var(--border-color) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-popup-content {
    font-family: var(--font-primary) !important;
    margin: 12px 14px !important;
    line-height: 1.4 !important;
}

.leaflet-popup-content strong {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

.popup-link {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--accent-red);
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(230, 57, 70, 0.25);
    transition: all 0.2s ease;
}

.popup-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(230, 57, 70, 0.4);
}

/* Custom Marker Pins */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-pin {
    width: 24px;
    height: 24px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -20px 0 0 -12px;
    border: 2.5px solid white;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.marker-pin::after {
    content: '';
    width: 9px;
    height: 9px;
    margin: 5px 0 0 5px;
    background: white;
    position: absolute;
    border-radius: 50%;
    opacity: 0.9;
}

.custom-marker:hover .marker-pin {
    transform: rotate(-45deg) scale(1.2);
    box-shadow: 0 5px 12px rgba(0,0,0,0.45);
}

/* Pulsazione marker selezionato */
.custom-marker.active-marker .marker-pin {
    transform: rotate(-45deg) scale(1.25);
    border-color: var(--accent-gold);
    animation: bounce-marker 1.2s ease-in-out infinite alternate;
}

.custom-marker.active-marker::before {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 183, 3, 0.3);
    animation: marker-glow 1.5s infinite ease-out;
    z-index: -1;
}

@keyframes bounce-marker {
    0% { margin-top: -20px; }
    100% { margin-top: -24px; }
}

@keyframes marker-glow {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Path Labels (Inizio/Fine) */
.path-label {
    background: var(--bg-drawer);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1.5px solid;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 20px;
}

/* Legenda Mappa */
.map-legend {
    background: var(--bg-drawer) !important;
    backdrop-filter: var(--glass-blur) !important;
    -webkit-backdrop-filter: var(--glass-blur) !important;
    border: 1px solid var(--border-color);
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    line-height: 1.6;
    font-size: 0.78rem;
    max-width: 220px;
    color: var(--text-primary);
}

.map-legend strong {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: block;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-weight: 500;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-item:hover {
    transform: translateX(3px);
    color: var(--accent-red);
}

.legend-item.hidden {
    opacity: 0.45;
    text-decoration: line-through;
}

.legend-color {
    width: 20px;
    height: 5px;
    margin-right: 10px;
    border-radius: 3px;
}

/* Animazione Polyline (effetto percorso in scorrimento) */
.leaflet-interactive[stroke-dasharray] {
    animation: dash-flow 1.5s linear infinite;
}

@keyframes dash-flow {
    to {
        stroke-dashoffset: -20;
    }
}

/* 11. RESPONSIVITÀ ED ERGONOMIA MOBILE */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        width: 320px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    /* Il Drawer diventa un Bottom-Sheet */
    .details-drawer {
        left: 12px;
        right: 12px;
        bottom: 12px;
        top: auto;
        width: calc(100% - 24px);
        height: 50%;
        max-height: 480px;
        transform: translateY(calc(100% + 24px));
        border-radius: 24px 24px 20px 20px;
    }

    .details-drawer.open {
        transform: translateY(0);
    }

    .drawer-handle {
        display: block;
    }

    .drawer-header {
        padding-top: 14px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%; /* Copre l'intero schermo */
    }
    
    .details-drawer {
        height: 60%;
        max-height: 420px;
    }
}