/* ==========================================================================
   Header - Sanzioni.cloud
   Strato visivo sopra la struttura Bootstrap Italia di views/layouts/main.php
   (it-header-wrapper). Regole limitate a .app-header; caricato dopo
   bootstrap-italia (AppAsset). Palette Bootstrap Italia, nessun accento arancio.
   ========================================================================== */

.app-header {
    --hd-primary: #0066cc;
    --hd-primary-strong: #004d99;
    --hd-slim: #003d7a;
    --hd-on-dark-muted: rgba(255, 255, 255, 0.78);
    --hd-glass: rgba(255, 255, 255, 0.1);
    --hd-glass-hover: rgba(255, 255, 255, 0.16);
    --hd-glass-border: rgba(255, 255, 255, 0.16);

    /* Non ridefinire position/z-index: resta il livello di Bootstrap Italia
       (z-index 5), sotto le tendine del contenuto (z-index 8). Un valore piu
       alto farebbe finire sotto l'header le tendine che si aprono verso l'alto. */
    box-shadow: 0 6px 20px rgba(0, 51, 102, 0.16);
}

/* ---------- Fascia superiore (ente, APP/Esci, lingua, utente) ---------- */

.app-header .it-header-slim-wrapper {
    background: var(--hd-slim);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-header .it-header-slim-wrapper .it-header-slim-wrapper-content .app-header__ente-zone {
    display: flex;
    align-items: center;
    align-self: stretch;
    min-width: 0;
    margin-right: 0.75rem;
}

.app-header .it-header-slim-wrapper .it-opener,
.app-header .it-header-slim-wrapper .it-opener span {
    text-decoration: none;
}

@media (max-width: 575.98px) {
    .app-header__ente-name,
    .app-header__ente .login-ente-name {
        max-width: 34vw;
    }
}

.app-header__ente {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    color: #ffffff;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}

.app-header__ente .fas {
    flex: 0 0 auto;
    color: var(--hd-on-dark-muted);
    font-size: 0.8rem;
}

.app-header__ente-name {
    overflow: hidden;
    max-width: 38vw;
    text-overflow: ellipsis;
    text-transform: capitalize;
    white-space: nowrap;
}

.app-header__ente .login-ente-name {
    font-weight: 600;
    text-align: left;
}

/* Bootstrap Italia colora .nav-link in blu scuro al focus/hover: sulla fascia scura resta bianco */
.app-header .it-header-slim-wrapper .it-header-slim-right-zone > .nav-item > .nav-link,
.app-header .it-header-slim-wrapper .it-header-slim-right-zone > .nav-item > .nav-link:hover,
.app-header .it-header-slim-wrapper .it-header-slim-right-zone > .nav-item > .nav-link:focus {
    color: #ffffff;
    text-decoration: none;
}

.app-header .it-header-slim-wrapper .nav-item.show > .nav-link,
.app-header .it-header-slim-wrapper .it-header-slim-right-zone > .nav-item > .nav-link:hover {
    background: var(--hd-glass);
}

.app-header .it-header-slim-wrapper .dropdown-menu {
    overflow: hidden;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 38, 77, 0.2);
}

.app-header .app-header__slim-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 600;
    text-decoration: none;
}

.app-header .app-header__slim-link .fas {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* chip utente */
.app-header .it-header-slim-wrapper .it-header-slim-wrapper-content .it-header-slim-right-zone .app-header__user {
    gap: 0.6rem;
    background: var(--hd-glass);
    border-left: 1px solid var(--hd-glass-border);
    box-shadow: none;
    transition: background-color 0.15s ease;
}

.app-header .it-header-slim-wrapper .it-header-slim-wrapper-content .it-header-slim-right-zone .app-header__user:hover {
    background: var(--hd-glass-hover);
}

.app-header .app-header__user .rounded-icon {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.app-header__user-text {
    min-width: 0;
    line-height: 1.2;
    text-align: left;
}

.app-header__user-name,
.app-header__user-role {
    display: block;
    overflow: hidden;
    max-width: 16rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header__user-name {
    color: #ffffff;
    font-size: 0.8125rem;
    font-weight: 700;
}

.app-header__user-role {
    margin-top: 0.1rem;
    color: var(--hd-on-dark-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

/* pulsante "Accedi" (ospite): stesso linguaggio del chip utente */
.app-header .it-header-slim-wrapper .it-header-slim-wrapper-content .it-header-slim-right-zone .it-access-top-wrapper .btn {
    background: var(--hd-glass);
    border-left: 1px solid var(--hd-glass-border);
    box-shadow: none;
    font-weight: 700;
    transition: background-color 0.15s ease;
}

.app-header .it-header-slim-wrapper .it-header-slim-wrapper-content .it-header-slim-right-zone .it-access-top-wrapper .btn:hover {
    background: var(--hd-glass-hover);
}

/* ---------- Fascia centrale (marchio e aree di lavoro) ---------- */

.app-header .it-header-center-wrapper {
    background:
        radial-gradient(40% 140% at 88% 0%, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0) 70%),
        linear-gradient(120deg, var(--hd-primary) 0%, #0059b3 60%, var(--hd-primary-strong) 100%);
}

.app-header .it-brand-wrapper a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.app-header .app-header__logo {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin-right: 0.85rem;
    transition: transform 0.2s ease;
}

.app-header .it-brand-wrapper a:hover .app-header__logo {
    transform: translateY(-1px);
}

.app-header .it-brand-wrapper .it-brand-text h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

.app-header__brand-tld {
    margin-left: 1px;
    font-size: 0.55em;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.8;
}

.app-header .it-brand-wrapper .it-brand-text h3 {
    margin: 0.2rem 0 0;
    color: var(--hd-on-dark-muted);
    font-size: 0.875rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

/* selettore area: controllo segmentato */
.app-header__areas ul {
    display: flex;
    gap: 0.25rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: rgba(0, 38, 77, 0.28);
    border: 1px solid var(--hd-glass-border);
    border-radius: 999px;
}

.app-header .app-header__area {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.95rem;
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-header .app-header__area .fas {
    font-size: 0.8rem;
    opacity: 0.85;
}

.app-header .app-header__area:hover {
    color: #ffffff;
    text-decoration: none;
    background: var(--hd-glass-hover);
}

.app-header .app-header__area.is-active {
    color: var(--hd-primary-strong);
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 38, 77, 0.2);
}

.app-header .app-header__area.is-active .fas {
    opacity: 1;
}

/* tablet: marchio e selettore devono stare sulla stessa riga */
@media (min-width: 768px) and (max-width: 991.98px) {
    .app-header .it-brand-wrapper .it-brand-text h3 {
        display: none !important;
    }

    .app-header .app-header__area {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }

    .app-header .app-header__area .fas {
        display: none;
    }
}

/* ---------- Focus ----------
   Bootstrap Italia evidenzia ogni :focus con !important (il suo JS che lo
   rimuove al clic non e caricato): qui lo si toglie solo per il focus da
   mouse; da tastiera resta l'anello standard del design system. */
.app-header a:focus:not(:focus-visible),
.app-header button:focus:not(:focus-visible) {
    box-shadow: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .app-header * {
        transition: none !important;
    }
}
