/* Frontend Map Dynamic Styles - TCR Theme Integration */

/* Custom marker styles */
.custom-div-icon {
    background: transparent !important;
    border: none !important;
}

.custom-marker {
    transition: all 0.3s ease;
    cursor: pointer;
}

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4) !important;
}

/* Bootstrap Icons in markers */
.custom-marker i {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === POPUP PERSONALIZZATO CON STILI TCR === */
.leaflet-popup-content-wrapper {
    border-radius: 9px; /* Utilizza il radius del tema */
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1); /* Come negli eventi timeline */
    border: none;
    overflow: hidden;
    max-width: calc(100vw - 40px);
    background: white;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
    font-family: 'Raleway', sans-serif; /* Font principale del tema */
    line-height: 1.4;
    max-width: 100%;
}

.map-popup {
    min-width: 220px;
    max-width: 320px;
    width: 100%;
    box-sizing: border-box;
}

/* === HEADER POPUP CON STILI TCR === */
.popup-header {
    padding: 20px 15px 10px;
    background: var(--tcr-blu-sky); /* Colore principale TCR */
    color: white;
    margin: 0;
    word-wrap: break-word;
    position: relative;
}

.popup-header h6 {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-transform: uppercase; /* Stile del tema */
    font-family: 'Merriweather Sans', sans-serif; /* Font secondario del tema */
}

.popup-header .badge {

    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px; /* Radius più squadrato come nel tema */
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: uppercase;
}

/* === BODY POPUP === */
.popup-body {
    padding: 15px 15px 20px;
    color: var(--text-dark2);
    background: white;
}

.popup-body p {
    margin-bottom: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-dark2);
}

.popup-body small {
    color: var(--text-gray7);
    font-size: 0.8rem;
}

.popup-body i {
    color: var(--tcr-blu-light);
    margin-right: 5px;
}

/* === META INFO === */
.popup-meta {
    background: var(--bg-gray1);
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    border-left: 3px solid var(--tcr-yellow);
}

.popup-meta small {
    display: block;
    margin-bottom: 3px;
    font-size: 0.8rem;
    color: var(--text-gray7);
}

.popup-meta strong {
    color: var(--text-dark2);
    font-weight: 600;
}

/* === TIP DELLA POPUP === */
.leaflet-popup-tip {
    background: white;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* === CONTAINER MAPPA === */
#expedition-leaflet-map {
    border-radius: 9px; /* Radius del tema */
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1); /* Come nel tema */
    transition: all 0.3s ease;
    border: 1px solid var(--bg-gray3);
}

#expedition-leaflet-map:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* === CONTROLLI MAPPA === */
.leaflet-control-zoom {
    border: none;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.leaflet-control-zoom a {
    background: white;
    color: var(--tcr-blu-sky);
    border: 1px solid var(--bg-gray3);
    width: 36px;
    height: 36px;
    line-height: 34px;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease; /* Transizione del tema */
}

.leaflet-control-zoom a:hover {
    background: var(--tcr-blu-sky);
    color: white;
    transform: scale(1.05);
    border-color: var(--tcr-blu-sky);
}

.leaflet-control-zoom a:first-child {
    border-radius: 4px 4px 0 0;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 4px 4px;
}

/* === ATTRIBUTION === */
.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 4px;
    font-size: 0.75rem;
    padding: 4px 8px;
    border: 1px solid var(--bg-gray3);
}

/* === FILTRI MAPPA === */
.map-filters {
    background: white;
    border-radius: 9px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--bg-gray3);
}

.map-filters h6 {
    margin-bottom: 15px;
    color: var(--tcr-blu-sky);
    font-weight: 600;
    text-transform: uppercase;
    font-family: 'Merriweather Sans', sans-serif;
}

.map-type-filter {
    margin-right: 16px;
    margin-bottom: 10px;
}

.filter-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 4px;
    background: var(--bg-gray1);
    border: 1px solid var(--bg-gray3);
    transition: all 0.3s ease;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.filter-checkbox:hover {
    background: var(--bg-gray2);
    border-color: var(--tcr-blu-light);
    transform: translateY(-1px);
}

.filter-checkbox input[type="checkbox"] {
    margin: 0;
    accent-color: var(--tcr-blu-sky);
}

.filter-checkbox.active {
    background: var(--tcr-blu-sky);
    color: white;
    border-color: var(--tcr-blu-sky);
}

/* === STATI DI CARICAMENTO === */
.map-loading {
    position: relative;
}

