/*
body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

html {
  height: -webkit-fill-available;
}

main {
  height: 100vh;
  height: -webkit-fill-available;
  max-height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
}
*/
.dropdown-toggle { outline: 0; }

.btn-toggle {
  padding: .25rem .5rem;
  font-weight: 600;
  color: var(--bs-emphasis-color);
  background-color: transparent;
}
.btn-toggle:hover,
.btn-toggle:focus {
  color: rgba(var(--bs-emphasis-color-rgb), .85);
  background-color: var(--bs-tertiary-bg);
}

.btn-toggle::before {
  width: 1.25em;
  line-height: 0;
  content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%280,0,0,.5%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
  transition: transform .35s ease;
  transform-origin: .5em 50%;
}

[data-bs-theme="dark"] .btn-toggle::before {
  content: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%28255,255,255,.5%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
}

.btn-toggle[aria-expanded="true"] {
  color: rgba(var(--bs-emphasis-color-rgb), .85);
}
.btn-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.btn-toggle-nav a {
  padding: .1875rem .5rem;
  margin-top: .125rem;
  margin-left: 1.25rem;
}
.btn-toggle-nav a:hover,
.btn-toggle-nav a:focus {
  background-color: var(--bs-tertiary-bg);
}

.scrollarea {
  overflow-y: auto;
}

/* ══════════════════════════════════════════
   SIDEBAR LAYOUT (ft2616)
══════════════════════════════════════════ */

html, body { height: 100%; }

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
#menu {
    width: 240px;
    min-width: 240px;
    background: #1e2a3a;
    color: #cfd8e3;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    flex-shrink: 0;
}

/* ── Content wrapper ── */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Topbar ── */
#header {
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    /* Sopra le testate sticky delle pagine (Bootstrap le mette a 1020) e
       sotto i modali (1055): il menu sul nome deve aprirsi sopra tutto
       quello che scorre, non sotto. Senza position lo z-index non conta. */
    position: relative;
    z-index: 1030;
}

/* La min-height regge la barra da sloggato, quando badge sessione e
   area utente sono nascosti e dentro non c'e' piu' niente: senza,
   la pagina di login mostra una striscia che al login salta su. */
#header .topbar-inner {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    gap: 12px;
    min-height: 47px;
}

/* A sinistra oggi non c'e' nulla, e le azioni si spingono a destra da
   sole. Con margin-left invece che con justify-content perche' se un
   giorno a sinistra torna qualcosa, il posto e' gia' pronto. */
#header .topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: auto;
}

.session-badge-topbar {
    background: #6c757d;
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.notif-wrapper {
    position: relative;
    display: inline-flex;
}

#topbar-user-area {
    display: none;
    align-items: center;
    gap: 10px;
}
#topbar-user-area.topbar-user-visible {
    display: flex;
}

/* ── Main content ── */
#main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f4f6f9;
}

/* ── Sidebar nav elements ── */
.sidebar-brand {
    padding: 12px 14px;
    border-bottom: 1px solid #2e3f54;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.sidebar-brand .brand-logo {
    width: 30px; height: 30px;
    background: #fff;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; color: #fff;
    flex-shrink: 0;
}
.sidebar-brand .brand-name {
    font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2;
}
.sidebar-brand .brand-sub {
    font-size: 10px; color: #7a93b0;
    text-transform: uppercase; letter-spacing: .05em;
}

.sidebar-nav { padding: 6px 5px; flex: 1; }

.sidebar-section {
    padding: 14px 10px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #4d6a82;
    font-weight: 700;
}

