﻿/* =============================================
   DIGIVENTS – Layout con Header + Sidebar
   File: /Styles/SidebarLayout.css
   ============================================= */

/* --- Global reset --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* =============================================
   COLORI
   Verde oliva:  #5c7a1e  |  Hover bg: #eef5e0
   Testo:        #3d3d3d  |  Bordi:    #e0e4eb
   ============================================= */

/* =============================================
   HEADER FISSO
   ============================================= */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: #fff;
    border-bottom: 2px solid #e0e4eb;
    z-index: 1040;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.header-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 16px;
}

/* Logo */
.header-logo {
    flex-shrink: 0;
    margin-right: 28px;
}

.header-logo-img {
    height: 34px;
    width: auto;
    display: block;
}

/* Menu superiore: SEMPRE un dropdown, mai inline orizzontale.
   Visibile solo quando il burger lo apre (.open). */
.header-mainnav {
    display: none !important;
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 2px solid #e0e4eb;
    box-shadow: 0 4px 12px rgba(0,0,0,0.10);
    z-index: 1039;
    overflow: hidden;
}

    .header-mainnav.open {
        display: block !important;
    }

/* NavigationMenu: sempre verticale (è sempre un panel dropdown, mai inline) */
#NavigationMenu,
#NavigationMenu table,
#NavigationMenu tbody,
#NavigationMenu tr,
#NavigationMenu td {
    display: block !important;
    width: 100% !important;
}

    #NavigationMenu a,
    #NavigationMenu a:link,
    #NavigationMenu a:visited {
        display: flex !important;
        align-items: center;
        gap: 7px;
        padding: 12px 20px !important;
        height: auto !important;
        color: #4a4a4a;
        font-size: 14px;
        font-weight: 500;
        text-decoration: none;
        border-bottom: 1px solid #f0f0f0;
        transition: color 0.15s, background 0.15s;
        white-space: nowrap;
    }

        #NavigationMenu a:hover,
        #NavigationMenu a:focus {
            color: #5c7a1e;
            background: #f5f9ec;
            text-decoration: none;
        }

    #NavigationMenu .active a,
    #NavigationMenu td.active a {
        color: #5c7a1e !important;
        background: #f5f9ec;
        font-weight: 600;
    }

    #NavigationMenu .menu-icon {
        font-size: 15px;
        width: 16px;
        text-align: center;
        color: #88aa3a;
        flex-shrink: 0;
    }

/* Burger menu principale: SEMPRE visibile, a tutte le risoluzioni */
.header-nav-toggle {
    display: flex !important; /* sempre visibile, nessun media query */
    align-items: center;
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 9px;
    margin-left: auto; /* spinge il burger verso destra nel flex row */
    cursor: pointer;
    color: #555;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

/* Quando il burger è nascosto (utente senza voci di menu), il margin-left:auto
   non è più presente: header-right resterebbe appiccicato a sinistra.
   Con la classe .no-top-nav sull'header-inner, si trasferisce l'auto a
   header-right così le credenziali rimangono allineate a destra. */
.header-inner.no-top-nav .header-nav-toggle {
    margin-left: 0;
}

.header-inner.no-top-nav .header-right {
    margin-left: auto;
}

.header-nav-toggle:hover {
    background: #f5f5f5;
    border-color: #aaa;
}

.header-nav-toggle .icon-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: #555;
    margin: 4px 0;
    border-radius: 1px;
}

/* Hamburger sidebar evento (header, lato sinistro – solo mobile) */
.mobile-sidebar-btn {
    display: none !important; /* !important: nascosto su desktop, non sovrascrivibile */
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 9px;
    margin-right: 10px;
    cursor: pointer;
    color: #5c7a1e;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

    .mobile-sidebar-btn:hover {
        background: #eef5e0;
        border-color: #5c7a1e;
    }

/* Destra header */
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    margin-left: 16px;
}

.header-languages {
    display: flex;
    align-items: center;
    gap: 6px;
}

    .header-languages img.language {
        width: 22px;
        height: auto;
        cursor: pointer;
        opacity: 0.75;
        transition: opacity 0.2s;
        vertical-align: middle;
    }

        .header-languages img.language:hover {
            opacity: 1;
        }

.header-user {
    display: flex;
    align-items: center;
}

