:root {
  --bav-blue: #4C70BA; /* Blu Istituzionale Ministero degli Esteri / Farnesina */
  --bav-red: #CE2B37;  /* Rosso ufficiale della Bandiera Italiana */
  --bav-text: #222222;
  --bav-bg-light: #f8f9fa;
  --header-height-mobile: 60px; 
}

body {
    background-color: #ffffff;
    color: var(--bav-text);
    font-family: 'Segoe UI', Verdana, sans-serif;
    font-size: 1rem; 
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: none; 
}

::selection { background-color: var(--bav-blue); color: #ffffff; }
::-moz-selection { background-color: var(--bav-blue); color: #ffffff; }

::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: #f0f4f8; }
::-webkit-scrollbar-thumb {
    background-color: var(--bav-blue); 
    border-radius: 6px; 
    border: 3px solid #f0f4f8; 
}
::-webkit-scrollbar-thumb:hover { background-color: var(--bav-red); }

html {
    scrollbar-color: var(--bav-blue) #f0f4f8;
    scrollbar-width: thin;
}

.nav-svg-icon {
    width: 38px; height: 38px; padding: 8px;
    border-radius: 12px !important; 
    border: none; 
    background-color: rgba(59, 89, 152, 0.08); 
    fill: var(--bav-blue);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    flex-shrink: 0;
}

.nav-link:hover .nav-svg-icon,
.nav-link:focus .nav-svg-icon {
    background-color: rgba(214, 0, 0, 0.12); 
    fill: var(--bav-red); 
    transform: translateY(-3px); 
    box-shadow: 0 8px 15px rgba(214, 0, 0, 0.15); 
}

.circle-icon {
    background: #ffffff; padding: 2px;
    border-radius: 12px !important; 
    border: 1px solid var(--bav-blue); 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); 
    transition: all 0.2s ease;
}
.nav-link:hover .circle-icon {
    border-color: var(--bav-red);
    box-shadow: 0 3px 6px rgba(214, 0, 0, 0.2);
}
.rotondo-icon { background: #ffffff; padding: 0px; border-radius: 50% !important; }

.weather-widget-container {
    display: flex; align-items: center; justify-content: center;
    margin-left: 8px; margin-right: 8px;
    background-color: #f0f4f8; border: 1px solid #d1d9e6; border-radius: 12px;
    width: 36px; height: 36px; /* Dimensioni fisse per un bottone a icona */
    transition: all 0.2s ease;
}
.weather-widget-container:hover { border-color: var(--bav-blue); background-color: #e2e8f0; }
.weather-text { color: var(--bav-blue); font-weight: 700; font-size: 0.85rem; }
.weather-text i { color: #f39c12; margin-right: 4px; }

/* =========================================================
   SEARCHBOX STYLE & SUGGERIMENTI
   ========================================================= */
.searchbox {
  --target-size: 40px; 
  --box-height: var(--target-size);
  --border-radius: 50px; 
  height: var(--box-height); width: 100%; 
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.searchbox input[type='search'] {
  width: 100%; height: 100%;
  padding-left: 42px; padding-right: 15px;
  border: 1px solid transparent; 
  border-radius: var(--border-radius);
  background-color: rgba(59, 89, 152, 0.06); 
  color: var(--bav-text); 
  font-family: 'Poppins', sans-serif; 
  font-size: 0.95rem;
  -webkit-appearance: none; 
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.searchbox input[type='search']::placeholder { color: #8b98b5; font-weight: 400; }
.searchbox input[type='search']:hover { background-color: rgba(59, 89, 152, 0.10); }
.searchbox input[type='search']:focus {
  background-color: #ffffff;
  border-color: var(--bav-blue); outline: none;
  box-shadow: 0 4px 15px rgba(59, 89, 152, 0.12), 0 0 0 4px rgba(59, 89, 152, 0.08);
}

.searchbox svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  height: 18px; width: 18px;
  fill: #8b98b5; 
  z-index: 1; pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.searchbox:focus-within svg { fill: var(--bav-blue); transform: translateY(-50%) scale(1.15); }
.searchbox input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* NUOVO: STILI SUGGERIMENTI RICERCA SITEMAP */
.suggestions-box-global {
    position: absolute;
    top: 110%; /* Appena sotto la barra */
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 2000; 
    max-height: 300px;
    overflow-y: auto;
    display: none;
    text-align: left;
}

.suggestion-item-global {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--bav-text);
    border-bottom: 1px solid #f1f1f1;
    transition: background 0.2s, color 0.2s;
}

.suggestion-item-global:last-child { border-bottom: none; }
.suggestion-item-global:hover {
    background-color: #f8f9fa;
    color: var(--bav-blue);
    font-weight: 600;
}


@media (min-width: 992px) {
    .desktop-search .searchbox {
        width: 220px; 
        margin-left: 15px;
        transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
    }
    .desktop-search .searchbox:focus-within { width: 300px; }
}

a { color: var(--bav-blue); text-decoration: none; font-weight: 600; transition: color 0.2s ease; }
a:hover { color: var(--bav-red); text-decoration: underline; }
hr { border-top: 1px solid #ddd; opacity: 1; margin: 1rem 0; }

.navbar-custom {
    backdrop-filter: none; -webkit-backdrop-filter: none; 
    background-color: #ffffff !important; /* Colore solido senza sfocatura */  
    border-bottom: 1px solid rgba(59, 89, 152, 0.15); 
    padding: 0; min-height: 65px; 
    z-index: 1050; position: sticky; top: 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05); 
    transition: all 0.3s ease;
}

.nav-link {
    display: flex; flex-direction: row; align-items: center; justify-content: center;
    margin: 0 2px; height: 100%; padding: 8px 4px; 
    cursor: pointer; border: none !important;
    color: var(--bav-text) !important;
    white-space: normal; text-align: center;
}
.nav-link:hover { background-color: #f7f7f7; border-radius: 5px; }

.nav-text-wrapper {
    display: inline-block; margin-left: 6px; margin-top: 0;
    font-weight: 600; font-size: 1rem; color: var(--bav-blue); line-height: 1.1; 
}
.nav-link:hover .nav-text-wrapper { color: var(--bav-red); }

.dropdown-toggle::after { display: none !important; }
.nav-icon-img { object-fit: cover; width: 34px; height: 34px; position: relative; z-index: 1; }

.dropdown-menu {
    background-color: #ffffff; border: none; border-radius: 16px; 
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0,0,0,0.05); 
    padding: 10px 0; margin-top: 15px !important; font-size: 0.95rem;
    display: none !important; animation: fadeInDropdown 0.2s ease forwards; 
}

.dropdown-menu::before {
    content: ""; position: absolute; top: -6px; left: 20px;
    width: 12px; height: 12px; background: #fff; transform: rotate(45deg);
    border-top: 1px solid rgba(0,0,0,0.05); border-left: 1px solid rgba(0,0,0,0.05);
}

@keyframes fadeInDropdown {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item { padding: 8px 20px; color: #444 !important; font-weight: 500; transition: all 0.2s ease; }
.dropdown-item:hover { 
    background-color: transparent !important; color: var(--bav-red) !important;
    transform: translateX(5px); 
}


/* Barra visibile di default (sarà PHP a decidere se inserirla nella pagina) */
.transport-alert-bar {
    background-color: var(--bav-red); color: #fff;
    font-size: 0.85rem; font-weight: bold; text-align: center;
    padding: 6px 0; display: block; width: 100%; z-index: 1040;
}

/* NOVITÀ: Flexbox per forzare tutto su una sola riga su mobile */
.transport-alert-inner {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 0 10px; max-width: 100%; box-sizing: border-box;
}

/* NOVITÀ: Taglia il testo troppo lungo con i puntini (...) */
#transportAlertText {
    white-space: nowrap;          
    overflow: hidden;             
    text-overflow: ellipsis;      
    flex: 1; text-align: left; margin: 0 10px;
}

/* DESKTOP */
@media (min-width: 992px) {
    .navbar-brand img { width: 50px; height: 50px; border-radius: 50% !important; border: 2px solid var(--bav-blue); }
    .desktop-search { display: block; margin-left: 10px; }
    .mobile-header-layout { display: none; }
    .nav-item.dropdown:hover .dropdown-menu { display: block !important; }
    
    #mainNavList { width: auto !important; flex-grow: 1; justify-content: space-between; }
    #mainNavList .nav-item { flex-grow: 1; flex-basis: 0; display: flex; justify-content: center; position: relative; }
    #mainNavList .nav-link { width: 100%; justify-content: center; margin: 0; height: 100%; }
    
    .dropdown-menu { top: 100% !important; margin-top: 0px !important; left: 0; }
    .nav-item.dropdown:hover .dropdown-columns { display: grid !important; grid-template-columns: 1fr 1fr; min-width: 400px; gap: 0px; }
    #mainNavList .nav-item:last-child .dropdown-menu { right: 0; left: auto; }
    #mobile-submenu-overlay { display: none !important; }
}

/* MOBILE */
@media (max-width: 991px) {
    .navbar-brand img { width: 36px; height: 36px; border-radius: 50% !important; }
    .mobile-header-layout { 
        display: flex; align-items: center; justify-content: space-between;
        height: var(--header-height-mobile); background-color: #ffffff; padding: 0 10px;
        position: relative; z-index: 1060; border-bottom: 2px solid var(--bav-blue); gap: 8px; 
    }
    
    .mobile-header-layout .navbar-brand { flex: 0 0 auto; margin-right: 0; }
    .weather-widget-container { margin: 0; padding: 0 6px; flex: 0 0 auto; font-size: 0.8rem; }
    .mobile-search-wrapper { flex: 1 1 auto; min-width: 80px; max-width: 100%; }

    .navbar-toggler { 
        flex: 0 0 auto; border: 2px solid var(--bav-blue); background-color: var(--bav-blue); 
        padding: 5px 8px; border-radius: 6px; color: white; display: flex;
        align-items: center; justify-content: center; gap: 4px; 
        box-shadow: 0 2px 6px rgba(59, 89, 152, 0.3); transition: all 0.3s ease;
    }
    
    .menu-testo {
        font-size: 0.75rem; font-weight: 700; letter-spacing: 0; color: white;
        text-transform: uppercase; width: 48px; text-align: center; display: inline-block;
    }

    .navbar-toggler-icon { filter: invert(1) grayscale(100%) brightness(200%); width: 1.2em; height: 1.2em; }
    .navbar-toggler[aria-expanded="true"] { background-color: var(--bav-red); border-color: var(--bav-red); box-shadow: none; }

    .navbar-collapse {
        position: fixed; top: var(--header-height-mobile); left: 0; width: 100vw;
        height: calc(100vh - var(--header-height-mobile)); background-color: #f0f4f8; 
        overflow-y: auto; border-top: 1px solid #eee;
    }

    .navbar-nav { 
        margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; 
        width: 100%; padding: 0 15px 50px 15px; gap: 10px; 
    }
    
    .nav-item { width: 100%; padding: 0; display: block; }
    
    .nav-link {
        flex-direction: row; justify-content: flex-start; align-items: center;
        padding: 10px 10px; width: 100%; height: 100%; background: #fff; 
        border: 1px solid #d1d9e6; border-radius: 12px; box-shadow: 0 4px 8px rgba(0,0,0,0.04); 
        transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.1s ease;
    }
    
    .nav-link:active { transform: scale(0.96); box-shadow: 0 1px 2px rgba(0,0,0,0.05); background-color: #f4f7fa; border-color: var(--bav-blue); }
    .nav-svg-icon { width: 32px; height: 32px; margin-right: 8px; margin-bottom: 0; flex-shrink: 0; }
    .nav-text-wrapper { font-size: 0.9rem; font-weight: 600; color: var(--bav-text); white-space: normal; text-align: left; line-height: 1.1; }

    .install-app-container { width: 100%; display: flex; justify-content: center; padding: 25px 15px 50px 15px; clear: both; }

    .btn-install-app {
        background: linear-gradient(135deg, var(--bav-blue) 0%, #4a6cb4 100%); 
        color: #ffffff; border: none; border-radius: 16px; padding: 12px 16px;
        box-shadow: 0 8px 20px rgba(59, 89, 152, 0.25); transition: transform 0.2s ease, box-shadow 0.2s ease;
        display: flex; align-items: center; justify-content: flex-start; gap: 15px; width: 90%; max-width: 350px;
    }

    .app-btn-icon {
        background: rgba(255, 255, 255, 0.2); border-radius: 50%; width: 42px; height: 42px;
        display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; animation: pulseIcon 2s infinite; 
    }

    .app-btn-text { display: flex; flex-direction: column; text-align: left; }
    .app-btn-title { font-size: 1.05rem; font-weight: 700; line-height: 1.2; letter-spacing: 0.2px; }
    .app-btn-subtitle { font-size: 0.75rem; font-weight: 400; opacity: 0.85; margin-top: 2px; }
    .btn-install-app:active { transform: scale(0.96); background: var(--bav-red); box-shadow: 0 4px 10px rgba(214, 0, 0, 0.3); }

    @keyframes pulseIcon { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); } }

    #mobile-submenu-overlay {
        position: fixed; left: 0; top: var(--header-height-mobile) !important;
        width: 100vw; height: calc(100vh - var(--header-height-mobile)) !important;
        background-color: #f4f7fa; z-index: 2000; overflow-y: auto; transform: translateX(100%); 
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; padding-bottom: 50px;
    }
    #mobile-submenu-overlay.active { transform: translateX(0); }
    
    .overlay-header { background-color: #fff; border-bottom: 1px solid rgba(59, 89, 152, 0.1); padding: 10px 15px; display: flex; align-items: center; justify-content: space-between; }
    .overlay-title { font-weight: 800; font-size: 1.1rem; color: var(--bav-blue); }
    .back-btn { background: rgba(59, 89, 152, 0.1); border: none; color: var(--bav-blue); padding: 6px 12px; border-radius: 12px; font-size: 0.85rem; font-weight: 700; cursor: pointer; }
    .overlay-content { padding: 10px; }
    .overlay-content ul { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0; margin: 0; list-style: none; }
    .overlay-content li { border: none; }
    .overlay-content a {
        display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
        background-color: #fff; border: 1px solid rgba(59, 89, 152, 0.15); border-radius: 12px; padding: 4px 2px; 
        height: 100%; color: var(--bav-text) !important; box-shadow: 0 2px 4px rgba(0,0,0,0.02); transition: transform 0.1s ease;
    }
    .overlay-content a:active { transform: scale(0.95); background-color: #f0f4f8; }
    .submenu-icon { font-size: 1.1rem; margin-bottom: 2px; }
    .submenu-text { font-size: 0.85rem; font-weight: 600; line-height: 1.1; }
}