/* ==========================================================================
   Sardinia Interactive Map - Base Container
   ========================================================================== */
.sardinia-map-container { 
    position: relative; 
    width: 100vw; 
    height: 100vh; 
    max-width: none !important; 
    margin-left: calc(50% - 50vw); 
    background: transparent; 
    z-index: 1; 
    overflow: hidden; 
}

#sm-map-canvas { 
    width: 100%; 
    height: 100%; 
    background: transparent; 
}

.leaflet-control-layers {
    display: none !important;
}

/* Nasconde elementi testuali del routing in caso di sovrascritture CSS di terze parti */
.leaflet-routing-container { display: none !important; }

/* ==========================================================================
   Offcanvas Menu - CONFIGURAZIONE FIXED SINISTRO (Filtri & PWA)
   ========================================================================== */
#sm-offcanvas-container {
    position: fixed; 
    top: 10px; 
    bottom: 30px; 
    left: -390px; 
    width: 390px; 
    display: flex;
    flex-direction: column;
    background: rgba(25, 25, 25, 0.95);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
    border-radius: 0 8px 8px 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999; 
    padding: 20px 15px;
    color: #fff;
    font-family: sans-serif;
    box-sizing: border-box;
}

#sm-offcanvas-container.open {
    left: 0;
}

#sm-offcanvas-trigger {
    position: absolute;
    top: 0; 
    right: -44px; 
    width: 44px;
    height: 52px;
    background-color: #d63638; 
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 4px 0 10px rgba(0,0,0,0.3);
    transition: background-color 0.2s;
}

#sm-offcanvas-trigger:hover { background-color: #b32d2e; }
#sm-offcanvas-trigger svg { width: 24px; height: 24px; fill: #ffffff; transition: transform 0.3s; }
#sm-offcanvas-container.open #sm-offcanvas-trigger svg { transform: rotate(90deg); }

/* Bottone Installazione PWA Nativo */
.sm-install-pwa-btn {
    display: none; 
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 18px;
    background: linear-gradient(135deg, #00b09b, #96c93d);
    color: #ffffff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    font-family: sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 176, 155, 0.25);
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.sm-install-pwa-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 176, 155, 0.4);
}

.sm-install-pwa-btn svg { width: 18px; height: 18px; fill: currentColor; }

.sm-offcanvas-header { 
    flex-shrink: 0; margin-bottom: 20px; font-size: 15px; font-weight: bold; 
    text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid rgba(255,255,255,0.2); padding-bottom: 10px; 
}

.sm-filter-list { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding-right: 5px; }
.sm-filter-item { display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 10px 14px; border-radius: 6px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.05); transition: all 0.2s; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.sm-filter-item:hover { background: rgba(255,255,255,0.1); }
.sm-filter-item.active { background: rgba(255,255,255,0.9); color: #000; }
.sm-filter-item input[type="checkbox"] { display: none; }
.sm-filter-color-indicator { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,0.2); flex-shrink: 0; }

/* ==========================================================================
   Offcanvas Menu - CONFIGURAZIONE FIXED DESTRO (Ad-Manager Console)
   ========================================================================== */
#sm-offcanvas-right {
    position: fixed; 
    top: 90px; 
    bottom: 30px;
    right: -390px;
    width: 390px;
    display: flex;
    flex-direction: column;
    background: rgba(25, 25, 25, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.5);
    border-radius: 8px 0 0 8px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99999; 
    padding: 20px 15px;
    color: #fff;
    font-family: sans-serif;
    overflow-y: auto;
    box-sizing: border-box;
}

#sm-offcanvas-right.open { right: 0; }

#sm-offcanvas-trigger-right {
    position: absolute; top: 0; left: -44px; width: 44px; height: 52px; background-color: #2271b1;
    border-radius: 8px 0 0 8px; cursor: pointer; display: flex; justify-content: center; align-items: center;
    box-shadow: -4px 0 10px rgba(0,0,0,0.3); transition: background-color 0.2s;
}

#sm-offcanvas-trigger-right:hover { background-color: #135e96; }
#sm-offcanvas-trigger-right svg { width: 24px; height: 24px; fill: #ffffff; transition: transform 0.3s; }
#sm-offcanvas-right.open #sm-offcanvas-trigger-right svg { transform: rotate(-90deg); }

