/* Stili per i modal dei popup */

/* Overlay di base */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10002;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Modal di base */
.poi-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    height: auto;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    animation: modalFadeIn 0.3s ease;
    position: relative;
}

/* Desktop: overlay non bloccante e modal sopra la sidebar */
@media (min-width: 769px) {
    .popup-overlay.poi-modal-overlay {
        background: transparent; /* nessun oscuramento */
        pointer-events: none;     /* non intercetta i click, lascia interagire con mappa/UI */
        z-index: 1500;           /* sopra sidebar (#sidebar z-index: 2) e user-menu (1000) */
    align-items: stretch;  /* il contenitore copre tutta l'altezza */
    justify-content: flex-start;
    padding: 0;            /* nessun padding che accorcia il pannello */
    }

    .popup-overlay.poi-modal-overlay .poi-modal {
        pointer-events: auto;     /* il modal resta interattivo */
        position: fixed;          /* JS imposta top/left/width */
        z-index: 1501;            /* sopra l'overlay trasparente */
    height: 100dvh;           /* full height su desktop */
    max-height: none !important; /* non limitare l'altezza a 90vh */
    border-radius: 0 12px 12px 0; /* pannello sinistro */
    margin: 0;                /* nessun margine che crei gap */
    }

    /* Lightweight modal for personal "Da visitare" POIs */
    .popup-overlay.poi-modal-overlay .poi-modal.poi-modal-to-visit {
        height: 100dvh !important;
        max-height: none !important;
    }
}

/* Animazioni */
@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Contenuto del modal - ora scorrevole */
.poi-modal-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    padding-bottom: 60px; /* Spazio ridotto per i pulsanti fissi */
}

/* Scrollbar moderna, sottile e visibile solo al passaggio del mouse (desktop) */
@media (min-width: 769px) {
    /* Desktop: nascondi sempre la scrollbar per evitare reflow del testo al passaggio del mouse */
    .poi-modal-content {
        scrollbar-width: none;            /* Firefox */
    }

    /* WebKit (Chrome, Edge, Safari): nascondi sempre */
    .poi-modal-content::-webkit-scrollbar {
        width: 0;
        height: 0;
    }
}

/* Container immagini */
.popup-image-container, .carousel-container {
    width: 100%;
    height: 338px;
    min-height: 250px;
    overflow: hidden;
    position: relative;
    background: #f5f5f5;
}

/* Panel Street View inline nella scheda POI (stessa altezza dell'image container) */
.poi-sv-panel {
    width: 100%;
    height: 338px;
    min-height: 250px;
    overflow: hidden;
    position: relative;
    background: #000;
}

.poi-sv-panel iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
    background: #000;
}

.popup-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    opacity: 1;
}

/* Gestione automatica per immagini verticali */
.popup-image-container img[data-orientation="portrait"] {
    object-fit: contain;
    background: #000;
}

.popup-image-container.portrait-image {
    background: #000; /* sfondo nero per le foto verticali */
}

/* Badge 'Aggiungi foto' in basso a sinistra sull'immagine */
.img-add-photo-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.42);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: background 0.2s;
    white-space: nowrap;
}

.img-add-photo-btn:hover {
    background: rgba(0,0,0,0.65);
}

/* Bottoni overlay immagine */
.image-overlay-buttons {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 70%, transparent 100%);
    transition: opacity 0.3s ease;
    pointer-events: auto;
    z-index: 2;
}
/* In assenza di immagini, nasconde la barra overlay inferiore per evitare sovrapposizioni */
.popup-image-container.no-image .image-overlay-buttons {
    display: none !important;
}

/* Nuovo contenitore overlay in alto a sinistra (per Street View) */
.image-overlay-top-left {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    z-index: 2;
}

.image-overlay-top-left .overlay-btn {
    background: rgba(0,0,0,0.5);
    color: #fff;
}

.image-overlay-top-left .overlay-btn:hover {
    background: rgba(0,0,0,0.7);
}