.sidebar-group-toggle {
    width: 100%;
    background: none;
    border: none;
    color: #cfd8e3;
    text-align: left;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-group-toggle:hover { background: #2e3f54; color: #fff; }
.sidebar-group-toggle .chevron {
    margin-left: auto;
    font-size: 10px;
    transition: transform .2s;
}
.sidebar-group-toggle.collapsed .chevron { transform: rotate(-90deg); }

/* Gruppo con label navigante + chevron separato */
.sidebar-group-header {
    display: flex;
    align-items: stretch;
    border-radius: 6px;
    overflow: hidden;
}
.sidebar-group-header-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    color: #cfd8e3;
    text-decoration: none;
    font-size: 13px;
    padding: 7px 4px 7px 10px;
    transition: background .15s;
}
.sidebar-group-header-link:hover { background: #2e3f54; color: #fff; }
.sidebar-group-header-link.nav-active { background: #1a3a60; color: #fff; }
.sidebar-group-header-chevron {
    background: none;
    border: none;
    color: #cfd8e3;
    padding: 7px 10px;
    cursor: pointer;
    transition: background .15s;
    font-size: 10px;
    display: flex;
    align-items: center;
}
.sidebar-group-header-chevron:hover { background: #2e3f54; color: #fff; }
.sidebar-group-header-chevron .chevron { transition: transform .2s; }
.sidebar-group-header-chevron[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.sidebar-sub {
    list-style: none;
    padding: 2px 0 4px 33px;
    margin: 0;
}
.sidebar-sub li a {
    display: block;
    color: #9db5cb;
    text-decoration: none;
    font-size: 12.5px;
    padding: 5px 8px;
    border-radius: 5px;
    border-left: 2px solid transparent;
    transition: all .12s;
}
.sidebar-sub li a:hover { color: #fff; background: #2e3f54; border-left-color: #4d8eff; }
.sidebar-sub li a.nav-active { color: #fff; background: #1a3a60; border-left-color: #0d6efd; font-weight: 600; }

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #cfd8e3;
    text-decoration: none;
    font-size: 13px;
    padding: 7px 10px;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-item a:hover { background: #2e3f54; color: #fff; }
.sidebar-item a.nav-active { background: #1a3a60; color: #fff; }

.sidebar-divider { border-top: 1px solid #2e3f54; margin: 8px 10px; }

.sidebar-footer {
    flex-shrink: 0;
    padding: 8px 10px;
    border-top: 1px solid #2e3f54;
}
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #7a93b0;
    text-decoration: none;
    font-size: 12.5px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background .15s;
}
.sidebar-footer a:hover { background: #2e3f54; color: #fff; }

/* Footer applicazione (in fondo al content) */
.app-footer {
    padding: 6px 20px;
    background: #fff;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}


/* ── Telefono: il menu e' un cassetto ──
   Largo fisso 240px e sempre presente, su un telefono da 375px lasciava
   alla pagina una striscia di 135px, qualunque cosa ci fosse dentro.
   Sotto i 768px esce dallo schermo e rientra con il tasto nella barra in
   alto, sopra la pagina e sotto i modali (1055). Da computer non cambia
   niente: il tasto e il velo non si vedono. */

#btn-menu,
#menu-velo {
    display: none;
}

@media (max-width: 767.98px) {

    #menu {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    #app.menu-aperto #menu {
        transform: none;
        box-shadow: 0 0 24px rgba(0, 0, 0, .35);
    }

    #app.menu-aperto #menu-velo {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(0, 0, 0, .4);
    }

    /* Alla pagina di login il menu non c'e': niente tasto. Con una classe
       messa da carica_sezione: :has(#menu:empty) funzionava ovunque tranne
       che su Safari per iPhone, che non lo riaggiornava dopo il login */
    #btn-menu {
        display: inline-flex;
    }

    #app.app-login #btn-menu {
        display: none;
    }

    #header .topbar-inner {
        padding: 6px 12px;
    }

    /* Il nome occupa mezza barra: sul telefono resta l'icona */
    #slot_info_utente {
        display: none;
    }
}



/* ── Menu compatto: solo le icone ──
   Il testo delle voci sta nudo accanto all'icona, senza uno span: lo si
   nasconde azzerando il font del link e ridando la misura alla sola icona. */

.brand-compatta {
    margin-left: auto;
    background: none;
    border: none;
    color: #7a93b0;
    padding: 2px 4px;
    font-size: 12px;
    cursor: pointer;
}
.brand-compatta:hover { color: #fff; }

@media (min-width: 768px) {
    #app.menu-compatto #menu {
        width: 56px;
        min-width: 56px;
    }
    #app.menu-compatto .sidebar-brand {
        flex-direction: column;
        padding: 10px 0;
        gap: 6px;
    }
    #app.menu-compatto .brand-name,
    #app.menu-compatto .sidebar-sub,
    #app.menu-compatto .sidebar-group-header-chevron {
        display: none;
    }
    #app.menu-compatto .brand-compatta { margin-left: 0; }
    /* Il titolo della sezione diventa una linea di separazione */
    #app.menu-compatto .sidebar-section {
        font-size: 0;
        padding: 0;
        margin: 8px 10px;
        border-top: 1px solid #2e3f54;
    }
    #app.menu-compatto .sidebar-section > * { display: none; }
    #app.menu-compatto .sidebar-nav { padding: 6px 4px; }
    #app.menu-compatto .sidebar-item a,
    #app.menu-compatto .sidebar-group-toggle,
    #app.menu-compatto .sidebar-group-header-link {
        font-size: 0;
        gap: 0;
        justify-content: center;
        padding: 9px 0;
    }
    #app.menu-compatto .sidebar-item a i,
    #app.menu-compatto .sidebar-group-toggle i,
    #app.menu-compatto .sidebar-group-header-link i {
        font-size: 17px;
    }
    #app.menu-compatto .sidebar-group-toggle .chevron { display: none; }
    #app.menu-compatto .sidebar-item a span {
        display: none;
    }
}
