/* ========================================
   INTERACTIVE MAP STYLES - Leaflet + OpenStreetMap
   ======================================== */

/* ========================================
   MAP OVERLAY
   ======================================== */

.map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(42, 42, 42, 0.95);
    z-index: 30000;
    display: flex;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.map-overlay.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
}

/* ========================================
   LEAFLET MAP CONTAINER
   ======================================== */

.leaflet-map-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Override Leaflet default styles */
#leaflet-map {
    width: 100%;
    height: 100%;
}

/* Custom attribution styling */
.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.7) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    padding: 4px 8px !important;
    font-family: 'Niramit', sans-serif !important;
    font-size: 10px !important;
}

/* ========================================
   CATEGORY PILLS BAR
   ======================================== */

.category-pills-bar {
    position: absolute;
    top: 108px; /* sotto topbar (56px, Task 5) + striscia titolo percorso quando visibile (~40px) + margine */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.category-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 2px solid var(--category-color, #f17e18);
    border-radius: 25px;
    color: white;
    font-family: 'Niramit', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-pill i {
    font-size: 14px;
}

/* Active state */
.category-pill.active {
    background: var(--category-color, #f17e18);
    opacity: 1;
}

/* Inactive state */
.category-pill:not(.active) {
    opacity: 0.4;
}

.category-pill:hover {
    opacity: 0.8 !important;
    transform: scale(1.05);
}

/* Category colors - massima distinzione cromatica */
.category-pill[data-category="chiese"] {
    --category-color: #5B4B9E;
}

.category-pill[data-category="monumenti"] {
    --category-color: #E76F51;
}

.category-pill[data-category="porte"] {
    --category-color: #2E86AB;
}

.category-pill[data-category="museo"] {
    --category-color: #7CB518;
}

/* ========================================
   CLOSE BUTTON
   ======================================== */

.map-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(241, 126, 24, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-close-btn:hover {
    background: rgba(241, 126, 24, 1);
    transform: rotate(90deg);
    box-shadow: 0 5px 20px rgba(241, 126, 24, 0.5);
}

/* ========================================
   CLOSE BUTTON
   ======================================== */

.map-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(241, 126, 24, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 30001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-close-btn:hover {
    background: rgba(241, 126, 24, 1);
    transform: rotate(90deg);
    box-shadow: 0 5px 20px rgba(241, 126, 24, 0.5);
}

/* ========================================
   LEAFLET MARKER STYLES
   ======================================== */

.custom-marker {
    background: transparent;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

/* Monument Popup Styles */
.monument-popup {
    min-width: 200px;
    overflow: hidden;
}

.monument-popup__img-wrapper {
    width: 100%;
    height: 160px;
    overflow: hidden;
}

.monument-popup img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    object-position: center;
    display: block;
}

.monument-popup-content {
    padding: 12px 16px;
    text-align: left;
}

.monument-popup-title {
    display: block;
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: rgb(241, 126, 24);
    margin-bottom: 6px;
}

.monument-popup-description {
    font-family: 'Niramit', sans-serif;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.4;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.monument-popup-link {
    display: inline-block;
    font-family: 'Niramit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgb(241, 126, 24);
    text-decoration: none;
    transition: color 0.2s;
}

.monument-popup-link:hover {
    color: rgb(200, 100, 20);
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
}

.leaflet-popup-tip {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.3);
}

.leaflet-popup-close-button {
    display: none;
}

/* Fix popup clipping at map edges */
.leaflet-popup {
    /* Allow popup to extend beyond map container */
    position: absolute;
}

.leaflet-map-pane {
    overflow: visible !important;
}

.leaflet-container {
    overflow: visible !important;
}

/* Ensure popup container doesn't clip */
#leaflet-map {
    overflow: visible !important;
}

/* Critical fix: allow popup pane to overflow */
.leaflet-popup-pane {
    z-index: 1000 !important;
}

/* Make sure map overlay doesn't clip popups */
.map-overlay.active {
    overflow: visible;
}

.leaflet-map-container {
    overflow: visible;
    position: relative;
}

/* Position popup fixed to viewport when near edges */
.custom-popup {
    z-index: 100000 !important;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .category-pills-bar {
        top: auto;
        bottom: 80px;
        flex-wrap: wrap;
        justify-content: center;
        border-radius: 20px;
        max-width: calc(100% - 40px);
        padding: 6px 10px;
        gap: 6px;
    }

    .category-pill {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .category-pill i {
        font-size: 12px;
    }

    .category-pill span {
        display: none;
    }

    /* Show text only for larger mobile screens */
    @media (min-width: 480px) {
        .category-pill span {
            display: inline;
        }
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.category-item {
    animation: fadeIn 0.3s ease backwards;
}

.category-item:nth-child(1) { animation-delay: 0.05s; }
.category-item:nth-child(2) { animation-delay: 0.1s; }
.category-item:nth-child(3) { animation-delay: 0.15s; }
.category-item:nth-child(4) { animation-delay: 0.2s; }

/* ========================================
   ZOOM CONTROLS CUSTOMIZATION
   ======================================== */

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #333 !important;
    border: none !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
}

.leaflet-control-zoom a:hover {
    background-color: #fff !important;
}
