/* ===== FONT ===== */
html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background-color: #F4F8FC;
    font-size: 0.9375rem;
    color: #1E334C;
}

h1, h2, h3, h4, h5, h6,
.card-title, .card-header,
.nav-link, label, th {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* ===== LINK ===== */
a, .btn-link {
    color: #1E334C;
}

/* ===== BOTTONI — radius 20px su tutti ===== */
.btn {
    border-radius: 20px;
    padding: 0.375rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.btn-sm {
    border-radius: 16px;
    padding: 0.25rem 0.85rem;
    font-size: 0.8125rem;
}

.btn-lg {
    border-radius: 24px;
}

/* Primary — #1E334C */
.btn-primary {
    color: #fff;
    background-color: #1E334C;
    border-color: #172840;
}

.btn-primary:hover {
    background-color: #172840;
    border-color: #101d2e;
    color: #fff;
}

/* Danger — tenue (coral morbido invece di rosso acceso) */
.btn-danger {
    color: #fff;
    background-color: #C0614F;
    border-color: #B0513F;
}

.btn-danger:hover {
    background-color: #A8503E;
    border-color: #98402E;
    color: #fff;
}

/* Success — tenue (salvia invece di verde acceso) */
.btn-success {
    color: #fff;
    background-color: #5F9150;
    border-color: #508040;
}

.btn-success:hover {
    background-color: #508040;
    border-color: #407030;
    color: #fff;
}

/* Warning — ambra tenue */
.btn-warning {
    color: #fff;
    background-color: #C89540;
    border-color: #B88430;
}

.btn-warning:hover {
    background-color: #B88430;
    border-color: #A07020;
    color: #fff;
}

/* Secondary — grigio-blu tenue */
.btn-secondary {
    color: #fff;
    background-color: #5B7A9A;
    border-color: #4B6A8A;
}

.btn-secondary:hover {
    background-color: #4B6A8A;
    border-color: #3B5A7A;
    color: #fff;
}

/* Outline primary */
.btn-outline-primary {
    color: #1E334C;
    border-color: #1E334C;
}

.btn-outline-primary:hover {
    background-color: #1E334C;
    border-color: #1E334C;
    color: #fff;
}

/* Outline secondary */
.btn-outline-secondary {
    color: #5B7A9A;
    border-color: #5B7A9A;
}

.btn-outline-secondary:hover {
    background-color: #5B7A9A;
    border-color: #5B7A9A;
    color: #fff;
}

/* Focus ring unificato */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #B7D8FF;
    outline: none;
}

/* ===== CARD ===== */
.card {
    border: 1px solid #dceaf8;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(30, 51, 76, 0.06);
}

.card-header {
    background-color: #f7fafd;
    border-bottom: 1px solid #dceaf8;
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
    font-size: 0.875rem;
    color: #1E334C;
    padding: 0.75rem 1.25rem;
}

.card-body {
    padding: 1rem 1.25rem;
}

/* ===== FORM CONTROLS ===== */
.form-control, .form-select {
    border-color: #dceaf8;
    border-radius: 10px;
    font-size: 0.875rem;
    color: #1E334C;
}

.form-control:focus, .form-select:focus {
    border-color: #B7D8FF;
    color: #1E334C;
}

/* ===== TABELLE ===== */
.table thead th {
    color: #1E334C;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #dceaf8;
}

.table td {
    font-size: 0.875rem;
    vertical-align: middle;
}

/* ===== SPAZIATURA CONTENUTO ===== */
.content {
    padding-top: 1.5rem;
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

h1:focus {
    outline: none;
}

/* ===== VALIDAZIONE ===== */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #5F9150;
}

.invalid {
    outline: 1px solid #C0614F;
}

.validation-message {
    color: #C0614F;
    font-size: 0.8125rem;
}

/* ===== BADGES ===== */
.badge {
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.7em;
}

/* ===== BLAZOR ERROR ===== */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ===== MISC ===== */
.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT PRINCIPALE (MainLayout)
   ═══════════════════════════════════════════════════════════════════════════ */

.page {
    position: relative;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    background-color: #F4F8FC;
    overflow-x: hidden;
    min-width: 0;
}

.sidebar {
    background-color: #FFFFFF;
    border-right: 1px solid #E2E8F0;
}

.top-row {
    background-color: #ffffff;
    border-bottom: 1px solid #dceaf8;
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
    align-items: center;
}

.top-row a, .top-row .btn-link {
    white-space: nowrap;
    margin-left: 1.5rem;
    text-decoration: none;
}

.top-row a:hover, .top-row .btn-link:hover { text-decoration: underline; }

.top-row a:first-child { overflow: hidden; text-overflow: ellipsis; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 719.98px) {
    .top-row { justify-content: space-between; }
    .top-row a, .top-row .btn-link { margin-left: 0; }
}

@media (min-width: 720px) {
    .page { flex-direction: row; }

    .sidebar {
        width: 260px;
        height: 100vh;
        position: sticky;
        top: 0;
        flex-shrink: 0;
        overflow: hidden;
        transition: width 0.22s ease;
        will-change: width;
    }

    :root.sidebar-compact .sidebar { width: 72px; }

    .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .top-row.auth a:first-child {
        flex: 1;
        text-align: right;
        width: 0;
    }

    .top-row, article {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    article { padding-bottom: 2rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR — CSS Variables
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
    --sidebar-bg:         #ffffff;
    --sidebar-text:       #17345c;
    --sidebar-text-muted: #6f83a1;
    --sidebar-hover:      #f4f7fb;
    --sidebar-active-bg:  #edf4ff;
    --sidebar-active:     #1565d8;
    --sidebar-border:     #e4ebf3;
    --sidebar-line:       #dbe5f0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR — NavMenu
   Larghezze: estesa 260px | compatta 72px
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Header sidebar ─────────────────────────────────────────────────────────── */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 16px;
    height: 3.5rem;
    background: #F8FAFB;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

.sidebar-brand:hover { color: var(--sidebar-text); text-decoration: none; }
.sidebar-brand-accent { color: #246B9A; }
.sidebar-brand-full    { display: block; }
.sidebar-brand-compact { display: none; }

/* ── Toggle button ─────────────────────────────────────────────────────────── */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--sidebar-text-muted);
    cursor: pointer;
    padding: 7px 8px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    min-width: 32px;
    min-height: 32px;
}

.sidebar-toggle-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

/* ── Mobile hamburger ─────────────────────────────────────────────────────── */
.navbar-toggler {
    appearance: none;
    cursor: pointer;
    width: 3.25rem;
    height: 2.25rem;
    position: absolute;
    top: 0.625rem;
    right: 1rem;
    border: 1px solid var(--sidebar-border);
    border-radius: 6px;
    background:
        url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%231D2B3A' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")
        no-repeat center/1.5rem #FFFFFF;
    transition: background-color 0.15s;
}

.navbar-toggler:checked { background-color: var(--sidebar-hover); }

/* ── Scrollable nav area ──────────────────────────────────────────────────── */
.nav-scrollable { display: none; }
.navbar-toggler:checked ~ .nav-scrollable { display: block; }

@media (min-width: 720px) {
    .navbar-toggler { display: none; }

    .nav-scrollable {
        display: block;
        height: calc(100vh - 3.5rem);
        overflow-y: auto;
        overflow-x: hidden;
        padding: 8px 0 32px;
        scrollbar-width: thin;
        scrollbar-color: var(--sidebar-border) transparent;
    }

    .nav-scrollable::-webkit-scrollbar       { width: 4px; }
    .nav-scrollable::-webkit-scrollbar-track { background: transparent; }
    .nav-scrollable::-webkit-scrollbar-thumb { background: #D0DAE5; border-radius: 2px; }
}

/* ── Section labels ────────────────────────────────────────────────────────── */
.nav-section-item { padding: 0; margin-top: 20px; }
.nav-section-item:first-of-type { margin-top: 4px; }

.nav-section-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    color: var(--sidebar-text-muted);
    text-transform: uppercase;
    padding: 4px 18px 6px;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
}

/* ── Nav link content wrapper ─────────────────────────────────────────────── */
.nav-link-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

/* ── Nav icons ─────────────────────────────────────────────────────────────── */
.nav-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--sidebar-text-muted);
    transition: color 0.13s;
}

/* ── Nav label ─────────────────────────────────────────────────────────────── */
.nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: left;
}

