/*
 * tpl_dnd5e — Header utilities (lingua, account)
 */

.dnd-header-inner {
    flex-wrap: wrap;
    gap: .75rem 1rem;
}

.dnd-header-right {
    display: flex;
    align-items: center;
    gap: .75rem 1rem;
    margin-left: auto;
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
}

.dnd-utilities {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-shrink: 0;
}

/* Nasconde mod_login Joomla quando c'è la barra nativa */
body.dnd-logged-in .dnd-utilities .mod-login,
body.dnd-logged-in .dnd-utilities .mod-login-logout {
    display: none !important;
}

/* Language switch compatto */
.dnd-lang-switch__list {
    display: flex;
    gap: .35rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.dnd-lang-switch__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.1rem;
    padding: .35rem .55rem;
    border-radius: 8px;
    border: 1px solid rgba(201, 162, 39, .28);
    background: rgba(0, 0, 0, .25);
    color: #c4b896;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-decoration: none;
    transition: .15s;
}

.dnd-lang-switch__item:hover {
    border-color: rgba(201, 162, 39, .55);
    color: #f6e8b1;
    background: rgba(201, 162, 39, .1);
}

.dnd-lang-switch__item.is-active {
    border-color: #c9a227;
    background: rgba(201, 162, 39, .18);
    color: #f6e8b1;
}

/* User bar */
.dnd-userbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .35rem .65rem .35rem .35rem;
    border-radius: 999px;
    border: 1px solid rgba(201, 162, 39, .35);
    background: rgba(0, 0, 0, .28);
    color: #f3ead4;
    font-weight: 600;
    font-size: .88rem;
    cursor: pointer;
    transition: .15s;
}

.dnd-userbar-toggle:hover,
.dnd-userbar-toggle:focus,
.dnd-userbar-toggle.show {
    border-color: #c9a227;
    background: rgba(201, 162, 39, .12);
    color: #fff;
    box-shadow: none;
}

.dnd-userbar-toggle::after {
    margin-left: .15rem;
    opacity: .7;
}

.dnd-userbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(180deg, #9b1a1c, #7b1113);
    color: #fff;
    font-weight: 800;
    font-size: .9rem;
    box-shadow: 0 2px 10px rgba(123, 17, 19, .35);
}

.dnd-userbar-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dnd-userbar-menu {
    min-width: 240px;
    padding: .5rem;
    background: linear-gradient(180deg, #231812, #150f0c);
    border: 1px solid rgba(201, 162, 39, .35);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}

.dnd-userbar-menu-head {
    padding: .55rem .75rem .65rem;
    pointer-events: none;
}

.dnd-userbar-menu-title {
    display: block;
    color: #f6e8b1;
    font-weight: 700;
    font-size: .92rem;
}

.dnd-userbar-menu-sub {
    display: block;
    margin-top: .15rem;
    color: #a89878;
    font-size: .78rem;
}

.dnd-userbar-menu .dropdown-item {
    border-radius: 8px;
    color: #e8ddc4;
    font-weight: 600;
    padding: .55rem .75rem;
}

.dnd-userbar-menu .dropdown-item:hover,
.dnd-userbar-menu .dropdown-item:focus {
    background: rgba(201, 162, 39, .12);
    color: #f6e8b1;
}

.dnd-userbar-menu .dropdown-divider {
    border-color: rgba(201, 162, 39, .15);
    margin: .35rem 0;
}

.dnd-userbar-logout {
    color: #efb4b4 !important;
}

.dnd-userbar-logout:hover {
    background: rgba(123, 17, 19, .25) !important;
    color: #ffd6d6 !important;
}

/* Nasconde icone modifica modulo/menu in frontend (Modifica modulo / Lingua / Main Menu) */
.dnd-body .jmodedit,
.dnd-body .jmenuedit,
.dnd-body [role="tooltip"][id^="tip-"] {
    display: none !important;
}

/* Menu: nascondi login/registrazione per utenti loggati */
body.dnd-logged-in .dnd-nav a[href*="view=login"],
body.dnd-logged-in .dnd-nav a[href*="view=registration"],
body.dnd-logged-in .dnd-nav a[href*="login-en"],
body.dnd-logged-in .dnd-nav a[href*="register-en"] {
    display: none;
}

body.dnd-logged-in .dnd-nav li:has(> a[href*="view=login"]),
body.dnd-logged-in .dnd-nav li:has(> a[href*="view=registration"]),
body.dnd-logged-in .dnd-nav li:has(> a[href*="login-en"]),
body.dnd-logged-in .dnd-nav li:has(> a[href*="register-en"]) {
    display: none;
}

@media (max-width: 992px) {
    .dnd-header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .dnd-header-right {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
    }

    .dnd-utilities {
        justify-content: space-between;
        order: -1;
    }

    .dnd-nav ul {
        width: 100%;
    }

    .dnd-userbar-name {
        max-width: 100px;
    }
}

@media (max-width: 680px) {
    .dnd-userbar-name {
        display: none;
    }

    .dnd-userbar-toggle {
        padding: .35rem;
    }
}
