:root {
    /* Icone e label: nere; la voce attiva si distingue con ombra leggera sull’icona (vedi sotto). */
    --nav-inactive: #000000;
    --nav-active: #000000;
    --border-color: #dbdbdb;
    --bg-blur: rgba(255, 255, 255, 0.0);
    --accent-color: var(--meedico-brand-blue, #0066cc);
    --logout-color: #ef4444;
}

body {
    padding-top: 60px;
    margin: 0;
    font-family: 'Inter', sans-serif;
}

.nav-mobile-only { display: flex; }
.nav-desktop-only { display: none; }

/* Evita conflitti con i temi (es. html[data-theme="glass-light"]) che ridefiniscono --nav-inactive ecc.
   Le variabili usate dalla navbar vengono “ancorate” al componente. */
.top-bar,
.icon-nav {
    --nav-inactive: #000000;
    --nav-active: #000000;
    --border-color: #dbdbdb;
    --bg-blur: rgba(255, 255, 255, 0.0);
    --accent-color: var(--meedico-brand-blue, #0066cc);
    --logout-color: #ef4444;
}

/* --- TOP BAR (LOGO) --- */
.top-bar {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 60px;
    background: rgb(0 29 255 / 11%);
    backdrop-filter: blur(20px);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 12px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transform: translateY(0);
    transition: transform 0.3s ease-in-out;
    will-change: transform;
    /* global.css imposta pointer-events:none sulla top-bar (solo logo cliccabile): ripristina tap su avatar */
    pointer-events: auto;
}

.top-bar .logo {
    grid-column: 2;
    justify-self: center;
}

.top-bar__side {
    display: flex;
    align-items: center;
    min-width: 0;
}

.top-bar__side--left,
.top-bar__spacer--left {
  grid-column: 1;
  justify-self: start;
}

.top-bar__side--right,
.top-bar__spacer--right {
  grid-column: 3;
  justify-self: end;
}

.top-bar__side--right {
  justify-self: end;
}

.top-bar-action {
    position: relative;
}

.top-bar-action__btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--accent-color);
    font-size: 1.35rem;
    cursor: pointer;
    padding: 0;
}

.top-bar-notifs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--nav-inactive, #000);
  font-size: 1.28rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}

.top-bar-notifs-btn .nav-ico-wrap {
  width: 1.35em;
  height: 1.35em;
}

.top-bar-notifs-btn .nav-badge-dot {
  top: -1px;
  right: -2px;
}

/* Non usare .hidden: su alcune pagine (es. profilo.css) .hidden = display:none e spezza la slide */
.top-bar.is-scroll-away {
    transform: translateY(-100%);
}

.top-bar .logo { 
    pointer-events: auto; 
    font-size: 1.5rem; 
    font-weight: 700; 
    color: var(--meedico-brand-blue, var(--accent-color)); 
}
.top-bar .logo a { 
    text-decoration: none; 
    color: inherit;
    text-shadow: none;
}