/* ── Nav chevron ───────────────────────────────────────────────────────────── */
.nav-chevron {
    flex-shrink: 0;
    color: var(--sidebar-text-muted);
    opacity: 0.45;
    transition: transform 160ms ease, opacity 0.13s;
}

.nav-group-toggle[aria-expanded="true"] .nav-chevron {
    transform: rotate(90deg);
    opacity: 0.65;
}

/* ── Nav items (direct links) ─────────────────────────────────────────────── */
.nav-item { padding: 1px 8px; }

.nav-item .nav-link {
    color: var(--sidebar-text);
    background: none;
    border: none;
    border-radius: 8px;
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    width: 100%;
    text-decoration: none;
    transition: background 0.13s, color 0.13s;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
}

.nav-item .nav-link:hover { background: var(--sidebar-hover); }
.nav-item .nav-link:hover .nav-icon { color: var(--sidebar-text); }

.nav-item a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}
.nav-item a.active .nav-icon { color: var(--sidebar-active); }

.nav-item .nav-link:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: -2px;
}

/* ── Group toggle ──────────────────────────────────────────────────────────── */
.nav-group-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    border-radius: 8px;
    min-height: 42px;
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 10px;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
    font-family: inherit;
    font-size: 0.875rem;
}

.nav-group-toggle:hover { background: var(--sidebar-hover); }
.nav-group-toggle:hover .nav-icon { color: var(--sidebar-text); }

