/* Compact page header (ADR-0072 amendment 2026-10-06): shared by every page that renders <PageHeader Compact>.
   Global (not scoped) on purpose: the row, the panels and the chips are filled by the PAGE through slots, so their markup
   carries the page's scope id, not the component's (skill blazor-scoped-css-class-on-child-component-needs-deep).
   Visual language = the `.pl-*` panels of «Risorse e commesse» (people-load-compact mock), under the neutral prefix `ph-`.
   One breakpoint: 600 px, written as a plain @media (max-width: 599.98px) — never MudHidden (skill mudhidden-breakpoint-exact-not-andup).
   Touch targets are 48 px under the breakpoint, 36 px above it. */

.ph { position: relative; margin: 0 0 8px; }
.ph-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 44px; min-width: 0; }

/* ── title block (desktop; on a phone the title lives in the app bar) ── */
.ph-title { display: flex; align-items: center; gap: 8px; min-width: 0; position: relative; }
.ph-area-chip { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; }
.ph-crumb { display: inline-flex; align-items: center; gap: 6px; font-size: .875rem; color: #64748b; text-decoration: none; }
.ph-crumb:hover { text-decoration: underline; }
.ph-sep { color: #94a3b8; }
.ph-h { margin: 0; font-size: 1.125rem; font-weight: 600; line-height: 1.3; color: #0f172a; white-space: nowrap; }
.ph-h:focus { outline: none; } /* MudBlazor's FocusOnNavigate focuses the first h1 after navigation: keep it for screen readers, hide the ring */
.ph-info {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0;
    border-radius: 50%; background: transparent; color: #64748b; cursor: pointer;
}
.ph-info:hover { background: #f1f5f9; }

/* ── triggers (panels and chip-panels) ── */
.ph-panels { display: contents; }
.ph-anchor { position: relative; flex: 0 0 auto; }
.ph-trigger {
    display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #cbd5e1;
    background: #fff; color: #334155; font: inherit; font-size: .875rem; cursor: pointer; white-space: nowrap;
}
.ph-trigger:hover:not(:disabled) { background: #f8fafc; }
.ph-trigger.open { box-shadow: 0 0 0 2px #818cf8; }
.ph-trigger.warn { border-color: #fcd34d; background: #fffbeb; color: #78350f; }
.ph-trigger:focus-visible, .ph-chip:focus-visible, .ph-chip-x:focus-visible, .ph-info:focus-visible, .ph-fab:focus-visible,
.ph-bar button:focus-visible { outline: 3px solid #0f172a; outline-offset: 1px; }
.ph-caret { display: inline-block; width: 1em; text-align: center; color: #64748b; }
.ph-badge {
    display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: #4f46e5; color: #fff; font-size: .75rem; font-weight: 600; line-height: 1;
}

/* ── active filters as removable chips ── */
.ph-chips { display: contents; }
.ph-chip {
    display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 12px; border-radius: 999px; background: #e0e7ff;
    color: #3730a3; font-size: .8125rem; white-space: nowrap;
}
.ph-chip-x {
    width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
}
.ph-chip-x:hover { background: rgba(79,70,229,.15); }

.ph-grow { flex: 1 1 auto; }
.ph-meta { font-size: .8125rem; color: #64748b; white-space: nowrap; }
.ph-actions { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ── pop-up panels (one element per panel, anchored to its trigger) ── */
.ph-pop {
    position: absolute; z-index: 1000; top: 100%; left: 0; width: 380px; max-width: calc(100vw - 32px); max-height: 60vh; overflow: auto;
    margin-top: 4px; padding: 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.2);
}
.ph-pop[hidden] { display: none; }
.ph-pop-info { width: 340px; font-size: .875rem; color: #334155; }
.ph-grp { margin: 0 0 12px; }
.ph-grp:last-child { margin-bottom: 0; }
.ph-grp > h4 { margin: 0 0 6px; font-size: .75rem; font-weight: 600; color: #475569; }
.ph-tc { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-tchip {
    display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff;
    color: #334155; font: inherit; font-size: .875rem; cursor: pointer;
}
.ph-tchip[aria-pressed="true"] { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 500; }
.ph-tchip:hover:not(:disabled):not([aria-pressed="true"]) { background: #f8fafc; }
.ph-tchip:disabled { opacity: .55; cursor: default; }
.ph-btn2 {
    display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid #cbd5e1;
    background: #fff; color: #0f172a; font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
}
.ph-btn2:disabled { opacity: .55; cursor: default; }
.ph-note { margin: 6px 0 0; font-size: .6875rem; color: #64748b; }
.ph-fld { width: 100%; height: 36px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 0 12px; font: inherit; font-size: .875rem; background: #fff; color: #0f172a; }

.ph-backdrop { position: fixed; inset: 0; z-index: 999; background: transparent; }
/* WHY: the triggers sit above the click-outside backdrop, so one click switches from a panel to another (same scheme as .pl-anchor). */
.ph-anchor, .ph-title { z-index: 1001; }
.ph-sheet-hd, .ph-sheet-ft, .ph-sheet-sh { display: none; }
.ph-sheet-body { display: contents; }

/* phone-only parts are hidden from 600 px up */
.ph-bar, .ph-fab { display: none; }

/* ═══ phone: title in the app bar, filters in a bottom sheet, chips in their own row ═══ */
@media (max-width: 599.98px) {
    .ph { margin-bottom: 8px; }
    .ph-row { display: contents; }
    .ph-meta, .ph-actions, .ph-grow { display: none; }
    /* the title block disappears but its info pop-up (a child) must stay reachable from the app bar's ⓘ */
    .ph-title { display: contents; }
    .ph-title > :not(.ph-pop-info) { display: none; }
    /* chips row: visible only when it holds something, so a page without chips costs no vertical space */
    .ph-chips { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; min-height: 48px; overflow-x: auto; scrollbar-width: none; }
    .ph-chips::-webkit-scrollbar { display: none; }
    .ph-chips:not(:has(.ph-chip, .ph-trigger)) { display: none; }
    .ph-chips > * { flex: 0 0 auto; }
    .ph-chip { height: 40px; }
    .ph-chip-x { width: 40px; height: 40px; }
    .ph-trigger { height: 48px; } /* ≥48 px touch target (TouchTargetAuditSpec flagged the 40 px «Legenda» chip on /scheduling/calendar) */
    /* chip-panels (the alert) open under the app bar, full width */
    .ph-chips .ph-anchor { position: static; }
    .ph-chips .ph-pop { position: fixed; top: 60px; left: 8px; right: 8px; width: auto; max-width: none; z-index: 1250; }
    .ph-pop-info { position: fixed; top: 60px; left: 8px; right: 8px; width: auto; max-width: none; z-index: 1250; }

    /* the bottom sheet: the SAME panels, restacked. Closed = not displayed; open = fixed to the bottom. */
    .ph-panels { display: none; }
    .ph-panels.ph-sheet-open {
        display: flex; flex-direction: column; position: fixed; z-index: 1250; left: 0; right: 0; bottom: 0; max-height: 85vh;
        background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 24px rgba(15,23,42,.25);
    }
    .ph-panels.ph-sheet-open .ph-sheet-hd {
        display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid #e2e8f0; font-weight: 600;
    }
    .ph-panels.ph-sheet-open .ph-sheet-body { display: block; overflow-y: auto; padding: 12px 16px; flex: 1 1 auto; }
    .ph-panels.ph-sheet-open .ph-sheet-ft { display: flex; gap: 8px; padding: 8px 16px; border-top: 1px solid #e2e8f0; }
    .ph-panels.ph-sheet-open .ph-sheet-sh { display: block; margin: 8px 0 6px; font-size: .8125rem; font-weight: 600; color: #334155; }
    .ph-panels.ph-sheet-open .ph-anchor { position: static; }
    .ph-panels.ph-sheet-open .ph-anchor > .ph-trigger { display: none; }
    .ph-panels.ph-sheet-open .ph-pop {
        position: static; display: block !important; /* beats MudBlazor's [hidden]{display:none!important}: in the sheet every panel is shown */ width: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; overflow: visible;
    }
    .ph-sheet-backdrop { position: fixed; inset: 0; z-index: 1240; background: rgba(15,23,42,.4); }
    .ph-backdrop { z-index: 1240; }
    .ph-tchip, .ph-btn2, .ph-fld { min-height: 48px; height: auto; }
    .ph-sheet-btn { min-height: 48px; padding: 0 16px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; font: inherit; font-weight: 500; cursor: pointer; }
    .ph-sheet-btn.p { background: #4f46e5; border-color: #4f46e5; color: #fff; flex: 1 1 auto; }

    /* ── app bar content (rendered by the page into MainLayout's SectionOutlet) ── */
    .ph-bar { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; gap: 2px; color: #fff; }
    .ph-bar button, .ph-bar a { color: inherit; }
    .ph-bar-title {
        display: flex; flex-direction: column; align-items: flex-start; justify-content: center; flex: 1 1 auto; min-width: 0; min-height: 48px;
        padding: 0 4px; border: 0; background: transparent; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
    }
    .ph-bar-title small { font-size: .6875rem; opacity: .85; line-height: 1.1; }
    .ph-bar-title b { font-size: 1rem; font-weight: 600; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .ph-bar-btn {
        display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 48px; min-height: 48px; padding: 0 8px; border: 0;
        background: transparent; font: inherit; font-size: .875rem; cursor: pointer; border-radius: 8px;
    }
    .ph-bar-btn .ph-badge { background: #fff; color: #4f46e5; }

    .ph-fab {
        display: inline-flex; align-items: center; justify-content: center; position: fixed; z-index: 1100; right: 16px; bottom: 16px; width: 56px; height: 56px;
        border: 0; border-radius: 50%; background: #4f46e5; color: #fff; box-shadow: 0 6px 16px rgba(15,23,42,.35); cursor: pointer;
    }
}