.header-user-btn {
    color: #3d3d3d !important;
    font-weight: 500;
    font-size: 14px;
    padding: 4px 8px !important;
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

    .header-user-btn:hover,
    .header-user-btn:focus {
        color: #5c7a1e !important;
        background: #f5f9ec !important;
        border-radius: 4px;
    }

    .header-user-btn .fa {
        font-size: 16px;
        margin-right: 4px;
        color: #88aa3a;
    }

.header-user .dropdown-menu {
    right: 0;
    left: auto;
    min-width: 180px;
    font-size: 14px;
}

    .header-user .dropdown-menu .dropdown-item {
        display: block;
        padding: 8px 16px;
        color: #3d3d3d;
        text-decoration: none;
    }

        .header-user .dropdown-menu .dropdown-item:hover {
            background: #f5f9ec;
            color: #5c7a1e;
        }

    .header-user .dropdown-menu .divider {
        height: 1px;
        background: #e0e4eb;
        margin: 4px 0;
    }

.header-version {
    font-size: 11px;
    color: #bbb;
    white-space: nowrap;
}

/* =============================================
   CORPO PAGINA
   ============================================= */
.body-layout {
    display: block;
    min-height: 100vh;
    padding-top: 58px;
}

/* =============================================
   SIDEBAR COLLASSABILE
   ============================================= */

/* Larghezze e transizioni */
:root { /* IE11 fallback: valori duplicati sotto */
}

.sidebar {
    position: fixed;
    top: 58px;
    left: 0;
    bottom: 0;
    width: 230px;
    background: #fff;
    border-right: 1px solid #e0e4eb;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
    transition: width 0.25s ease, transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

    /* Stato collassato */
    .sidebar.collapsed {
        width: 0;
        border-right: none;
        box-shadow: none;
        overflow: hidden;
    }

/* Pulsante toggle sidebar — posizionato sul bordo destro della sidebar */
#sidebarToggleBtn {
    position: fixed;
    top: 50%;
    /* Si sposta con la sidebar */
    left: 230px;
    transform: translateY(-50%) translateX(-50%);
    z-index: 1035;
    width: 22px;
    height: 46px;
    background: #fff;
    border: 1px solid #e0e4eb;
    border-left: none;
    border-radius: 0 6px 6px 0;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: left 0.25s ease;
    color: #888;
    font-size: 12px;
}

    #sidebarToggleBtn:hover {
        background: #f5f9ec;
        color: #5c7a1e;
    }


/* Quando collassato: il pulsante si sposta a sinistra e diventa più largo */
body.sidebar-collapsed #sidebarToggleBtn {
    left: 10;
    /* Manteniamo i tuoi colori e bordi originali */
    background-color: #5c7a1e;#5c7a1e
    color: #ffffff;
    border-left: 1px solid #e0e4eb;
    border-radius: 0 6px 6px 0;
    /* AGGIUNTA: Aumentiamo la larghezza tramite lo spazio interno */
    /* Regola il secondo valore (25px) per decidere quanto farlo largo */
    padding-left: 25px;
    padding-right: 15px;
    /* Assicura che l'icona interna rimanga centrata se necessario */
    display: flex;
    justify-content: center;
    align-items: center;
}


/* Scrollbar sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f8f8f8;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 2px;
}

    .sidebar::-webkit-scrollbar-thumb:hover {
        background: #b0b8c5;
    }

/* =============================================
   MENU EVENTO – NUOVO STILE
   ============================================= */