.nav-group-toggle[aria-expanded="true"] {
    font-weight: 600;
    color: var(--sidebar-text);
}

.nav-group-toggle:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: -2px;
}

/* ── Group wrap ────────────────────────────────────────────────────────────── */
.nav-group-wrap {
    position: relative;
    padding: 1px 8px;
}

/* Parent con figlio attivo (CSS :has) */
.nav-group-wrap:has(.nav-submenu-link.active) > .nav-group-toggle {
    font-weight: 600;
    color: var(--sidebar-text);
}
.nav-group-wrap:has(.nav-submenu-link.active) > .nav-group-toggle .nav-icon {
    color: var(--sidebar-text);
    opacity: 0.75;
}

/* ── Badge counter ─────────────────────────────────────────────────────────── */
.nav-badge {
    background: #C95245;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    line-height: 1.4;
    flex-shrink: 0;
}

/* ── Badge "Presto" ────────────────────────────────────────────────────────── */
.nav-badge-presto {
    font-size: 0.6rem;
    background: #e8eef5;
    color: var(--sidebar-text-muted);
    padding: 0.1em 0.55em;
    border-radius: 10px;
    margin-left: auto;
    flex-shrink: 0;
    font-weight: 600;
    white-space: nowrap;
}

/* ── Submenu inline ────────────────────────────────────────────────────────── */
.nav-submenu {
    position: relative;
    margin-left: 27px;
    padding: 2px 0 4px 14px;
    margin-bottom: 2px;
}

.nav-submenu::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 1.5px;
    background: var(--sidebar-line);
    border-radius: 1px;
}

/* Titolo sezione flyout (visibile solo in modalità compatta) */
.nav-submenu-title {
    display: none;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    padding: 8px 10px 6px;
    white-space: nowrap;
}

/* ── Submenu links ─────────────────────────────────────────────────────────── */
.nav-submenu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 7px;
    color: #4e647d;
    font-size: 0.845rem;
    font-weight: 450;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    overflow: hidden;
    background: none;
    border: none;
    width: 100%;
    font-family: inherit;
    text-align: left;
}

