/* 📸 INSTAGRAM-INSPIRED FULL SCREEN NO-SCROLL STYLE */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden; /* Impedisce tassativamente lo scorrimento della pagina */
    background-color: #000000; /* Nero assoluto di sfondo stile Instagram Dark */
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    color: #f5f5f5; 
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Struttura dell'applicazione ancorata alla viewport */
.container { 
    width: 100%;
    max-width: 935px; /* Dimensione tipica del feed desktop di Instagram */
    margin: 0 auto;
    height: 100vh; 
    display: flex;
    flex-direction: column;
    padding: 16px;
    position: relative;
    background-color: #000000;
}

/* Intestazione minimale per dare priorità visiva alla mappa */
.header-section {
    text-align: left;
    padding-right: 80px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

h1 { 
    font-size: 1.5rem; 
    font-weight: 800; 
    letter-spacing: -0.03em;
    /* Iconico gradiente Instagram Sunset */
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 3px;
}
p { font-size: 0.92rem; color: #a8a8a8; max-width: 95%; line-height: 1.4; }

/* Selettore lingua discreto in stile menu IG */
.lang-switcher {
    position: absolute; top: 16px; right: 16px; cursor: pointer; 
    background: #121212;
    padding: 6px 14px; border-radius: 8px;
    display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
    color: #f5f5f5; border: 1px solid #262626; 
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent; z-index: 1001;
}
.lang-switcher:hover { background-color: #262626; }
.lang-icon { width: 14px; height: 10px; object-fit: cover; border-radius: 1px; }

/* 🕹️ PULSANTI DI AZIONE INTERFACCIA: Testo molto grande disposto su due righe */
.btn-group { 
    display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; 
    flex-wrap: nowrap; flex-shrink: 0;
}

button { 
    flex: 1; 
    padding: 10px 8px; 
    font-size: 18px; /* SUPER INGRANDITO per schermi PC/Tablet */
    font-weight: 700; 
    color: #ffffff; 
    border: none; 
    border-radius: 10px; 
    cursor: pointer;
    line-height: 1.2; 
    text-align: center;
    display: block;
    transition: transform 0.1s ease, opacity 0.2s ease; 
    outline: none; 
    -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.98); }

#refresh-btn { background-color: #363636; }
#refresh-btn:hover { background-color: #454545; }

#share-btn { 
    background: linear-gradient(45deg, #f09433 0%, #dc2743 50%, #bc1888 100%); 
}
#share-btn:hover { opacity: 0.9; }

#remove-btn { background-color: #121212; color: #ed4956; border: 1px solid #262626; display: none; font-size: 18px; }
#remove-btn:hover { background-color: #262626; }

#status { 
    margin-bottom: 10px; font-weight: 600; font-size: 0.95rem; min-height: 18px; 
    color: #0095f6; 
    text-align: left; flex-shrink: 0;
}

/* 🎯 LA MAPPA CENTRALE DELL'INTERFACCIA */
#map { 
    flex: 1; 
    width: 100%; 
    border-radius: 12px; 
    background-color: #121212; 
    border: 1px solid #262626;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.leaflet-popup-content-wrapper { background: #262626 !important; color: #f5f5f5 !important; border-radius: 12px !important; font-size: 14px; }
.leaflet-popup-tip { background: #262626 !important; }

.popup-foto { width: 100%; max-width: 180px; height: auto; margin-top: 8px; border-radius: 4px; display: block; object-fit: cover; cursor: pointer; }
.popup-info-box { cursor: pointer; padding: 4px 0; font-weight: 700; color: #0095f6; }

/* 🌟 OVERLAY SCHERMATE DI CONDIVISIONE (LIGHTBOX MODALE) */
.lightbox-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
    padding: 16px; opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
}
.lightbox-overlay.active { opacity: 1; pointer-events: auto; }

.lightbox-content {
    background: #262626; width: 100%; max-width: 400px; height: 100%;
    padding: 24px; border-radius: 12px; text-align: center;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    transform: scale(0.95); transition: transform 0.2s ease;
    border: 1px solid #363636;
}
.lightbox-overlay.active .lightbox-content { transform: scale(1); }

.lightbox-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; color: #ffffff; }
.lightbox-text { font-size: 0.92rem; color: #a8a8a8; margin-bottom: 16px; text-align: left; line-height: 1.4; }

.photo-select-container { display: none; margin-bottom: 16px; text-align: left; background: #121212; padding: 14px; border-radius: 8px; border: 1px dashed #454545; }
.photo-label { font-size: 0.88rem; font-weight: 600; color: #f5f5f5; display: block; margin-bottom: 6px; }

#msg-input { 
    background-color: #121212 !important; color: #ffffff !important;
    border: 1px solid #363636 !important; border-radius: 24px !important; 
    padding: 10px 16px !important; font-size: 14px !important; transition: border-color 0.2s !important;
}
#msg-input:focus { border-color: #a8a8a8 !important; }

.lightbox-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lightbox-btn { flex: 1; min-width: 100px; padding: 12px; font-size: 14px; font-weight: 700; border-radius: 8px; }

#modal-cancel-btn { background-color: transparent; color: #ffffff; border: 1px solid #454545; }
#modal-cancel-btn:hover { background-color: #363636; }
#modal-confirm-btn { background-color: #0095f6; } 
#modal-confirm-btn:hover { background-color: #1877f2; }

/* 🖼️ CARD ANTEPRIMA PROFILO (RIPRISTINO DIMENSIONI ORIGINALI SENZA TAGLI) */
.image-lightbox-content { 
    position: relative; 
    width: 100%; 
    max-width: 480px; /* Ripristinata larghezza ottimale originale */
    display: flex; 
    flex-direction: column;
    transform: scale(0.95); 
    transition: transform 0.2s ease; 
}
.lightbox-overlay.active .image-lightbox-content { transform: scale(1); }

.image-lightbox-content.no-photo { max-width: 380px !important; }

.image-wrapper-box {
    position: relative; 
    width: 100%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    background-color: #1c1c1c; /* Sfondo scuro neutro per le bande laterali delle foto non quadrate */
    border-radius: 12px 12px 0 0; 
    overflow: hidden;
    border: 1px solid #262626; 
    border-bottom: none;
}

/* 🌟 CORREZIONE: Impostato 'contain' per non tagliare l'immagine e ripristinato l'aspetto dinamico */
.image-lightbox-preview { 
    width: 100%; 
    height: auto;
    max-height: 55vh; /* Altezza massima bilanciata per la viewport */
    object-fit: contain; /* Mantiene le proporzioni originali senza tagliare nulla */
    display: block; 
}

/* Sezione commento/didascalia sotto al post */
.image-lightbox-caption { 
    width: 100%; 
    background: #121212; 
    padding: 16px; 
    text-align: left; 
    color: #fff; 
    border-radius: 0 0 12px 12px; 
    border: 1px solid #262626; 
    border-top: none;
}
.caption-title { font-size: 1rem; font-weight: 700; color: #ffffff; margin-bottom: 6px; }
.caption-text { font-size: 0.95rem; color: #f5f5f5; line-height: 1.4; word-break: break-word; background: #1c1c1c; padding: 10px; border-radius: 6px; margin-top: 4px; }

/* Pulsante X di chiusura integrato su Desktop */
.image-lightbox-close { 
    position: absolute; top: 12px; right: 12px; background: rgba(0, 0, 0, 0.6); color: #ffffff; 
    border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; width: 32px; height: 32px; 
    font-size: 18px; font-weight: bold; line-height: 28px; text-align: center; cursor: pointer; backdrop-filter: blur(4px); z-index: 1004;
}

.image-lightbox-content.no-photo .image-lightbox-caption { border-radius: 12px; border: 1px solid #262626; }
.image-lightbox-content.no-photo .image-wrapper-box { display: none !important; }

/* 📱 LOGICA SMARTPHONE FULL-SCREEN COMPATTA */
@media (max-width: 580px) {
    body { padding: 0; }
    .container { padding: 12px; border-radius: 0; border: none; }
    
    h1 { font-size: 1.3rem; }
    p { font-size: 0.85rem; }
    
    .btn-group { gap: 6px; }
    button { 
        padding: 10px 4px; 
        font-size: 16px; /* Ingrandito da mobile per un'interazione immediata */
        border-radius: 8px; 
    }
    
    #map { border-radius: 12px; }
    
    .image-lightbox-content { max-width: 100%; }
    .image-lightbox-caption { order: 1; border-radius: 12px 12px 0 0; border-bottom: 1px solid #262626; }
    .image-wrapper-box      { order: 2; border-radius: 0; }
    .image-lightbox-close   { order: 3; }
    
    .image-lightbox-preview { max-height: 45vh; }
    
    /* BARRA ERGONOMICA DI CHIUSURA MOBILE (Stile Pulsante IG Blu Azzurro) */
    .image-lightbox-close { 
        position: static !important; width: 100%; height: 46px; padding: 0;               
        background-color: #0095f6; color: #ffffff; border: none;
        font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center;
        margin: 8px 0 0 0; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,149,246,0.2);
    }
    .image-lightbox-close::after { content: "Torna alla Mappa"; color: #ffffff; display: block; }
}
/* 📢 STILE LIGHTBOX BANNER PUBBLICITARIO */
.adv-lightbox-content {
    background-color: #121212;
    border: 1px solid #262626;
    border-radius: 12px;
    max-width: 340px;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    animation: advFadeIn 0.3s ease-out;
}

@keyframes advFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.adv-wrapper-box {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    padding: 10px;
}

.adv-image-preview {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.adv-lightbox-caption {
    padding: 12px;
    background-color: #121212;
    text-align: center;
    border-top: 1px solid #262626;
}

.adv-lightbox-caption p {
    font-size: 0.75rem;
    color: #a8a8a8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.adv-lightbox-close {
    position: absolute;
    top: 5px;
    right: 12px;
    color: #f5f5f5;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
}

.adv-lightbox-close:hover {
    color: #ff3b30;
}

/* Ottimizzazione Mobile */
@media (max-width: 580px) {
    .adv-lightbox-content {
        max-width: 90%;
    }
}