.map-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-gray3);
    border-top: 4px solid var(--tcr-blu-sky);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 30px);
        min-width: 200px;
    }

    .map-popup {
        min-width: 200px;
        max-width: 280px;
        width: auto;
    }

    .popup-header {
        padding: 15px 12px 8px;
    }

    .popup-header h6 {
        font-size: 0.85rem;
        line-height: 1.1;
        margin-bottom: 6px;
    }

    .popup-header .badge {
        font-size: 0.65rem;
        padding: 3px 6px;
        gap: 3px;
    }

    .popup-body {
        padding: 10px 12px 15px;
    }

    .popup-body p {
        font-size: 0.8rem;
        line-height: 1.3;
        margin-bottom: 8px;
    }

    .popup-meta {
        padding: 8px;
        margin-top: 8px;
    }

    .popup-meta small {
        font-size: 0.7rem;
        margin-bottom: 2px;
    }

    /* Icone marker più piccole */
    .custom-marker {
        width: 26px !important;
        height: 26px !important;
    }

    .custom-marker i {
        font-size: 12px !important;
    }

    /* Controlli zoom più piccoli */
    .leaflet-control-zoom a {
        width: 32px;
        height: 32px;
        line-height: 30px;
        font-size: 16px;
    }

    .map-filters {
        padding: 15px;
        margin-bottom: 16px;
    }

    .filter-checkbox {
        padding: 6px 10px;
        margin-right: 8px;
        margin-bottom: 8px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    #expedition-leaflet-map {
        height: 400px !important;
        border-radius: 6px;
    }

    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 20px);
        min-width: 180px;
    }

    .map-popup {
        min-width: 180px;
        max-width: 240px;
    }

    .popup-header {
        padding: 12px 10px 6px;
    }

    .popup-header h6 {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }

    .popup-header .badge {
        font-size: 0.6rem;
        padding: 2px 5px;
    }

    .popup-body {
        padding: 8px 10px 12px;
    }

    .popup-body p {
        font-size: 0.75rem;
        line-height: 1.2;
    }

    .popup-meta {
        padding: 6px;
    }

    .popup-meta small {
        font-size: 0.65rem;
    }

    /* Marker ancora più piccoli */
    .custom-marker {
        width: 22px !important;
        height: 22px !important;
    }

    .custom-marker i {
        font-size: 10px !important;
    }
}

/* === TOOLTIP PERSONALIZZATO === */
.leaflet-tooltip {
    background: var(--tcr-blu-sky);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 0.8rem;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-weight: 500;
}

.leaflet-tooltip-top:before {
    border-top-color: var(--tcr-blu-sky);
}

.leaflet-tooltip-bottom:before {
    border-bottom-color: var(--tcr-blu-sky);
}

.leaflet-tooltip-left:before {
    border-left-color: var(--tcr-blu-sky);
}

.leaflet-tooltip-right:before {
    border-right-color: var(--tcr-blu-sky);
}

/* === CLUSTERING === */
.marker-cluster-small {
    background-color: var(--tcr-blu-light);
    border-radius: 50%;
    color: white;
    border: 3px solid white;
}

.marker-cluster-medium {
    background-color: var(--tcr-yellow);
    border-radius: 50%;
    color: var(--tcr-black);
    border: 3px solid white;
}

.marker-cluster-large {
    background-color: var(--tcr-blu-dark);
    border-radius: 50%;
    color: white;
    border: 3px solid white;
}

.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
}

.marker-cluster:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

/* === ANIMAZIONI === */
@keyframes markerBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) rotate(-45deg);
    }
    40% {
        transform: translateY(-10px) rotate(-45deg);
    }
    60% {
        transform: translateY(-5px) rotate(-45deg);
    }
}

.marker-bounce {
    animation: markerBounce 1s ease-in-out;
}

.map-fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease-in forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === UTILITY CLASSES === */
.map-hidden {
    display: none !important;
}

.map-visible {
    display: block !important;
}



.map-type--event {
    color: #000;
    background-color: #28a745;
}

.map-type--trip_stop {
    color: #000;
    background-color: #007bff;
}

.map-type--projection {
    color: #000;
    background-color: #6c757d;
}
.map-type--festival {
    color: #000;
    background-color: #fd7e14;
}

.map-type--manifestation {
    color: #000;
    background-color: #20c997;
}
.map-type--conference {
    color: #000;
    background-color: #17a2b8;
}

.popup-header {
    background: var(--tcr-blu-sky);
}