.sidebar-event-menu {
    flex: 1;
    padding: 12px 0 16px;
}

    /* Reset completo di qualsiasi navbar iniettata dalle pagine evento */
    .sidebar-event-menu .navbar,
    .sidebar-event-menu .navbar-inverse,
    .sidebar-event-menu .navbar-default {
        background: transparent !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        min-height: 0 !important;
        border-radius: 0 !important;
    }

    .sidebar-event-menu .navbar-header {
        display: none !important;
    }

    .sidebar-event-menu .navbar-collapse,
    .sidebar-event-menu .collapse {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    /* Liste */
    .sidebar-event-menu .navbar-nav,
    .sidebar-event-menu ul.nav {
        float: none !important;
        margin: 0 !important;
        padding: 0 6px !important; /* padding laterale per arrotondamento */
        width: 100%;
        list-style: none;
    }

        .sidebar-event-menu .navbar-nav > li,
        .sidebar-event-menu ul.nav > li {
            float: none !important;
            display: block !important;
            width: 100%;
            margin-bottom: 2px;
        }

            /* ---- VOCE PRINCIPALE ---- */
            .sidebar-event-menu .navbar-nav > li > a,
            .sidebar-event-menu ul.nav > li > a {
                display: flex !important;
                align-items: flex-start; /* top-align: testo può andare a capo */
                gap: 10px;
                padding: 9px 12px !important;
                color: #3d3d3d !important;
                font-size: 13.5px;
                font-weight: 500;
                text-decoration: none;
                border-radius: 6px; /* pill stile */
                white-space: normal !important; /* PERMETTE IL WRAPPING */
                overflow: visible !important;
                text-overflow: clip !important;
                line-height: 1.35;
                transition: background 0.15s ease, color 0.15s ease;
            }

                .sidebar-event-menu .navbar-nav > li > a:hover,
                .sidebar-event-menu ul.nav > li > a:hover {
                    background: #eef5e0 !important;
                    color: #4a6818 !important;
                    text-decoration: none;
                }

                /* Voce attiva: sfondo verde oliva chiaro, testo verde, icona marcata */
                .sidebar-event-menu .navbar-nav > li.active > a,
                .sidebar-event-menu ul.nav > li.active > a,
                .sidebar-event-menu .navbar-nav > li > a.active {
                    background: #deeec0 !important;
                    color: #3d5a10 !important;
                    font-weight: 600;
                }

            /* Caret per i dropdown: spinto a destra */
            .sidebar-event-menu .navbar-nav > li.dropdown > a {
                position: relative;
            }

                .sidebar-event-menu .navbar-nav > li.dropdown > a .caret {
                    margin-left: auto;
                    flex-shrink: 0;
                    margin-top: 4px;
                    transition: transform 0.2s ease;
                }
            /* Rotazione caret quando aperto */
            .sidebar-event-menu .navbar-nav > li.dropdown.open > a .caret {
                transform: rotate(180deg);
            }

    /* Icone Font Awesome */
    .sidebar-event-menu .menu-icon {
        font-size: 14px;
        width: 17px;
        text-align: center;
        color: #88aa3a;
        flex-shrink: 0;
        margin-top: 1px; /* allineamento con testo */
    }

    .sidebar-event-menu li.active > a .menu-icon,
    .sidebar-event-menu li > a:hover .menu-icon {
        color: #5c7a1e;
    }

    /* ---- DROPDOWN / SOTTOVOCI ----
   Usa max-height + opacity invece di display:none/block:
   - il dropdown è sempre nel DOM (nessun flash al primo render)
   - la transizione è fluida quando il JS aggiunge/rimuove .open
   - il DOMContentLoaded pre-apre il dropdown corretto PRIMA del paint */
    .sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu {
        position: static !important;
        float: none !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        /* Stato chiuso: occupa zero spazio, invisibile */
        display: block !important; /* sempre nel DOM */
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.25s ease, opacity 0.2s ease;
    }

    .sidebar-event-menu .navbar-nav > li.dropdown.open > .dropdown-menu {
        /* 60px × max 15 voci = 900px abbondanti */
        max-height: 900px;
        opacity: 1;
    }

    /* Sottovoce */
    .sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu > li > a {
        display: flex !important;
        align-items: flex-start;
        gap: 8px;
        padding: 7px 12px 7px 38px !important; /* rientro */
        color: #555 !important;
        font-size: 13px;
        font-weight: 400;
        border-radius: 6px;
        white-space: normal !important; /* wrapping anche nei dropdown */
        overflow: visible !important;
        text-overflow: clip !important;
        line-height: 1.35;
        transition: background 0.15s ease, color 0.15s ease;
        text-decoration: none;
    }

        .sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu > li > a:hover {
            background: #eef5e0 !important;
            color: #4a6818 !important;
        }

        .sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu > li.active > a,
        .sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu > li > a.active {
            background: #deeec0 !important;
            color: #3d5a10 !important;
            font-weight: 600;
        }

/* ---- Separatori nei sotto-menu: allineati con il rientro delle voci (38px) ----
   Usiamo #divMenuEvento (ID) come ancore per massima specificità — batte
   qualsiasi regola Bootstrap basata su soli selettori di classe/elemento.

   (A) <li class="divider"> o <hr>: vengono indentati di 38px a sinistra
   (B) border-bottom su <li>/<a>: rimosso e rigenerato via ::after a left:38px */

/* (A) Divider — specificità ID garantisce override assoluto su Bootstrap */
#divMenuEvento .divider,
#divMenuEvento li.divider,
#divMenuEvento hr {
    margin-left: 38px !important;
    margin-right: 0 !important;
    width: calc(100% - 38px) !important;
    box-sizing: border-box !important;
}

