html,
body {
    height: 100%;
    margin: 0;
    font-family: 'Roboto Condensed', sans-serif;
    overflow: hidden;
}

/* --- MAPPA & OVERLAY --- */
#map {
    height: 100vh;
    width: 100%;
    z-index: 1;
}

/* --- PRIVACY BANNER --- */
.privacy-banner {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transition: bottom 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 4px solid #547c45;
    box-sizing: border-box;
}

.privacy-banner.active {
    bottom: 0;
}

.privacy-text {
    font-size: 14px;
    color: #333;
    max-width: 900px;
    text-align: center;
    line-height: 1.6;
}

.btn-privacy {
    padding: 10px 35px;
    border-radius: 25px;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-privacy-accept {
    background: #d63838;
    color: white;
}

.btn-privacy-accept:hover {
    background: #446638;
    transform: scale(1.05);
}

/* A cura di Raffaele Moschillo - Vertical Label */
.author-label {
    position: absolute;
    left: 3px;
    top: 113px;
    z-index: 2000;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    color: gray;
    opacity: 0.7;
    font-size: 9pt;
    pointer-events: none;
    background: transparent;
    font-family: 'Roboto Condensed', sans-serif;
}

/* --- CONTROLLI SINISTRA (Filtri Esistenti) --- */
/* --- CONTROLLI SINISTRA (Filtri RIMOSSI) --- */
/* (Styles removed) */

/* --- CONTROLLI DESTRA (Zoom, Locazione, Legenda) --- */
.right-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-btn {
    width: 44px;
    height: 44px;
    background: rgba(214, 56, 56, 0.9);
    /* #d63838 with 0.9 opacity (Admin btn style) */
    backdrop-filter: blur(8px);
    /* Glass effect */
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
    /* 70% White Icon to match admin btn svg */
}

.control-btn:hover {
    background-color: rgba(214, 56, 56, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    color: white;
}

.control-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- FILTER PANEL (Unified) --- */
.filter-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2500;
    display: none;
    flex-direction: column;
    max-height: 85vh;
    overflow-y: auto;
}

.filter-panel.active {
    display: flex;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.filter-title {
    font-size: 18px;
    font-weight: bold;
    color: #547c45;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-section label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.filter-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    font-family: inherit;
    font-size: 14px;
}

.filter-categories {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 8px;
    background: #f9f9f9;
}

/* Double Slider Styling */
.range-values {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: #547c45;
    margin-bottom: 10px;
}

.double-slider-container {
    position: relative;
    width: 100%;
    height: 30px;
}

.slider-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 5px;
    width: 100%;
    background: #ddd;
    border-radius: 3px;
    z-index: 1;
}

.double-slider-container input[type="range"] {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    z-index: 2;
    margin: 0;
}

.double-slider-container input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #d63838;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

.double-slider-container input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #d63838;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 2px solid white;
}

.double-slider-container input[type="range"]::-webkit-slider-runnable-track {
    background: transparent;
}

/* --- INFO PANEL --- */
.info-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 3000;
    display: none;
    flex-direction: column;
    max-height: 80vh;
    overflow-y: auto;
}

.info-panel.active {
    display: flex;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.info-title {
    font-size: 18px;
    font-weight: bold;
    color: #547c45;
}

.info-content {
    font-size: 14px;
    color: #444;
    line-height: 1.6;
}

.info-content h4 {
    margin-top: 10px;
    margin-bottom: 5px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}


/* --- PANNELLO EVENTI VICINI --- */
.nearest-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    padding: 10px;
    max-width: 320px;
    max-height: 40vh;
    overflow-y: auto;
    display: none;
}

.nearest-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.nearest-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #888;
    padding: 0 5px;
}

.close-btn:hover {
    color: #333;
}

.nearest-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nearest-item {
    padding: 10px;
    border-radius: 6px;
    background: #f9f9f9;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    border: 1px solid transparent;
}

.nearest-item:hover {
    background: #eee;
    border-color: #ddd;
}

.nearest-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.nearest-name {
    font-size: 13px;
    font-weight: bold;
    color: #333;
}

.nearest-spec {
    font-size: 11px;
    color: #777;
    font-weight: normal;
    margin-left: 5px;
}

.nearest-dist {
    font-size: 12px;
    font-weight: bold;
    color: #547c45;
    white-space: nowrap;
}

.nearest-address {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- POPUP DELLO STILE PIZZAMAP --- */
.leaflet-popup-content-wrapper {
    background: #FFFFFF;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.2);
    border-radius: 0px;
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 15px;
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    min-width: 200px;
}

.leaflet-popup-tip {
    background: #FFFFFF;
}

.leaflet-container a.leaflet-popup-close-button {
    padding: 8px 8px 0 0;
    color: #999;
}

.popup-title {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
    color: #d63838;
}

.popup-desc {
    font-size: 13px;
    color: #444;
    margin-bottom: 8px;
}

.popup-meta {
    font-size: 11px;
    color: #777;
    border-top: 1px solid #eee;
    padding-top: 5px;
    margin-top: 5px;
}

/* --- MAP LABELS & MARKERS --- */
.map-label {
    background: transparent;
    border: none;
    box-shadow: none;
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 700;
    font-size: 13px;
    color: #333;
    text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
    margin-top: 0px;
    /* Reduced distance from marker */
}

/* User Location Marker (Red Pulse) */
.user-pulse-marker {
    position: relative;
    width: 40px;
    height: 40px;
}

.user-pulse-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #E31B23;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.user-pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(227, 27, 35, 0.3);
    border-radius: 50%;
    animation: pulse 2s infinite;
    z-index: 1;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Marker Oggi (Verde con Alone Fisso) */
.marker-today {
    display: block !important;
}

.marker-today-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.marker-today-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    z-index: 1;
    animation: pulse-active-new 1.5s infinite;
}

@keyframes pulse-active-new {
    0% {
        transform: translate(-50%, -50%) scale(0.6);
        opacity: 0.9;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.0);
        opacity: 0;
    }
}

.marker-today-img {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.9));
}

/* Marker Passati (Grigio) */
.marker-past img {
    filter: grayscale(100%);
    opacity: 0.7;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .right-controls {
        top: 10px;
        right: 10px;
    }

    .control-btn {
        width: 35px;
        height: 35px;
    }

    .nearest-panel {
        left: 10px;
        right: 10px;
        bottom: 20px;
        max-width: none;
        width: auto;
    }
}

/* --- ADMIN TABLE STYLES --- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Alata', sans-serif;
    font-size: 14px;
    background: white;
}

.admin-table th,
.admin-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
    min-width: 120px;
}

.admin-table th {
    background-color: #f4f4f4;
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: bold;
    color: #333;
}

.admin-table td[contenteditable="true"]:hover {
    background-color: #fff9c4;
    cursor: text;
}

.admin-table td[contenteditable="true"]:focus {
    background-color: #fffde7;
    outline: 2px solid #547c45;
}

.admin-table tr:nth-child(even) {
    background-color: #fafafa;
}

.admin-table tr:hover {
    background-color: #f1f1f1;
}

.btn-delete-row {
    background: #d63838;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-delete-row:hover {
    background: #b92b2b;
}

.btn-delete-column {
    position: absolute;
    top: 2px;
    right: 5px;
    color: #d63838;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.btn-delete-column:hover {
    opacity: 1;
}