/* Wordmark: blu (m…dico) + giallo (ee), stessi token della mappa */
.meedico-wordmark {
  color: var(--meedico-brand-blue, #0066cc);
  text-decoration: none;
}
.meedico-wordmark__ee {
  color: var(--meedico-brand-yellow, #ffcc00);
  text-shadow: 0 0 9px var(--meedico-brand-blue-glow, rgba(13, 0, 255, 0.75));
}

/* --- ICON NAV --- */
/* Desktop: wrapper trasparente. Mobile (@media): shell fixed che morfizza glass+nav. */
.nav-dock {
    display: contents;
}

.icon-nav { 
    position: fixed; 
    z-index: 1001; 
    background: var(--bg-blur);
    backdrop-filter: blur(20px); 
    width: 100%; 
    transition: transform 0.3s ease-in-out;
}

/* Layer vetro colorato dietro la navbar (solo mobile) */
.nav-glass-backdrop {
    display: none;
}

.nav-container { 
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    width: 100%; 
    height: 100%; 
    margin: 0 auto; 
}

.icon-nav .nav-item {
    text-decoration: none;
    color: var(--nav-inactive);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    flex: 1;
    height: 100%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Clip del ripple senza tagliare i dropdown (overflow sul solo host) */
.nav-tap-ripple-host {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

/* Contenuto sopra il ripple */
.icon-nav .nav-item > .nav-link,
.icon-nav .nav-item > i,
.icon-nav .nav-item > .nav-text,
.icon-nav .nav-item > .nav-profile-avatar,
.icon-nav .nav-item > .nav-meeday-ico,
.icon-nav .nav-item > .nav-ico-wrap {
    position: relative;
    z-index: 1;
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Non scalare il contenuto al tap: riduce l’hit-area e il click va perso. */

/* Goccia sull’acqua: dal centro, più evidente per conferma tap */
.nav-tap-ripple {
    position: absolute;
    left: var(--nav-ripple-x, 50%);
    top: var(--nav-ripple-y, 50%);
    width: calc(var(--nav-ripple-r, 40px) * 2);
    height: calc(var(--nav-ripple-r, 40px) * 2);
    margin-left: calc(var(--nav-ripple-r, 40px) * -1);
    margin-top: calc(var(--nav-ripple-r, 40px) * -1);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    will-change: transform, opacity;
}

.nav-tap-ripple::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(15, 23, 42, 0.14) 0%,
        rgba(15, 23, 42, 0.07) 36%,
        rgba(15, 23, 42, 0.02) 62%,
        rgba(15, 23, 42, 0) 78%
    );
    animation: nav-tap-bloom 0.64s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.nav-tap-ripple::after {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    border: 1.5px solid rgba(15, 23, 42, 0.18);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.4),
        0 0 10px rgba(15, 23, 42, 0.06);
    animation: nav-tap-ring 0.68s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes nav-tap-bloom {
    0% { transform: scale(0.08); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

@keyframes nav-tap-ring {
    0% { transform: scale(0.15); opacity: 0.55; }
    45% { opacity: 0.22; }
    100% { transform: scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .nav-tap-ripple,
    .nav-tap-ripple::before,
    .nav-tap-ripple::after {
        animation: none !important;
        display: none !important;
    }
    .icon-nav .nav-item.is-nav-press > .nav-link,
    .icon-nav .nav-item.is-nav-press > i,
    .icon-nav .nav-item.is-nav-press > .nav-text,
    .icon-nav .nav-item.is-nav-press > .nav-profile-avatar,
    .icon-nav .nav-item.is-nav-press > .nav-meeday-ico {
        transform: none;
    }
}

.top-bar-notifs-btn.is-nav-press {
    /* niente scale: stesso problema del doppio tap */
}
.top-bar-notifs-btn .nav-tap-ripple-host {
    border-radius: 50%;
}

.nav-link { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 100%;
    height: 100%;
    justify-content: center;
}

.icon-nav .nav-item i {
    font-size: 1.2rem;
    margin-bottom: 4px;
    color: inherit;
}

.nav-text { 
    font-size: 10px; 
    font-weight: 600; 
    display: block; 
}

/* Pagina corrente: stesso nero; evidenza = ::after (mobile sopra, desktop sul bordo destro rail) */
.icon-nav .nav-item.active,
.icon-nav .nav-item.active .nav-link {
    color: var(--nav-active);
}

.nav-publish i { color: var(--accent-color); font-size: 1.4rem; }

/* meeday: anello + pallino centrati (pallino = misura ex-cerchio esterno) */
.nav-meeday-ico {
  position: relative;
  width: calc(1.45em + 2px);
  height: calc(1.45em + 2px);
  flex-shrink: 0;
  display: inline-block;
  color: inherit;
  vertical-align: middle;
}
.nav-meeday-ico__ring {
  position: absolute;
  inset: 0;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-sizing: border-box;
}
.nav-meeday-ico__dot {
  position: absolute;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  background: currentColor;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.dropdown-content-crea a .nav-meeday-ico {
  font-size: 1em;
}

/* --- DROPDOWNS COMUNI --- */
.dropdown-content-profile, 
.dropdown-content-turni,
.dropdown-content-cerca,
.dropdown-content-offerte,
.dropdown-content-crea,
.dropdown-content-notifs {
    display: none;
    position: absolute;
    background-color: #fff;
    min-width: 170px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
    z-index: 1002;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.dropdown-content-profile.show,
.dropdown-content-turni.show,
.dropdown-content-cerca.show,
.dropdown-content-offerte.show,
.dropdown-content-crea.show,
.dropdown-content-notifs.show { 
    display: block;
    animation: nav-dd-pop 0.34s cubic-bezier(0.32, 0.72, 0, 1) both;
}

/* Voci: leggero stagger in apertura */
.dropdown-content-profile.show > a,
.dropdown-content-turni.show > a,
.dropdown-content-cerca.show > a,
.dropdown-content-offerte.show > a,
.dropdown-content-crea.show > a {
    animation: nav-dd-item 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.dropdown-content-profile.show > a:nth-child(1),
.dropdown-content-turni.show > a:nth-child(1),
.dropdown-content-cerca.show > a:nth-child(1),
.dropdown-content-offerte.show > a:nth-child(1),
.dropdown-content-crea.show > a:nth-child(1) { animation-delay: 0.03s; }
.dropdown-content-profile.show > a:nth-child(2),
.dropdown-content-turni.show > a:nth-child(2),
.dropdown-content-cerca.show > a:nth-child(2),
.dropdown-content-offerte.show > a:nth-child(2),
.dropdown-content-crea.show > a:nth-child(2) { animation-delay: 0.055s; }
.dropdown-content-profile.show > a:nth-child(3),
.dropdown-content-turni.show > a:nth-child(3),
.dropdown-content-cerca.show > a:nth-child(3),
.dropdown-content-offerte.show > a:nth-child(3),
.dropdown-content-crea.show > a:nth-child(3) { animation-delay: 0.08s; }
.dropdown-content-profile.show > a:nth-child(4),
.dropdown-content-turni.show > a:nth-child(4),
.dropdown-content-cerca.show > a:nth-child(4),
.dropdown-content-offerte.show > a:nth-child(4),
.dropdown-content-crea.show > a:nth-child(4) { animation-delay: 0.105s; }
.dropdown-content-profile.show > a:nth-child(5),
.dropdown-content-turni.show > a:nth-child(5),
.dropdown-content-cerca.show > a:nth-child(5),
.dropdown-content-offerte.show > a:nth-child(5),
.dropdown-content-crea.show > a:nth-child(5) { animation-delay: 0.13s; }
.dropdown-content-profile.show > a:nth-child(n+6),
.dropdown-content-turni.show > a:nth-child(n+6),
.dropdown-content-cerca.show > a:nth-child(n+6),
.dropdown-content-offerte.show > a:nth-child(n+6),
.dropdown-content-crea.show > a:nth-child(n+6) { animation-delay: 0.15s; }

@keyframes nav-dd-pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes nav-dd-pop-center {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes nav-dd-pop-side {
    from {
        opacity: 0;
        transform: translateX(-10px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes nav-dd-item {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dropdown-content-profile.show,
    .dropdown-content-turni.show,
    .dropdown-content-cerca.show,
    .dropdown-content-offerte.show,
    .dropdown-content-crea.show,
    .dropdown-content-notifs.show,
    .dropdown-content-profile.show > a,
    .dropdown-content-turni.show > a,
    .dropdown-content-cerca.show > a,
    .dropdown-content-offerte.show > a,
    .dropdown-content-crea.show > a {
        animation: none !important;
    }
}

.dropdown-content-profile a,
.dropdown-content-turni a,
.dropdown-content-cerca a,
.dropdown-content-offerte a,
.dropdown-content-crea a,
.dropdown-content-notifs a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid #f5f5f5;
}

.dropdown-content-profile a:last-child,
.dropdown-content-turni a:last-child,
.dropdown-content-cerca a:last-child,
.dropdown-content-offerte a:last-child,
.dropdown-content-crea a:last-child,
.dropdown-content-notifs a:last-child { 
    border-bottom: none; 
}

.dropdown-content-profile a:hover,
.dropdown-content-turni a:hover,
.dropdown-content-cerca a:hover,
.dropdown-content-offerte a:hover,
.dropdown-content-crea a:hover,
.dropdown-content-notifs a:hover { 
    background-color: #f9f9f9; 
    color: var(--accent-color); 
}

/* Tendina notifiche (desktop): lista scrollabile, non esce dal viewport */
.dropdown-content-notifs {
    min-width: 320px;
    max-width: min(380px, calc(100vw - 24px));
    max-height: min(520px, calc(100vh - 100px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Notifiche / messaggi: pallino ancorato all'icona (non alla riga intera) */
.nav-ico-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.nav-badge-dot {
    position: absolute;
    top: -2px;
    right: -3px;
    left: auto;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #ef4444;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 6px 14px rgba(0,0,0,0.12);
    z-index: 2;
    pointer-events: none;
}

.nav-profile-ico-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* PEC nudge: mobile = posizione precedente (avatar); desktop = più in alto/sinistra sul glifo */
#profile-nav-item .nav-profile-ico-wrap .nav-badge-dot {
    top: -1px;
    right: -2px;
}

@media (min-width: 1025px) {
    #profile-nav-item .nav-profile-ico-wrap .nav-badge-dot {
        top: -3px;
        right: 5px;
    }
}

.dropdown-content-profile a.nav-profile-menu-nudge {
    position: relative;
}

.dropdown-content-profile .nav-profile-menu-nudge__dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-radius: 999px;
    background: #ef4444;
    flex-shrink: 0;
}

/* Pannello notifiche mobile: full-page da destra */
.nav-notifs-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
    z-index: 1100;
}
.nav-notifs-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.nav-notifs-sheet {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.22,1,0.36,1);
    z-index: 1101;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    box-sizing: border-box;
}

/* Desktop: nascondi overlay + pannello (si usa la tendina) */
@media (min-width: 769px) {
    .nav-notifs-overlay,
    .nav-notifs-sheet {
        display: none !important;
    }
}
.nav-notifs-sheet.is-open {
    transform: translateX(0);
}
.nav-notifs-sheet__handle {
    display: none;
}
.nav-notifs-sheet__head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 8px 12px 10px 6px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
    min-height: 52px;
    box-sizing: border-box;
}
.nav-notifs-sheet__title {
    font-weight: 800;
    color: #0f172a;
    font-size: 1.05rem;
}
.nav-notifs-sheet__back,
.nav-notifs-sheet__close {
    border: none;
    background: transparent;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    cursor: pointer;
    color: #111827;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.nav-notifs-sheet__body {
    padding: 10px 10px 14px;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.nav-notifs-empty {
    padding: 18px 12px;
    color: #64748b;
    font-weight: 600;
    text-align: center;
}
.nav-notif-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px;
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
}
.nav-notif-row__main {
    min-width: 0;
    flex: 1;
}

.nav-notif-row__section {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    color: #94a3b8;
}
.nav-notif-row > .fa-chevron-right {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: 0.75rem;
}
.nav-notif-row:hover {
    background: rgba(0, 102, 204, 0.06);
}
.nav-notif-row__title {
    font-weight: 500;
    color: #0f172a;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.nav-notif-row__detail {
    margin-top: 4px;
    font-size: 0.88rem;
    font-weight: 400;
    color: #475569;
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.nav-notif-row--unread .nav-notif-row__title,
.nav-notif-row--unread .nav-notif-row__detail {
    font-weight: 700;
}
.nav-notif-row__time {
    margin-top: 4px;
    font-size: 0.82rem;
    color: #64748b;
}

/* Logout specifico */
.dropdown-content-profile a.logout-link { color: var(--logout-color); }
.dropdown-content-profile a.logout-link:hover { background-color: #fef2f2; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- RESPONSIVE --- */

/* MOBILE (< 768px) */
@media (max-width: 768px) {
    body { padding-bottom: 90px; } /* Aumentato per via del margine della navbar */
    /* Su mobile le sezioni "desktop-only" non devono comparire mai */
    .nav-desktop-only { display: none !important; }

    /* Ospiti: Esplora → Turni → Pubblica → Accedi
       Loggati: Home → Messaggi → Pubblica → Esplora → Avatar */
    #explore-nav-item { order: 1; }
    #turni-nav-item-guest { order: 2; }
    #crea-nav-item { order: 3; }
    #accedi-nav-item { order: 4; }

    .icon-nav--authed #messages-nav-item { order: 2; }
    .icon-nav--authed #crea-nav-item { order: 3; }
    .icon-nav--authed #esplora-nav-item { order: 4; }
    .icon-nav--authed #profile-nav-item { order: 5; }

    .icon-nav .nav-profile-avatar {
        width: 1.2rem;
        height: 1.2rem;
        margin-bottom: 4px;
        border-radius: 50%;
        overflow: hidden;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #000;
        color: #fff;
        font-size: 0.52rem;
        font-weight: 800;
        letter-spacing: -0.04em;
        line-height: 1;
        flex-shrink: 0;
        border: 0;
        box-sizing: border-box;
    }

    @supports (mix-blend-mode: destination-out) {
        .icon-nav .nav-profile-avatar--initials {
            isolation: isolate;
            color: #000;
        }
        .icon-nav .nav-profile-avatar--initials > span {
            mix-blend-mode: destination-out;
        }
    }

    .icon-nav .nav-profile-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .top-bar {
        overflow: visible;
    }
    
    /*
     * Shell mobile: dock = pill con backdrop-filter; glass = sibling fixed sotto (z più basso).
     * Il blur satina funziona solo se l'elemento con backdrop-filter è sibling del glass
     * (non un figlio in un wrapper). Geometria sync via body:has(#bottom-nav…).
     */
    .nav-dock {
        display: block;
        position: fixed;
        bottom: 10px;
        left: 10px;
        right: 10px;
        height: 65px;
        border-radius: 20px;
        z-index: 1001;
        pointer-events: none;
        background: var(--bg-blur);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--border-color);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
        transition:
            left 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            right 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            height 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            border-radius 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            bottom 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            box-shadow 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    }
    body:has(#bottom-nav.is-scroll-compact) .nav-dock,
    .nav-dock:has(#bottom-nav.is-scroll-compact) {
        left: max(20px, calc((100vw - min(300px, 72vw)) / 2));
        right: max(20px, calc((100vw - min(300px, 72vw)) / 2));
        height: 48px;
        border-radius: 999px;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    }
    body:has(#bottom-nav.nav-hidden) .nav-dock,
    .nav-dock:has(#bottom-nav.nav-hidden) {
        bottom: calc(-1 * (100% + 20px));
    }

    /* Nav riempie il dock; niente backdrop qui (è sul sibling .nav-dock) */
    .nav-dock .icon-nav {
        position: absolute;
        inset: 0;
        left: 0;
        right: 0;
        bottom: 0;
        top: 0;
        width: auto;
        height: auto;
        border: none;
        border-radius: inherit;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        overflow: visible;
        z-index: 1;
        pointer-events: auto;
        transform: none;
        transition: opacity 0.32s ease;
    }

    body:has(#bottom-nav.is-scroll-compact) .nav-dock .icon-nav,
    .nav-dock:has(#bottom-nav.is-scroll-compact) .icon-nav {
        box-shadow: none;
    }

    /* Scroll down: solo hide testi / icone (geometria su dock + glass) */
    .icon-nav.is-scroll-compact {
        /* height/left gestiti dal dock / glass sync */
    }

    .icon-nav.is-scroll-compact .nav-text {
        display: none;
    }

    .icon-nav.is-scroll-compact .nav-item i,
    .icon-nav.is-scroll-compact .nav-profile-avatar {
        margin-bottom: 0;
    }
    .icon-nav.is-scroll-compact.nav-hidden { /* hide: body:has(#bottom-nav.nav-hidden) */ }

    /* Legacy .icon-nav--iconic: non nasconde più i testi (lo fa solo is-scroll-compact) */
    .icon-nav.icon-nav--iconic {
        height: 65px;
    }
    .icon-nav.icon-nav--iconic .nav-text {
        display: block;
    }
    .icon-nav.icon-nav--iconic.is-scroll-compact {
        height: 48px;
    }
    .icon-nav.icon-nav--iconic.is-scroll-compact .nav-text {
        display: none;
    }
    body.nav-iconic {
        padding-bottom: 95px; /* allineato alla nav piena mobile */
    }

    /*
     * Immagine SOTTO la pill: stesso box del .nav-dock (sibling), z più basso.
     * Sync geometria con body:has(#bottom-nav…) così non si stacca allo scroll.
     */
    .nav-glass-backdrop {
        display: block;
        position: fixed;
        bottom: 10px;
        left: 10px;
        right: 10px;
        height: 65px;
        border-radius: 20px;
        overflow: hidden;
        z-index: 1000;
        pointer-events: none;
        transition:
            left 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            right 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            height 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            border-radius 0.42s cubic-bezier(0.32, 0.72, 0, 1),
            bottom 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    }
    body:has(#bottom-nav.is-scroll-compact) .nav-glass-backdrop {
        left: max(20px, calc((100vw - min(300px, 72vw)) / 2));
        right: max(20px, calc((100vw - min(300px, 72vw)) / 2));
        height: 48px;
        border-radius: 999px;
    }
    body:has(#bottom-nav.nav-hidden) .nav-glass-backdrop {
        bottom: calc(-1 * (100% + 20px));
    }
    .nav-glass-backdrop__pan {
        position: absolute;
        inset: 0;
        background-repeat: no-repeat;
        background-size: 100% 100%;
        background-position: 50% 50%;
        will-change: background-position, background-size, transform, opacity;
        animation: nav-glass-pan-full 36s ease-in-out 0.6s infinite;
        opacity: 0;
        /*
         * Satin leggero + saturazione: blur troppo alto “sbiadisce” i colori.
         * Prima il backdrop-filter lasciava i colori più vivi; qui bilanciamo.
         */
        filter: blur(12px) saturate(1.45);
        /* scale minimo anche a riposo: nasconde i bordi molli del blur */
        transform: scale(1.2);
    }

    .icon-nav .nav-container {
        display: flex;
        position: relative;
        z-index: 1;
    }

    @keyframes nav-glass-pan-full {
        0% { background-position: 50% 50%; background-size: 100% 100%; transform: scale(1.2); opacity: 0; }
        12% { background-position: 46% 48%; background-size: 170% 170%; transform: scale(1.24); opacity: 0; }
        16% { background-position: 52% 46%; background-size: 210% 210%; transform: scale(1.32); opacity: 0.65; }
        20% { background-position: 48% 52%; background-size: 240% 240%; transform: scale(1.4); opacity: 1; }
        24% { background-position: 54% 50%; background-size: 220% 220%; transform: scale(1.34); opacity: 0.65; }
        28% { background-position: 50% 48%; background-size: 180% 180%; transform: scale(1.26); opacity: 0; }
        48% { background-position: 52% 54%; background-size: 175% 175%; transform: scale(1.26); opacity: 0; }
        52% { background-position: 46% 50%; background-size: 215% 215%; transform: scale(1.34); opacity: 0.65; }
        56% { background-position: 50% 46%; background-size: 250% 250%; transform: scale(1.44); opacity: 1; }
        60% { background-position: 54% 52%; background-size: 225% 225%; transform: scale(1.36); opacity: 0.65; }
        64% { background-position: 48% 50%; background-size: 185% 185%; transform: scale(1.28); opacity: 0; }
        78% { background-position: 50% 52%; background-size: 170% 170%; transform: scale(1.24); opacity: 0; }
        82% { background-position: 54% 48%; background-size: 205% 205%; transform: scale(1.32); opacity: 0.65; }
        86% { background-position: 48% 50%; background-size: 235% 235%; transform: scale(1.4); opacity: 1; }
        90% { background-position: 52% 54%; background-size: 210% 210%; transform: scale(1.32); opacity: 0.65; }
        94% { background-position: 50% 50%; background-size: 175% 175%; transform: scale(1.24); opacity: 0; }
        100% { background-position: 50% 50%; background-size: 100% 100%; transform: scale(1.2); opacity: 0; }
    }

    @media (prefers-reduced-motion: reduce) {
        .nav-glass-backdrop__pan {
            animation: none !important;
            background-position: 50% 50%;
            background-size: 100% 100%;
            transform: scale(1.2);
            filter: blur(12px) saturate(1.45);
            opacity: 0.22;
        }
    }
    .icon-nav .nav-item.active::after {
        content: '';
        position: absolute;
        top: -1px; /* Leggermente rialzato per combaciare col bordo */
        left: 50%;
        transform: translateX(-50%);
        width: 40%;
        height: 3px;
        background-color: var(--nav-active);
        border-radius: 0 0 4px 4px;
        pointer-events: none;
    }
    
    /* Navbar a scomparsa: geometria sul dock (glass+nav insieme) */
    .icon-nav.nav-hidden {
        /* transform su .nav-dock:has(#bottom-nav.nav-hidden) */
    }
    
    /* Attaccati al bordo superiore della voce: seguono altezza piena / pill compatta */
    .dropdown-content-cerca,
    .dropdown-content-profile,
    .dropdown-content-turni,
    .dropdown-content-crea {
        top: auto;
        bottom: calc(100% + 8px);
    }

    .dropdown-content-cerca {
        left: 0;
        right: auto;
        transform-origin: bottom left;
    }

    .dropdown-content-profile {
        right: 0;
        left: auto;
        transform-origin: bottom right;
    }

    .dropdown-content-turni,
    .dropdown-content-crea {
        left: 50%;
        transform: translateX(-50%);
        transform-origin: bottom center;
    }

    /* Pop dal basso (dal trigger nav) — preserva translateX dei menu centrati */
    .dropdown-content-cerca.show,
    .dropdown-content-profile.show,
    .dropdown-content-notifs.show {
        animation-name: nav-dd-pop;
    }
    .dropdown-content-turni.show,
    .dropdown-content-crea.show {
        animation-name: nav-dd-pop-center;
    }
}

/* Desktop: sidebar a sinistra (stile vetro top-bar) */
@media (min-width: 769px) {
    /*
     * Meccanismo originale (commit e727153 / pre-perf): il BODY si sposta con padding-left.
     * !important: batte reset * { padding:0 } e regole body di index/global.
     */
    body {
        padding-left: var(--meedico-nav-rail, 72px) !important;
        padding-top: 0 !important;
        transition: padding-left 0.22s ease;
        box-sizing: border-box;
    }
    /* Mappa: layout fixed con left + --nav-rail-w (non usare padding body) */
    body.exmap-page,
    body.exmap-page.nav-rail-expanded {
        padding-left: 0 !important;
    }

    /* Top bar sparisce su desktop: logo passa nella sidebar */
    .top-bar { display: none !important; }

    .icon-nav {
        top: 0;
        left: 0;
        bottom: 0;
        width: 72px;
        height: auto;
        background: rgb(0 29 255 / 11%);
        border-right: 1px solid var(--border-color);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transition: width 0.22s ease;
    }

    .nav-dock {
        display: contents;
    }

    .nav-glass-backdrop {
        display: none !important;
    }

    .nav-container {
        flex-direction: column;
        justify-content: flex-start;
        gap: 8px;
        padding: 14px 8px;
        height: 100%;
        align-items: stretch;
    }

    .nav-side-logo {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        padding: 8px 12px 16px;
        border-bottom: 1px solid rgba(0,0,0,0.08);
        margin-bottom: 6px;
    }

    .nav-side-logo__link {
        text-decoration: none;
        color: var(--meedico-brand-blue, var(--accent-color));
        font-weight: 800;
        font-size: 1.4rem;
        letter-spacing: -0.02em;
        text-shadow: none;
        display: inline-flex;
        align-items: baseline;
        white-space: nowrap;
        overflow: hidden;
    }

    .nav-side-logo__m { display: inline-block; }
    /* Default: sidebar chiusa => mostra solo "m". Il resto appare su hover / is-open */
    .nav-side-logo__rest { display: none; }

    .icon-nav.is-open .nav-side-logo__rest,
    .icon-nav.nav-dropdown-pinned .nav-side-logo__rest {
        display: inline-block;
    }

    .icon-nav .nav-item {
        flex: 0 0 auto;
        height: 44px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 10px 12px;
        border-radius: 14px;
    }

    .nav-link {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
    }

    .icon-nav .nav-item i {
        margin-bottom: 0;
        font-size: 1.25rem;
        width: 24px;
        text-align: center;
    }

    /*
     * Caps come su mobile: spessore 3px, lato sul margine resta dritto, l’altro lato con raggio 4px.
     * Allineamento al margine destro della rail: stesso padding destro di .nav-container (8px).
     */
    .icon-nav .nav-item.active::after {
        content: '';
        position: absolute;
        top: 50%;
        right: -8px;
        left: auto;
        bottom: auto;
        width: 3px;
        height: 50%;
        min-height: 18px;
        max-height: 22px;
        margin: 0;
        transform: translateY(-50%);
        background-color: var(--nav-active);
        border-radius: 4px 0 0 4px;
        pointer-events: none;
    }

    /* Testi: appaiono/scompaiono smooth, icone restano ferme */
    .nav-text { 
        opacity: 0;
        transform: translateX(-6px);
        max-width: 0;
        overflow: hidden;
        white-space: nowrap;
        transition: opacity 0.18s ease, transform 0.18s ease, max-width 0.22s ease;
        pointer-events: none;
        font-size: 0.9rem;
        font-weight: 600;
    }
    @media (hover: hover) and (pointer: fine) {
        .icon-nav:hover { width: 196px; }
        .icon-nav:hover .nav-text {
            opacity: 1;
            transform: translateX(0);
            max-width: 220px;
            pointer-events: auto;
        }
        .icon-nav:hover .nav-side-logo__rest {
            display: inline-block;
        }
    }

    /* Sottomenu aperti al click: sidebar espansa finché non si chiude il pannello */
    .icon-nav.nav-dropdown-pinned {
        width: 196px;
    }
    .icon-nav.nav-dropdown-pinned .nav-side-logo__rest {
        display: inline-block;
    }
    .icon-nav.nav-dropdown-pinned .nav-text {
        opacity: 1;
        transform: translateX(0);
        max-width: 220px;
        pointer-events: auto;
    }

    /* Sidebar aperta all'inizio pagina (JS), poi si "chiude" in scroll */
    .icon-nav.is-open { width: 196px; }
    .icon-nav.is-open .nav-text {
        opacity: 1;
        transform: translateX(0);
        max-width: 220px;
    }

    /* Stato compatto in scroll: icone + solo "m" (larghezza resta 72px per non creare "striscia") */
    .icon-nav.is-compact { width: 72px; }
    .icon-nav.is-compact .nav-side-logo__rest { display: none; }
    .icon-nav.is-compact .nav-side-logo__link { text-shadow: none; }
    @media (hover: hover) and (pointer: fine) {
        .icon-nav.is-compact:hover { width: 196px; }
        .icon-nav.is-compact:hover .nav-side-logo__rest { display: inline-block; }
        .icon-nav.is-compact:hover .nav-side-logo__link { text-shadow: none; }
    }

    .icon-nav .nav-item:hover {
        background: rgba(0, 102, 204, 0.06);
        color: var(--nav-active);
    }

    /* Mostra voci desktop, nascondi il dropdown mobile */
    .nav-mobile-only { display: none !important; }
    .nav-desktop-only { display: flex !important; }

    /* Dropdowns: aprono verso destra, ancorati alla sidebar */
    .dropdown-content-profile,
    .dropdown-content-turni,
    .dropdown-content-offerte,
    .dropdown-content-crea,
    .dropdown-content-notifs {
        left: 100%;
        top: 0;
        margin-left: 10px;
        bottom: auto;
        transform-origin: top left;
    }

    .dropdown-content-profile.show,
    .dropdown-content-turni.show,
    .dropdown-content-offerte.show,
    .dropdown-content-crea.show,
    .dropdown-content-notifs.show {
        animation-name: nav-dd-pop-side;
    }

    /* Profilo è l’ultima voce: apri verso l’alto e resta nel viewport */
    #profile-nav-item .dropdown-content-profile {
        top: auto;
        bottom: 0;
        transform-origin: bottom left;
        max-height: min(70vh, calc(100vh - 24px));
        overflow-x: hidden;
        overflow-y: auto;
    }

    /*
     * Notifiche: il max-height da solo non basta — il pannello è position:absolute con top:0
     * rispetto alla voce sidebar e può andare oltre il fondo dello schermo. Su desktop lo
     * fissiamo tra top/bottom del viewport, scroll interno.
     */
    #notifs-nav-item .dropdown-content-notifs {
        position: fixed;
        top: 12px;
        bottom: 12px;
        left: calc(72px + 10px);
        margin-left: 0;
        width: min(380px, calc(100vw - 72px - 22px));
        min-width: 300px;
        max-width: min(380px, calc(100vw - 72px - 22px));
        max-height: none;
        height: auto;
    }

    .icon-nav:hover #notifs-nav-item .dropdown-content-notifs,
    .icon-nav.is-open #notifs-nav-item .dropdown-content-notifs,
    .icon-nav.nav-dropdown-pinned #notifs-nav-item .dropdown-content-notifs {
        left: calc(196px + 10px);
        width: min(380px, calc(100vw - 196px - 22px));
        max-width: min(380px, calc(100vw - 196px - 22px));
    }
}

/* (rimosso vecchio layout desktop top-nav in favore della sidebar) */