.sm-auth-form { display: flex; flex-direction: column; gap: 15px; margin-top: 10px; }
.sm-auth-form input, .sm-auth-form select { width: 100%; padding: 10px; border-radius: 4px; border: 1px solid #444; background: #222; color: #fff; box-sizing: border-box; }
.sm-btn { padding: 12px; border: none; border-radius: 4px; background: #2271b1; color: #fff; font-weight: bold; cursor: pointer; text-transform: uppercase; font-size: 13px; transition: background 0.2s; display:flex; justify-content:center; align-items:center; gap:8px;}
.sm-btn:hover { background: #135e96; }
.sm-btn-success { background: #00a32a; } .sm-btn-success:hover { background: #008a20; }
.sm-switch-form { text-align: center; font-size: 12px; margin-top: 15px; color: #aaa; cursor: pointer; text-decoration: underline; }
.sm-alert { padding: 10px; border-radius: 4px; font-size: 13px; margin-bottom: 10px; display: none; box-sizing: border-box;}
.sm-alert.error { background: rgba(214, 54, 56, 0.2); border: 1px solid #d63638; color: #ff8a8a; display: block; }
.sm-alert.success { background: rgba(0, 163, 42, 0.2); border: 1px solid #00a32a; color: #8aff9e; display: block; }
.sm-dash-box { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 15px; margin-bottom: 15px; }
.sm-dash-box label { display: block; font-size: 12px; margin-bottom: 5px; color: #aaa; font-weight: bold;}
.sm-preview-img { width: 100%; height: auto; max-height: 100px; object-fit: cover; border-radius: 4px; margin-bottom: 10px; border: 1px dashed #555; }
.sm-status-badge { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; text-transform: uppercase; }
.sm-status-attivo { background: #00a32a; color: #fff; } .sm-status-in_attesa { background: #f0b849; color: #000; }

/* ==========================================================================
   CONFIGURAZIONI RESPONSIVE MOBILE
   ========================================================================== */
@media (max-width: 768px) {
    #sm-offcanvas-container { width: 220px; left: -220px; top: 10px; bottom: 20px; padding: 12px 8px; }
    #sm-offcanvas-container.open { left: 0; }
    #sm-offcanvas-trigger { top: 0; right: -34px; width: 34px; height: 42px; }
    #sm-offcanvas-trigger svg { width: 18px; height: 18px; }
    .sm-install-pwa-btn { padding: 9px 10px; font-size: 11px; margin-bottom: 12px; gap: 6px; }
    .sm-install-pwa-btn svg { width: 15px; height: 15px; }
    .sm-offcanvas-header { margin-bottom: 12px; font-size: 11px; padding-bottom: 6px; }
    .sm-filter-item { padding: 6px 10px; gap: 8px; font-size: 11px; border-radius: 5px; }

    #sm-offcanvas-right { width: 280px; right: -280px; top: 90px; bottom: 20px; padding: 12px 8px; }
    #sm-offcanvas-right.open { right: 0; }
    #sm-offcanvas-trigger-right { top: 0; left: -34px; width: 34px; height: 42px; }
    #sm-offcanvas-trigger-right svg { width: 18px; height: 18px; }
    
    .sm-gps-btn { bottom: 20px !important; right: 20px !important; }
}

/* ==========================================================================
   Mappa, Pin SVG & Modale Popup
   ========================================================================== */
.sm-leaflet-icon { background: none; border: none; }
.sm-pin-svg-wrapper { width: 40px; height: 48px; position: relative; transform: translate(-50%, -100%); filter: drop-shadow(0px 4px 4px rgba(0,0,0,0.5)); transition: transform 0.2s, filter 0.2s; }
.sm-pin-svg-wrapper:hover { transform: translate(-50%, -105%) scale(1.05); filter: drop-shadow(0px 8px 8px rgba(0,0,0,0.6)); z-index: 1000 !important; }
.sm-pin-svg-wrapper svg { width: 100%; height: 100%; }

.sm-zoom-warning { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.85); color: #fff; padding: 15px 25px; border-radius: 8px; font-family: sans-serif; font-size: 18px; pointer-events: none; opacity: 0; transition: opacity 0.3s; z-index: 10000; text-align: center; }
.sm-zoom-warning.show { opacity: 1; }

.sm-popup-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); z-index: 999999; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.sm-popup-overlay.active { opacity: 1; visibility: visible; }
.sm-popup-content { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.3); opacity: 0; flex-shrink: 0; max-width: none !important; transition: opacity 0.3s ease; display: flex; flex-direction: column; width: 400px; }
.sm-popup-overlay.active .sm-popup-content { opacity: 1; }
.sm-popup-header { padding: 25px 20px 20px 20px; position: relative; text-align: center; border-bottom: 1px solid #eee; background: #ffffff; flex-shrink: 0; }
.sm-popup-title { margin: 0; font-size: 22px; color: #2c3338; font-family: sans-serif; font-weight: 700; line-height: 1.3;}
.sm-popup-close { position: absolute; top: 10px; right: 10px; font-size: 24px; cursor: pointer; color: #a7aaad; background: #f0f0f1; border-radius: 50%; width: 30px; height: 30px; text-align: center; line-height: 30px; z-index: 10; transition: color 0.2s, background 0.2s; }
.sm-popup-close:hover { color: #fff; background: #d63638; }

/* ==========================================================================
   Galleria Fotografica del Pin 
   ========================================================================== */
.sm-gallery-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
    background: #111;
    overflow: hidden;
    flex-shrink: 0;
}

.sm-gallery-track {
    position: relative;
    width: 100%;
    height: 100%;
}

.sm-gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

.sm-gallery-slide.active {
    opacity: 1;
    z-index: 2;
}

.sm-gallery-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sm-gallery-nav {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    box-sizing: border-box;
    z-index: 5;
    pointer-events: none;
}

.sm-gal-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
    user-select: none;
    backdrop-filter: blur(2px);
}

.sm-gal-btn:hover { background: rgba(0, 0, 0, 0.8); }

.sm-gallery-dots {
    position: absolute;
    bottom: 12px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 8px;
    z-index: 5;
}

.sm-gal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background 0.3s, transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.sm-gal-dot.active {
    background: #fff;
    transform: scale(1.3);
}

/* ==========================================================================
   Banner Pubblicitario ETS
   ========================================================================== */
.sm-banner-container { width: 100%; background: #f0f0f1; overflow: hidden; position: relative; height: 140px; flex-shrink: 0; }
.sm-banner-slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.8s ease-in-out; display: flex; justify-content: center; align-items: center; }
.sm-banner-slide.active { opacity: 1; z-index: 2; }
.sm-banner-slide a { display: block; width: 100%; height: 100%; }
.sm-banner-slide img { width: 100%; height: 100%; object-fit: cover; }
.sm-banner-placeholder { width: 100%; height: 100%; background: repeating-linear-gradient(45deg, #e5e5e5, #e5e5e5 10px, #f0f0f1 10px, #f0f0f1 20px); display: flex; justify-content: center; align-items: center; flex-direction: column; text-decoration: none; color: #50575e; font-family: sans-serif; font-size: 14px; transition: background 0.3s; text-align: center; padding: 0 20px; box-sizing: border-box; }
.sm-banner-placeholder:hover { background: #dcdcde; color: #2c3338; }
.sm-banner-placeholder span { font-weight: bold; font-size: 16px; margin-bottom: 5px; color: #d63638;}

/* ==========================================================================
   PWA iOS Toast Instruction
   ========================================================================== */
.sm-ios-pwa-toast {
    position: fixed; bottom: -120px; left: 50%; transform: translateX(-50%); width: calc(100vw - 32px); max-width: 400px;
    background: rgba(28, 28, 30, 0.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7);
    border-radius: 12px; padding: 16px 18px; color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px; line-height: 1.45; z-index: 9999999;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; align-items: center; gap: 14px; box-sizing: border-box; cursor: pointer;
}

.sm-ios-pwa-toast.show { bottom: 25px; }
.sm-ios-toast-icon { font-size: 26px; flex-shrink: 0; line-height: 1; }
.sm-ios-toast-content { flex-grow: 1; }
.sm-ios-toast-content b { color: #0a84ff; font-weight: 600; }

/* ==========================================================================
   Interfaccia GPS: Bottone e Marker Animato
   ========================================================================== */
.sm-gps-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    transition: background 0.2s, transform 0.2s;
}

.sm-gps-btn:hover { background: #f0f0f1; transform: translateY(-2px); }
.sm-gps-btn svg { width: 24px; height: 24px; fill: #2c3338; }

.sm-user-loc-icon { position: relative; }
.sm-loc-dot {
    width: 14px;
    height: 14px;
    background-color: #0a84ff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    z-index: 2;
}

.sm-loc-pulse {
    width: 40px;
    height: 40px;
    background-color: rgba(10, 132, 255, 0.6);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    animation: smPulseAnim 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes smPulseAnim {
    0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* ==========================================================================
   Modale Errore GPS / Modale Generico
   ========================================================================== */
.sm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sm-modal-overlay.active { opacity: 1; visibility: visible; }

.sm-modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 420px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    font-family: sans-serif;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.sm-modal-overlay.active .sm-modal-content { transform: translateY(0); }

.sm-modal-header {
    background: #d63638;
    color: #ffffff;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sm-modal-body {
    padding: 24px 20px;
    font-size: 14px;
    color: #3c434a;
    line-height: 1.6;
}

.sm-modal-footer {
    padding: 16px 20px;
    background: #f6f7f7;
    text-align: right;
    border-top: 1px solid #dcdcde;
}

.sm-modal-footer .sm-btn {
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 13px;
    margin: 0;
}

/* ==========================================================================
   Controlli Navigatore (Turn-by-Turn UI)
   ========================================================================== */
.sm-nav-controls {
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    padding: 15px;
    flex-shrink: 0;
}

.sm-start-nav-wrapper {
    width: 100%;
}

.sm-start-nav-btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    border-radius: 8px;
    background: #0073aa;
}

.sm-start-nav-btn svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

.sm-stop-nav-btn {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #d63638;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 30px;
    font-family: sans-serif;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(214, 54, 56, 0.4);
    cursor: pointer;
    z-index: 999999;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.sm-stop-nav-btn:hover {
    background: #b32d2e;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 8px 25px rgba(214, 54, 56, 0.5);
}

.sm-stop-nav-btn svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}