/* (B) Rimuove border full-width dal <li> e lo rigenera via pseudo-elemento indentato */
.sidebar-event-menu .dropdown-menu > li {
    border-bottom: none !important;
    border-top: none !important;
}

.sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu > li > a {
    position: relative;
    border-bottom: none !important;
}

    .sidebar-event-menu .navbar-nav > li.dropdown > .dropdown-menu > li > a::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 38px; /* allineato con padding-left del testo/icona */
        right: 0;
        height: 1px;
        background: #f0f0f0;
    }

/* ---- asp:Menu renderizzato come TABLE ---- */
.sidebar-event-menu table {
    width: 100% !important;
    border-collapse: collapse;
    padding: 0 6px !important;
}

    .sidebar-event-menu table td {
        display: block !important;
        width: 100% !important;
        padding: 1px 0 !important;
    }

        .sidebar-event-menu table td a {
            display: flex !important;
            align-items: flex-start;
            gap: 10px;
            padding: 9px 12px;
            color: #3d3d3d;
            font-size: 13.5px;
            font-weight: 500;
            text-decoration: none;
            border-radius: 6px;
            white-space: normal !important;
            line-height: 1.35;
            transition: background 0.15s ease, color 0.15s ease;
        }

            .sidebar-event-menu table td a:hover {
                background: #eef5e0;
                color: #4a6818;
            }

            .sidebar-event-menu table td a.selected,
            .sidebar-event-menu table td.selected a {
                background: #deeec0;
                color: #3d5a10;
                font-weight: 600;
            }

/* =============================================
   AREA CONTENUTO
   ============================================= */
.main-wrapper {
    margin-left: 230px;
    min-height: calc(100vh - 58px);
    transition: margin-left 0.25s ease;
}

/* Sidebar nascosta: contenuto a larghezza piena */
body.no-sidebar .main-wrapper,
body.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

body.no-sidebar .sidebar,
body.no-sidebar #sidebarToggleBtn {
    display: none;
}

.main-wrapper > .main.container-fluid {
    padding: 20px 24px;
    overflow-x: auto;
    max-width: 100%;
}

.main-wrapper .footer {
    padding: 10px 24px;
    text-align: center;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #bbb;
}

/* =============================================
   OVERLAY SIDEBAR (mobile)
   ============================================= */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.42);
    z-index: 1029; /* sotto la sidebar (1030) ma sopra il contenuto */
}

    .sidebar-overlay.active {
        display: block;
    }

/* =============================================
   RESPONSIVE ≤ 768px  – sidebar va off-screen (mobile)
   ============================================= */
@media (max-width: 768px) {

    /* Mostra hamburger sidebar (a sinistra del logo) */
    .mobile-sidebar-btn {
        display: flex !important;
    }

    /* Nasconde la versione app: troppo stretta */
    .header-right .header-version {
        display: none;
    }

    /* Su mobile la larghezza della sidebar è SEMPRE 230px: l'off-screen è
       gestito da transform, non da width. Questo evita che la classe .collapsed
       (che imposta width:0 su desktop) faccia apparire la sidebar vuota su mobile. */
    .sidebar,
    .sidebar.collapsed {
        width: 230px !important;
        overflow-x: hidden;
        overflow-y: auto;
    }

    /* Sidebar esce dallo schermo a sinistra */
    .sidebar {
        transform: translateX(-230px);
        box-shadow: none;
    }
        /* Sidebar richiamata via JS: overlay + slide-in */
        .sidebar.sidebar-open,
        .sidebar.collapsed.sidebar-open {
            transform: translateX(0) !important;
            box-shadow: 4px 0 20px rgba(0,0,0,0.18);
        }

    /* Pulsante toggle desktop (bordo sidebar) inutile su mobile */
    #sidebarToggleBtn {
        display: none !important;
    }

    /* Contenuto: nessun margine sinistro (sidebar è fuori schermo) */
    .main-wrapper,
    body.sidebar-collapsed .main-wrapper,
    body.no-sidebar .main-wrapper {
        margin-left: 0 !important;
    }

        /* Padding ridotto su schermi piccoli */
        .main-wrapper > .main.container-fluid {
            padding: 12px 14px;
        }
}