.overlay-btn {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 6px;
    color: white;
    background: rgba(0,0,0,0.5);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.overlay-btn.left {
    margin-right: auto;
}

.overlay-btn.right {
    margin-left: auto;
    background: none;
    font-style: italic;
    font-size: 0.8em;
}

.overlay-btn:hover {
    background: rgba(0,0,0,0.7);
    transform: translateY(-1px);
}

.overlay-btn.right:hover {
    background: none;
    transform: none;
}

.overlay-btn svg {
    width: 16px;
    height: 16px;
    stroke: white;
}

/* Testo submitted by */
.submitted-by {
    font-size: 0.85em;
    color: #666;
    margin: -10px 0 15px;
    font-style: italic;
}

/* Stili per contenitore senza immagine */
.popup-image-container.no-image {
    cursor: default; /* il contenitore non è più cliccabile */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7f7f7; /* leggermente più chiaro per evidenziare l'assenza foto */
    transition: background-color 0.3s;
    /* Compatta l'altezza quando non ci sono foto */
    height: 140px;
    min-height: 0;
    padding: 10px 12px;
    position: relative; /* necessario per overlay full-cover */
}

.popup-image-container.no-image:hover { background: #f0f0f0; }

.no-image-content {
    /* Trasforma il contenuto in un overlay full-cover con stile JS originale */
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px; /* mantiene padding originale JS */
    background: rgba(0, 0, 0, 0.45); /* overlay meno scuro */
    color: white; /* mantiene colore testo originale JS */
    backdrop-filter: blur(2px); /* meno blur */
    border-radius: 0; /* rimossi angoli arrotondati per coincidere con foto */
    z-index: 2;
    text-align: center;
}

.no-image-content svg {
    margin-bottom: 10px;
    color: white; /* icona bianca su fondo scuro */
}

.no-image-content p {
    margin-bottom: 15px; /* spaziatura originale JS */
    font-size: 16px; /* dimensione originale JS */
    color: white; /* colore testo su fondo scuro */
}

.upload-photo-btn {
    background: #ffffff;
    color: #2e7d32;
    border: 1px solid rgba(255,255,255,0.85);
    padding: 8px 16px; /* padding originale JS */
    border-radius: 6px; /* border-radius originale JS */
    font-size: 14px; /* dimensione originale JS */
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
    font-weight: 500; /* peso carattere originale JS */
}

.upload-photo-btn:hover {
    background: #f0fdf4;
    color: #14532d;
    box-shadow: 0 0 0 1px rgba(209,250,229,0.8);
}

/* Contenuto del popup */
.popup-content {
    padding: 24px 20px 20px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.popup-content h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.3em;
    font-weight: 600;
    text-align: left;
    width: 100%;
    clear: both;
    padding: 0 0 15px 0;
    border-bottom: 1px solid #e0e0e0;
}

.popup-content p {
    margin: 0 0 20px 0;
    line-height: 1.6;
    color: #333;
    font-size: 0.95em;
}

.poi-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 24px 20px 0 20px;
}

.poi-modal-title {
    font-size: 1.28em;
    font-weight: 600;
    margin: 0;
    color: #1f1f1f;
}

.to-visit-title-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}


/* Stili per i pulsanti header del modal */
.poi-modal-header-buttons {
    position: absolute;
    top: 10px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 10003;
}

/* Contenitore pulsanti header a sinistra (es. Street View) */
.poi-modal-header-left {
    position: absolute;
    top: 10px;
    left: 16px;
    display: flex;
    gap: 8px;
    z-index: 10003;
}

.poi-modal-close,
.favorite-btn,
.share-btn,
.streetview-btn {
    width: 35px;
    height: 35px;
    background: white;
    border: none;
    border-radius: 50%;
    padding: 0;
    flex: 0 0 auto;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    position: relative;
}

.poi-modal-close {
    font-size: 20px;
    color: #333;
}

.poi-modal-close:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.favorite-btn svg,
.share-btn svg {
    width: 18px;
    height: 18px;
    stroke: #333;
    fill: none;
    stroke-width: 2;
    transition: all 0.2s ease;
}

/* Icona Font Awesome per Street View */
.streetview-btn i {
    font-size: 18px;
    color: #333;
    line-height: 1;
}

.favorite-btn.active svg {
    fill: #ff4757;
    stroke: #ff4757;
}

.favorite-btn:hover,
.share-btn:hover,
.streetview-btn:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.streetview-btn.plus-required::after,
.favorite-btn.plus-required::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 10px;
    height: 10px;
    background: #FFC107;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #ffffff;
}