.nav-submenu-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-submenu-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

.nav-submenu-link:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: -2px;
}

/* Variante "in arrivo" */
.nav-submenu-link--coming {
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

/* Toggle annidato (Impostazioni dentro Profilo) */
.nav-submenu-toggle {
    justify-content: space-between;
}

/* ── Chevron piccolo per toggle annidato ───────────────────────────────────── */
.nav-chevron-sm {
    flex-shrink: 0;
    color: var(--sidebar-text-muted);
    opacity: 0.45;
    transition: transform 160ms ease;
}

.nav-chevron-sm.open { transform: rotate(90deg); opacity: 0.65; }

/* ── Sub-submenu (Impostazioni dentro Profilo) ─────────────────────────────── */
.nav-sub-submenu {
    padding: 0 0 2px 8px;
    border-left: 1.5px solid var(--sidebar-line);
    margin: 1px 0 1px 8px;
}

.nav-sub-submenu-link {
    display: flex;
    align-items: center;
    min-height: 33px;
    padding: 0 8px;
    border-radius: 6px;
    color: #5a7a9a;
    font-size: 0.81rem;
    font-weight: 450;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    background: none;
    width: 100%;
}

.nav-sub-submenu-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

.nav-sub-submenu-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

/* ── Separatore interno al submenu ────────────────────────────────────────── */
.nav-submenu-sep {
    height: 1px;
    background: var(--sidebar-border);
    margin: 4px 6px;
}

/* ── Tooltip in modalità compatta (data-nav-tip) ───────────────────────────── */
:root.sidebar-compact [data-nav-tip] { position: relative; }

:root.sidebar-compact [data-nav-tip]:hover::after {
    content: attr(data-nav-tip);
    position: fixed;
    left: 80px;
    background: #1D2B3A;
    color: #fff;
    font-size: 0.775rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 6px;
    z-index: 1300;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(23, 37, 54, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALITÀ COMPATTA  :root.sidebar-compact
   ═══════════════════════════════════════════════════════════════════════════ */

:root.sidebar-compact .sidebar-brand-full    { display: none; }
:root.sidebar-compact .sidebar-brand-compact { display: block; }

:root.sidebar-compact .nav-label        { display: none; }
:root.sidebar-compact .nav-section-item { display: none; }
:root.sidebar-compact .nav-chevron      { display: none; }
:root.sidebar-compact .nav-chevron-sm   { display: none; }
:root.sidebar-compact .nav-badge-presto { display: none; }
:root.sidebar-compact .nav-submenu-title { display: block; }

:root.sidebar-compact .nav-icon { color: var(--sidebar-text-muted); }

:root.sidebar-compact .nav-item       { padding: 1px 4px; position: relative; }
:root.sidebar-compact .nav-group-wrap { padding: 1px 4px; }

/* In compatto, il wrapper del contenuto non si espande */
:root.sidebar-compact .nav-link-content { flex: 0 0 auto; }

:root.sidebar-compact .nav-item .nav-link,
:root.sidebar-compact .nav-group-toggle {
    justify-content: center;
    padding: 0;
    min-height: 44px;
}

:root.sidebar-compact .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    margin-left: 0;
    min-width: 14px;
    font-size: 0.52rem;
    padding: 1px 3px;
    line-height: 1.35;
}

/* ── Flyout laterale in compatto ─────────────────────────────────────────── */
:root.sidebar-compact .nav-submenu {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.14s ease, visibility 0s 0.14s;
    position: fixed;
    left: 72px;
    z-index: 1200;
    background: #FFFFFF;
    min-width: 214px;
    border-radius: 0 10px 10px 0;
    box-shadow: 4px 0 20px rgba(23, 37, 54, 0.10);
    padding: 6px 6px 10px;
    border: 1px solid var(--sidebar-border);
    border-left: none;
    /* reset modalità normale */
    margin-left: 0;
    margin-bottom: 0;
}

:root.sidebar-compact .nav-submenu::before { display: none; }

:root.sidebar-compact .nav-group-wrap:hover .nav-submenu {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.14s ease, visibility 0s;
}

/* Label riabilitata dentro il flyout */
:root.sidebar-compact .nav-submenu .nav-label { display: block; }

:root.sidebar-compact .nav-submenu .nav-submenu-link {
    color: #4A5568;
    min-height: 38px;
    font-size: 0.875rem;
    padding: 0 12px;
    border-radius: 7px;
}

:root.sidebar-compact .nav-submenu .nav-submenu-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
}

:root.sidebar-compact .nav-submenu .nav-submenu-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

:root.sidebar-compact .nav-sub-submenu {
    margin-left: 4px;
    padding-left: 6px;
}

:root.sidebar-compact .nav-sub-submenu-link {
    color: #4A5568;
    font-size: 0.845rem;
    padding: 0 10px;
}

:root.sidebar-compact .nav-sub-submenu-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}