.poi-modal-footer {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: #e9ecef;
    padding: 15px 20px;
    border-top: 1px solid #d0d0d0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Assicura stessa altezza e niente testo su due righe
   per i pulsanti principali nel footer POI, anche su mobile */
.poi-modal-footer .add-to-route-btn.fixed-bottom,
.poi-modal-footer .google-maps-btn.fixed-bottom {
    white-space: nowrap;
    min-height: 44px; /* stessa altezza minima per entrambi i pulsanti */
}

.add-to-route-btn.fixed-bottom {
    width: 100%;
    margin: 0;
    background-color: #4CAF50;
    color: white;
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.add-to-route-btn.fixed-bottom:hover {
    background-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.google-maps-btn.fixed-bottom {
    width: 100%;
    margin: 0;
    background-color: #4285F4;
    color: white;
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.google-maps-btn.fixed-bottom:hover {
    background-color: #3367D6;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.google-maps-btn.fixed-bottom .plus-badge {
    background: #FFC107;
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    margin-left: 8px;
    font-weight: bold;
}

/* POI footer: submenu "Apri in Mappe" */
.poi-modal-footer .poi-maps-group {
    position: relative;
    width: 100%;
}

@media (min-width: 769px) {
    .poi-modal-footer .poi-maps-group {
        flex: 1 1 0;
        width: auto;
    }
}

.poi-modal-footer .poi-maps-group .google-maps-btn.fixed-bottom {
    width: 100%;
    padding-right: 44px; /* spazio per il toggle menu */
}

.poi-modal-footer .poi-maps-menu-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    z-index: 2;
}

.poi-modal-footer .poi-maps-menu-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: 2px;
}

.poi-modal-footer .poi-footer-maps-menu {
    top: auto;
    bottom: calc(100% + 10px);
    left: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    z-index: 20;
}

.poi-modal-footer .poi-footer-maps-menu .plus-badge {
    background: #FFC107;
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    margin-left: auto;
    font-weight: bold;
}

/* Desktop: affianca i pulsanti nel footer */
@media (min-width: 769px) {
    .poi-modal-footer {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }
    .poi-modal-footer .add-to-route-btn.fixed-bottom,
    .poi-modal-footer .google-maps-btn.fixed-bottom {
        width: auto;
        flex: 1 1 0;
    }
}

/* Nascondi il pulsante originale nei modal buttons */
.poi-modal-buttons {
    display: none;
}

@media (max-width: 768px) {
    .poi-modal-header-buttons {
        top: 15px;
        right: 15px;
        gap: 10px;
    }
    
    .poi-modal-close,
    .favorite-btn,
    .share-btn,
    .streetview-btn {
        width: 34px;   /* leggermente più piccoli su mobile */
        height: 34px;
    }
    
    .favorite-btn svg,
    .share-btn svg {
        width: 18px;
        height: 18px;
    }

    .streetview-btn i { font-size: 16px; }
    
    /* Modal POI come bottom sheet su mobile, mappa visibile sopra */
    .popup-overlay.poi-modal-overlay {
        padding: 0 !important;
        align-items: flex-end !important; /* posiziona il modal in basso */
        justify-content: center !important;
        background: transparent !important; /* lascia la mappa visibile */
        pointer-events: none; /* non blocca interazioni con la mappa sopra */
    }

    .popup-overlay.poi-modal-overlay .poi-modal {
        width: 100% !important;
        max-width: none !important;
        border-radius: 12px 12px 0 0 !important; /* angoli arrotondati sopra */
        margin: 0 !important;
        pointer-events: auto; /* il modal resta interattivo */
        height: 60vh !important;
        max-height: 60vh !important;
    }

    /* Lightweight modal for personal "Da visitare" POIs */
    .popup-overlay.poi-modal-overlay .poi-modal.poi-modal-to-visit {
        height: 60vh !important;
        max-height: 60vh !important;
    }

    /* Stato ridotto per mostrare solo le azioni */
    .popup-overlay.poi-modal-overlay .poi-modal.collapsed {
        height: auto !important;
        max-height: 175px !important;
        min-height: 120px !important;
        justify-content: flex-end;
    }

    .popup-overlay.poi-modal-overlay .poi-modal.expanded-top {
        height: var(--poi-modal-expanded-height, 80vh) !important;
        max-height: var(--poi-modal-expanded-height, 80vh) !important;
    }

    .popup-overlay.poi-modal-overlay .poi-modal.collapsed .poi-modal-content {
        max-height: 0;
        flex: 0 0 auto;
        overflow: hidden;
        padding: 0;
        opacity: 0;
        pointer-events: none;
    }

    .popup-overlay.poi-modal-overlay .poi-modal-content {
        padding-bottom: 70px; /* spazio ridotto per i pulsanti fissi su mobile */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .poi-modal-footer {
        padding: 10px 12px;            /* leggermente più compatta */
        flex-direction: row;            /* affianca i pulsanti su mobile */
        align-items: center;
        gap: 8px;                       /* spazio tra i pulsanti */
    }

    .poi-modal.poi-modal-to-visit .to-visit-actions-row {
        flex-wrap: nowrap;
        gap: 8px;
    }

    /* Maniglia per ridurre/espandere velocemente il bottom sheet */
    .sheet-handle {
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 44px;
        height: 5px;
        border-radius: 3px;
        background: rgba(0,0,0,0.25);
        cursor: pointer;
        z-index: 10005; /* sopra al contenuto */
    }

    /* Regione di trascinamento più ampia per catturare i drag verticali */
    .sheet-drag-region {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 36px; /* area comoda per il pollice */
        z-index: 10002; /* sotto i pulsanti header (10003) */
        cursor: grab;
        /* non visibile, ma presente per gli eventi */
        background: transparent;
        /* Evita che tocchi/scroll passino al contenuto sotto durante il drag */
        touch-action: none;
    }

    /* Pulsanti più piccoli e affiancati */
    .poi-modal-footer .add-to-route-btn.fixed-bottom,
    .poi-modal-footer .google-maps-btn.fixed-bottom {
        width: auto;                    /* override del 100% */
        flex: 1 1 0;                    /* due colonne di pari larghezza */
        min-width: 0;                   /* consenti shrink reale (evita che uno schiacci l'altro) */
        padding: 10px 12px;             /* più piccoli */
        font-size: 0.9em;               /* testo più piccolo */
        border-radius: 6px;
    }

    /* Il wrapper del menu mappe deve comportarsi come un bottone (50/50) */
    .poi-modal-footer .poi-maps-group {
        width: 0;
        min-width: 0;
        flex: 1 1 0;
    }

    /* Il bottone dentro al wrapper deve riempire la sua metà */
    .poi-modal-footer .poi-maps-group .google-maps-btn.fixed-bottom {
        width: 100%;
        padding-right: 44px; /* spazio per il toggle menu (ripristina su mobile) */
    }
    /* Altezza ancora più compatta su mobile per lo stato senza immagine */
    .popup-image-container.no-image {
        height: 110px;
        padding: 8px 10px;
    }
    
    /* Altezza ridotta per le foto su mobile */
    .popup-image-container, .carousel-container {
        height: 280px;
        min-height: 220px;
    }

    .poi-sv-panel {
        height: 280px;
        min-height: 220px;
    }
    
    /* Nascondi i pulsanti di navigazione del carosello su mobile */
    .carousel-btn {
        display: none !important;
    }
}

/* Compact layout + actions row for personal "Da visitare" POIs */
.poi-modal.poi-modal-to-visit .poi-modal-content {
    padding-bottom: 16px;
}

.poi-modal.poi-modal-to-visit .popup-content {
    padding: 0 20px 20px;
}

.popup-content-to-visit {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 18px;
}

.to-visit-description-card {
    border: 1px solid #e6e8eb;
    border-radius: 12px;
    background: #f9fafc;
    padding: 16px;
}

.to-visit-card-label {
    font-size: 0.75em;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #6c7a89;
    font-weight: 600;
}

.to-visit-description {
    margin: 8px 0 0 0;
    color: #4a4f58;
    line-height: 1.6;
    font-size: 0.95em;
    font-weight: 400;
}

.to-visit-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.to-visit-meta-row-header {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e4e7eb;
}

.to-visit-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f1f3f4;
    color: #5f6368;
    font-weight: 500;
    font-size: 0.82em;
    border: 1px solid #e4e7eb;
}

.to-visit-meta-pill-flag {
    background: #fff8e1;
    border-color: #ffe08a;
    color: #d48a00;
}

.to-visit-flag-icon {
    color: #ffca28;
}

@media screen and (max-width: 768px) {
    .to-visit-meta-row.to-visit-meta-row-header {
        flex-wrap: nowrap;
        gap: 6px;
        align-items: center;
    }

    .to-visit-meta-row.to-visit-meta-row-header .to-visit-meta-pill {
        white-space: nowrap;
    }

    .to-visit-meta-row.to-visit-meta-row-header .to-visit-meta-pill:first-child {
        flex: 0 0 auto;
    }

    .to-visit-meta-row.to-visit-meta-row-header .to-visit-meta-pill:last-child {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.to-visit-actions-row {
    display: flex;
    width: 100%;
    gap: 12px;
    align-items: stretch;
    flex-wrap: wrap;
}
.poi-modal.poi-modal-to-visit .poi-modal-footer .to-visit-actions-row {
    flex: 1 1 auto;
    width: 100%;
}

.to-visit-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
}

.to-visit-secondary-btn,
.to-visit-danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #d0d0d0;
    background: #fff;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88em;
    white-space: nowrap;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.to-visit-secondary-btn:hover {
    background: #f7f7f7;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.to-visit-danger-btn {
    border-color: rgba(244, 67, 54, 0.35);
    color: #f44336;
}

.to-visit-danger-btn:hover {
    background: rgba(244, 67, 54, 0.08);
}

/* Make primary action take remaining space */
.poi-modal.poi-modal-to-visit .to-visit-actions-row .add-to-route-btn.fixed-bottom {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.poi-modal.poi-modal-to-visit .to-visit-actions-row .google-maps-btn.fixed-bottom {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.poi-modal.poi-modal-to-visit .to-visit-actions-row .poi-maps-group {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

/* Desktop: altezza compatta senza immagine */
@media (min-width: 769px) {
    .popup-image-container.no-image {
        height: 140px;
    }
}

/* Nasconde eventuali controlli del carosello nello stato senza immagine */
.popup-image-container.no-image .carousel-controls,
.popup-image-container.no-image .carousel-btn,
.popup-image-container.no-image .carousel-indicators {
    display: none !important;
}

/* Pulsanti */
.add-to-route-btn {
    display: flex !important;
    align-items: center;
    gap: 8px;
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: background-color 0.2s;
    font-size: 0.9em;
}

.contribute-photos-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    background-color: #f0f0f0;
    color: #444444;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s;
}

.contribute-photos-btn:hover {
    background-color: #e0e0e0;
}

.contribute-photos-btn svg {
    margin-right: 8px;
    stroke: #444444;
}

/* Utility classes */
.text-center {
    text-align: center;
}

.text-sm {
    font-size: 0.8em;
}

.text-muted {
    color: #6c757d;
}

.mt-1 {
    margin-top: 4px;
}

.mb-4 {
    margin-bottom: 16px;
}

/* Stili per il carosello */
.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.carousel-slide.active {
    opacity: 1;
    display: block;
    width: 100%;
    height: 100%;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.carousel-controls {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    pointer-events: none;
}

.carousel-btn {
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    margin: 0 10px;
    pointer-events: auto;
    transition: all 0.2s ease;
}

.carousel-btn:hover {
    background: rgba(0,0,0,0.8);
    transform: scale(1.1);
}

.carousel-indicators {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 5px;
    pointer-events: auto;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    cursor: pointer;
}

.indicator.active {
    background: white;
}

/* POI action pills (Google Maps-style)
   Note: keep ASCII for class names, text is in HTML. */
.poi-action-pills {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 0 0 12px;
    margin: 0 0 12px;
    scrollbar-width: none;
}

.poi-action-pills::-webkit-scrollbar {
    display: none;
}

.poi-pill-btn {
    white-space: nowrap;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #1f2937;
    border-radius: 9999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s ease;
}

.poi-pill-btn i {
    margin-right: 6px;
}

.poi-pill-btn:hover {
    border-color: #cbd5f5;
    box-shadow: 0 4px 10px rgba(76,175,80,0.18);
}

.poi-pill-btn.active {
    background: #4CAF50;
    color: #ffffff;
    border-color: #4CAF50;
}

.poi-pill-group {
    position: relative;
}

.poi-pill-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 190px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    display: none;
    z-index: 5;
}

.poi-pill-group.open .poi-pill-menu {
    display: block;
}

.poi-pill-menu button,
.poi-pill-menu a {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
    text-align: left;
}

.poi-pill-menu button:hover,
.poi-pill-menu a:hover {
    background: #f3f4f6;
}

@media screen and (max-width: 768px) {
    .poi-action-pills {
        padding: 0 0 8px;
        margin-bottom: 8px;
    }
}

/* Stili per la sezione commenti */
.poi-comments-section {
    margin-top: 20px;
    padding-top: 20px;
}

.comments-title {
    font-size: 0.95em;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.comments-list {
    margin-bottom: 20px;
}

.comment-item {
    padding: 12px;
    border-radius: 8px;
    background: #f9f9f9;
    margin-bottom: 10px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-author {
    font-weight: 600;
    color: #4CAF50;
    font-size: 0.85em;
}

.comment-date {
    font-size: 0.8em;
    color: #777;
}

.comment-text {
    line-height: 1.4;
    color: #333;
    font-size: 0.85em;
}

.add-comment-form h5 {
    font-size: 0.9em;
    margin-bottom: 12px;
    font-weight: 600;
    color: #333;
}

.comment-form-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment-form-row {
    display: flex;
    gap: 10px;
}

.comment-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85em;
}

.comment-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
    font-size: 0.85em;
}

.submit-comment-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    align-self: flex-start;
    transition: background-color 0.2s;
}

.submit-comment-btn:hover {
    background: #45a049;
}

.loading-comments {
    text-align: center;
    padding: 15px;
    color: #777;
    font-style: italic;
    font-size: 0.85em;
}

.no-comments {
    text-align: center;
    padding: 15px;
    color: #777;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 0.85em;
}

/* Spazio extra per mobile ridotto */
.mobile-padding-bottom {
    height: 20px; /* spazio minimo per completare lo scroll */
    width: 100%;
}

/* Stili per il segmento mappa */
.poi-road-segment-section {
    margin-top: 20px;
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
}

.segment-map-title {
    font-size: 0.95em;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.segment-map-title small {
    font-size: 0.8em;
    color: #666;
    opacity: 0.7;
    font-weight: normal;
    transition: opacity 0.2s;
}

.segment-map-title:hover small {
    opacity: 1;
    color: #4CAF50;
}

.segment-map-container {
    width: 100%;
    height: 250px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
}

.map-error-container {
    text-align: center;
    padding: 20px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f5f5f5;
}

.error-message {
    text-align: center;
    padding: 20px;
    color: #888;
}

.retry-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background-color 0.2s;
}

.retry-button:hover {
    background: #388E3C;
}

/* Media queries duplicati rimossi - mantenute solo le regole aggiuntive */
@media (max-width: 768px) {
    /* Riduce il padding superiore del contenuto per avvicinare il titolo alla foto */
    .popup-content {
        padding-top: 10px;
        padding-right: 16px; /* leggermente più stretti su mobile */
        padding-bottom: 16px;
        padding-left: 16px;
    }

    .popup-content p {
        line-height: 1.6;
        color: #333;
        font-size: 0.95em;
        margin: 0 0 20px 0;
    }

    .popup-content h3 {
        margin: 10px 0 20px 0;
        color: #333;
        font-size: 1.3em;
        font-weight: 600;
        text-align: left;
        width: 100%;
        clear: both;
        padding: 0 0 15px 0;
        border-bottom: 1px solid #e0e0e0;
    }

    /* Ripristino regole rimosse */
    .comment-form-row {
        flex-direction: column;
    }

    .segment-map-container {
        border-radius: 8px;
        margin: 0;
        width: 100%;
        border: 1px solid #e0e0e0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        margin-bottom: 20px;
    }

    .contributor-badge {
        font-size: 0.8em;
        padding: 4px 10px;
    }

    .contributor-badge-container {
        margin-top: 15px;
        margin-bottom: 15px;
    }

    .contributor-badge .contributor-tooltip {
        left: 0;
        transform: translateX(0);
        width: 200px;
    }

    .contributor-badge:hover .contributor-tooltip {
        transform: translateX(0) translateY(2px);
    }
}

/* Touch handling */
.poi-modal-content,
.poi-modal {
    touch-action: pan-x pan-y !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.popup-image-container img,
.carousel-slide img {
    touch-action: pan-x pan-y !important;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Regole specifiche mobile */
@media (max-width: 768px) {
    /* Normalizzazione testo per Android */
    .popup-content {
    }

    /* Normalizzazione specifica per descrizioni su Android */
    .popup-content p {
        line-height: 1.4 !important; /* ancora più compatto per Android */
        font-size: 0.85em !important; /* ridotto ulteriormente */
        margin: 0 0 12px 0 !important; /* meno spazio tra paragrafi */
        font-weight: 400 !important; /* peso carattere normale */
        letter-spacing: normal !important;
    }

    /* Titoli più consistenti su Android */
    .popup-content h3 {
        font-size: 1.1em !important; /* leggermente ridotto per Android */
        line-height: 1.3 !important;
        margin: 4px 0 10px 0 !important;
        padding-top: 4px;
        padding-bottom: 8px;
    }

    /* Normalizzazione pulsanti per Android */
    .poi-modal-footer .add-to-route-btn.fixed-bottom,
    .poi-modal-footer .google-maps-btn.fixed-bottom {
        font-size: 0.85em !important; /* leggermente più piccolo per Android */
        line-height: 1.2 !important;
    }

    /* Commenti più compatti su Android */
    .comment-input,
    .comment-textarea,
    .submit-comment-btn {
        font-size: 0.8em !important;
        line-height: 1.3 !important;
    }

    .comments-title {
        font-size: 0.9em !important;
        line-height: 1.3 !important;
    }

    .comment-text {
        font-size: 0.8em !important;
        line-height: 1.3 !important;
    }

    .contributor-badge {
    }
}

/* Stili per l'header del POI */
.poi-header {
    margin-bottom: 15px;
}

.poi-header h3 {
    margin: 0;
    color: #4CAF50;
    font-size: 1.2em;
    font-weight: 600;
}

/* Stili per il badge del contributore */
.contributor-badge-container {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    width: 100%;
}

.contributor-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 20px;
    font-size: 0.85em;
    color: #666;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    float: none;
    margin: 0;
}

.contributor-badge:hover {
    background: #eeeeee;
}

.contributor-badge svg {
    color: #4CAF50;
}

.contributor-badge span strong {
    color: #4CAF50;
    font-weight: 600;
}

.contributor-badge .contributor-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    width: 220px;
    font-size: 0.9em;
    color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1;
}

.contributor-badge:hover .contributor-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(2px);
}

.mini-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 4px 8px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-add-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.mini-add-btn svg {
    color: white;
}

.photo-credit-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 0;
    background: #ffffff;
    border-radius: 999px;
    font-size: 0.75em;
    color: #111827;
    margin-left: auto;
    height: 26px;
    line-height: 1;
    transition: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
    pointer-events: auto;
    z-index: 3;
}

.photo-credit-badge * {
    cursor: pointer;
}

.photo-credit-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, max-width 0.2s ease;
    pointer-events: auto;
}

.photo-credit-name {
    font-weight: 600;
}

.photo-credit-badge.is-open .photo-credit-text {
    opacity: 1;
    max-width: 220px;
    pointer-events: auto;
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #cbd5e1;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7em;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-avatar-sm {
    width: 18px;
    height: 18px;
    font-size: 0.65em;
}

.image-overlay-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
}

.photo-credit-badge span {
    opacity: 0.9;
}

/* Stile per il pulsante Google Maps */
.google-maps-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #4285F4;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: background-color 0.2s;
    font-size: 0.9em;
    margin-top: 15px;
}

.google-maps-btn:hover {
    background: #3367D6;
}

.google-maps-btn svg {
    stroke: white;
}

.google-maps-btn .plus-badge {
    background: #FFC107;
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    margin-left: 8px;
    font-weight: bold;
}

/* Media queries per il pulsante Google Maps */
@media (max-width: 768px) {
    .google-maps-btn {
        margin-top: 12px;
        padding: 10px 14px;
    }
}

.poi-modal-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.add-to-route-btn {
    background-color: #4CAF50;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    flex: 1;
}

.add-to-route-btn:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.share-poi-btn {
    background-color: #2196F3;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.share-poi-btn:hover {
    background-color: #0b7dda;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}