/* ═══════════════════════════════════════════════════════════════════════════
   BREADCRUMB UNIVERSALE — .page-bc
   Usato da tutte le pagine. Le varianti prefissate (sc-breadcrumb, sf-breadcrumb,
   ecc.) sono equivalenti e rimangono per retrocompatibilità.
   ═══════════════════════════════════════════════════════════════════════════ */

.page-bc {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
    font-size: 0.78rem;
    color: #5B7A9A;
}

.page-bc-item + .page-bc-item::before {
    content: '›';
    margin: 0 0.4rem;
    color: #b0c4d8;
}

.page-bc-item a { color: #5B7A9A; text-decoration: none; }
.page-bc-item a:hover { color: #1E334C; text-decoration: underline; }
.page-bc-item.active { color: #1E334C; font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════════════════
   NAV-TABS — override Bootstrap per stile underline uniforme
   Rende le tab coerenti con ws-tab-btn / aq-tab-btn / sf-tab-btn
   ═══════════════════════════════════════════════════════════════════════════ */

.nav-tabs {
    border-bottom: 2px solid #dceaf8;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: #B7D8FF transparent;
}

.nav-tabs::-webkit-scrollbar { height: 3px; }
.nav-tabs::-webkit-scrollbar-thumb { background: #B7D8FF; border-radius: 3px; }

.nav-tabs .nav-link {
    color: #5B7A9A;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.45rem 0.85rem;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 0 !important;
    margin-bottom: -2px;
    background: transparent !important;
    white-space: nowrap;
    transition: color 0.12s, border-color 0.12s;
}

.nav-tabs .nav-link:hover {
    color: #1E334C;
    border-bottom-color: #b5cfe8 !important;
    background: transparent !important;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: #1E334C !important;
    font-weight: 700;
    border-bottom: 2px solid #1E334C !important;
    background: transparent !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDE DRAWER
   ═══════════════════════════════════════════════════════════════════════════ */

.side-drawer__overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 29, 46, 0.45);
    z-index: 1040;
    animation: sd-fade-in 0.18s ease;
}

.side-drawer__panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 66.67%;
    max-width: 900px;
    background: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 32px rgba(16, 29, 46, 0.18);
    animation: sd-slide-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.side-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.1rem 1.25rem 1rem;
    border-bottom: 1px solid #dceaf8;
    flex-shrink: 0;
    background: #f7fafd;
}

.side-drawer__header-text { min-width: 0; flex: 1; }

.side-drawer__title {
    font-size: 1rem;
    font-weight: 700;
    color: #1E334C;
    line-height: 1.3;
}

.side-drawer__subtitle {
    font-size: 0.8rem;
    color: #5B7A9A;
    margin-top: 0.15rem;
}

.side-drawer__close {
    background: none;
    border: none;
    color: #5B7A9A;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    margin-left: 0.75rem;
    transition: background 0.12s, color 0.12s;
}

.side-drawer__close:hover { background: #e8f0fb; color: #1E334C; }

.side-drawer__unsaved-warn {
    background: #fff8e1;
    border-bottom: 1px solid #f0d060;
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    color: #7a5a00;
    flex-shrink: 0;
}

.side-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: #c8d8e8 transparent;
}

.side-drawer__body::-webkit-scrollbar       { width: 5px; }
.side-drawer__body::-webkit-scrollbar-track { background: transparent; }
.side-drawer__body::-webkit-scrollbar-thumb { background: #c8d8e8; border-radius: 3px; }

.side-drawer__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #dceaf8;
    background: #f7fafd;
    flex-shrink: 0;
    gap: 0.5rem;
}

@keyframes sd-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes sd-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

@media (max-width: 768px) {
    .side-drawer__panel {
        width: 100%;
        max-width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE ≤720px — Sizing globale per operatori di cantiere
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 719.98px) {
    html, body { font-size: 16px; }

    .form-control,
    .form-select {
        font-size: 1.0625rem;
        min-height: 48px;
    }

    label { font-size: 0.9375rem; }

    .btn { min-height: 44px; font-size: 1rem; }
    .btn-sm { min-height: 40px; font-size: 0.9375rem; }

    /* Evita scroll orizzontale */
    article, .content { overflow-x: hidden; }

    /* ── Nascondi sidebar desktop su mobile ─────────────────────────────── */
    .sidebar { display: none !important; }

    /* ── Nascondi workspace (login/profilo) nell'header desktop su mobile ── */
    .hdr-workspace-area { display: none !important; }

    /* ── Notifiche panel: adattato alla larghezza mobile ────────────────── */
    .notif-panel {
        width: calc(100vw - 24px);
        right: -4px;
    }

    /* ── Padding bottom main per lasciare spazio alla bottom nav fissa ──── */
    main { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 16px); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE HEADER (mob-top-bar) — visibile solo sotto 720px
   ═══════════════════════════════════════════════════════════════════════════ */

.mob-top-bar {
    display: none;
}

@media (max-width: 719.98px) {
    .mob-top-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 56px;
        padding: 0 16px;
        background: #ffffff;
        border-bottom: 1px solid #dceaf8;
        position: sticky;
        top: 0;
        z-index: 300;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }
}

.mob-top-bar-logo {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #1D2B3A;
    text-decoration: none;
    letter-spacing: 0.02em;
    line-height: 1;
}

.mob-top-bar-logo:hover { color: #1D2B3A; text-decoration: none; }

.mob-top-bar-logo-accent { color: #246B9A; }

.mob-top-bar-hamburger {
    background: none;
    border: none;
    cursor: pointer;
    color: #1D2B3A;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.mob-top-bar-hamburger:active { background: #f0f5fb; }

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE DRAWER — mob-drawer-*
   Aperto da sinistra, overlay scuro, chiusura via X / click esterno
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Body lock ──────────────────────────────────────────────────────────────── */
body.mob-drawer-open {
    overflow: hidden;
}

/* ── Overlay ─────────────────────────────────────────────────────────────────── */
.mob-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 29, 46, 0.52);
    z-index: 1050;
    animation: mob-overlay-fadein 0.2s ease;
}

@keyframes mob-overlay-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Pannello ────────────────────────────────────────────────────────────────── */
.mob-drawer-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 340px;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 40px rgba(16, 29, 46, 0.2);
    animation: mob-drawer-slidein 0.25s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow: hidden;
}

@keyframes mob-drawer-slidein {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

/* ── Header del drawer ───────────────────────────────────────────────────────── */
.mob-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 1px solid #edf2f7;
    background: #f7fafd;
    flex-shrink: 0;
    gap: 8px;
}

.mob-drawer-brand-area {
    flex: 1;
    min-width: 0;
}

.mob-drawer-logo {
    display: block;
    font-size: 1.0625rem;
    font-weight: 700;
    color: #1D2B3A;
    text-decoration: none;
    letter-spacing: 0.02em;
    line-height: 1;
    margin-bottom: 6px;
}

.mob-drawer-logo:hover { color: #1D2B3A; text-decoration: none; }
.mob-drawer-logo-accent { color: #246B9A; }

.mob-drawer-company {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #1E334C;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mob-drawer-email {
    font-size: 0.72rem;
    color: #6B7C8F;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mob-drawer-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6B7C8F;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
    -webkit-tap-highlight-color: transparent;
}

.mob-drawer-close-btn:active { background: #e8f0fb; color: #1E334C; }

/* ── Corpo scrollabile ───────────────────────────────────────────────────────── */
.mob-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: #dce8f5 transparent;
}

.mob-drawer-body::-webkit-scrollbar       { width: 3px; }
.mob-drawer-body::-webkit-scrollbar-track { background: transparent; }
.mob-drawer-body::-webkit-scrollbar-thumb { background: #dce8f5; border-radius: 2px; }

/* ── Etichetta sezione ───────────────────────────────────────────────────────── */
.mob-drawer-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #B0BCCA;
    text-transform: uppercase;
    padding: 14px 20px 4px;
    pointer-events: none;
}

/* ── Voce di menu di primo livello ──────────────────────────────────────────── */
.mob-drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 0 20px;
    height: 48px;
    min-height: 48px;
    color: #2D4059;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.mob-drawer-item:active,
.mob-drawer-item:hover {
    background: #f0f5fb;
    color: #1E334C;
    text-decoration: none;
}

.mob-drawer-item.active {
    background: #EAF2FF;
    color: #246B9A;
    font-weight: 600;
    text-decoration: none;
}

/* ── Gruppo con accordion ────────────────────────────────────────────────────── */
.mob-drawer-group { }

.mob-drawer-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 0 20px;
    height: 48px;
    min-height: 48px;
    color: #2D4059;
    font-size: 0.9375rem;
    font-weight: 500;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    text-align: left;
}

.mob-drawer-group-toggle:active { background: #f0f5fb; }

.mob-drawer-chevron {
    margin-left: auto;
    font-size: 0.55rem;
    color: #9BAABB;
    transition: transform 0.2s ease;
    display: inline-block;
    line-height: 1;
    flex-shrink: 0;
}

.mob-drawer-chevron.open { transform: rotate(180deg); }

/* ── Badge numerico ──────────────────────────────────────────────────────────── */
.mob-drawer-badge {
    background: #C95245;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    line-height: 1.4;
    flex-shrink: 0;
}

/* ── Sottomenu ───────────────────────────────────────────────────────────────── */
.mob-drawer-submenu {
    padding: 4px 0 8px 52px;
    background: #fafcfe;
    border-bottom: 1px solid #f0f5fb;
}

.mob-drawer-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px 0 0;
    height: 44px;
    min-height: 44px;
    color: #5B7A9A;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: background 0.1s;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    font-family: inherit;
}

.mob-drawer-subitem:active,
.mob-drawer-subitem:hover {
    color: #1E334C;
    text-decoration: none;
}

.mob-drawer-subitem.active {
    color: #246B9A;
    font-weight: 600;
    text-decoration: none;
}

/* ── Footer: Profilo + Logout ───────────────────────────────────────────────── */
.mob-drawer-footer {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #edf2f7;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    background: #f7fafd;
}

.mob-drawer-footer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px 0 20px;
    height: 48px;
    min-height: 48px;
    color: #2D4059;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: none;
    width: 100%;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.mob-drawer-footer-item:active,
.mob-drawer-footer-item:hover {
    background: #f0f5fb;
    color: #1E334C;
    text-decoration: none;
}

.mob-drawer-footer-item.active {
    background: #EAF2FF;
    color: #246B9A;
    font-weight: 600;
}

.mob-drawer-footer-item--logout {
    color: #C0614F !important;
}

.mob-drawer-footer-item--logout:active,
.mob-drawer-footer-item--logout:hover {
    background: #fff5f4 !important;
    color: #A0513F !important;
    text-decoration: none;
}
