/* Fondix MudBlazor overrides — mockup chrome + tokens */

/* ─── Global body + Typography ─── */
html, body, .mud-typography {
  font-family: var(--fx-font-body);
  color: var(--fx-ink);
  background: var(--fx-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mud-typography-h1, .mud-typography-h2 {
  font-family: var(--fx-font-display);
  font-weight: 400;
  letter-spacing: -0.025em;
}

.mud-typography-h3, .mud-typography-h4,
.mud-typography-h5, .mud-typography-h6 {
  font-family: var(--fx-font-body);
  font-weight: 600;
}

.mud-typography-button {
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ─── AppBar: full-bleed toolbar aligned to the page, not the mockup in-flow header ─── */
.mud-appbar.fx-appbar,
.mud-appbar.mud-appbar-fixed-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  min-height: 3.4rem;
  padding: 0;
  background: color-mix(in oklch, var(--fx-surface) 88%, transparent) !important;
  color: var(--fx-ink) !important;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--fx-border);
  box-shadow: none !important;
}

.mud-appbar.fx-appbar .mud-toolbar {
  width: 100%;
  min-height: 3.4rem;
  height: 3.4rem;
  padding-inline: clamp(1rem, 2.4vw, 2rem);
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow: visible;
}

.app-avatar-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.app-avatar-trigger:focus-visible {
  outline: none;
  box-shadow: var(--fx-focus-ring);
}

.fx-appbar__meta,
.fx-appbar__actions {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.fx-appbar__meta {
  gap: 0.45rem;
  padding-right: 0.7rem;
  margin-right: 0.1rem;
  border-right: 1px solid var(--fx-border);
}

.fx-appbar__actions {
  gap: 0.2rem;
}

.mud-appbar.fx-appbar .mud-spacer {
  flex: 1 1 auto;
  min-width: 1rem;
}

.mud-appbar.fx-appbar .fx-clock {
  min-height: 0;
  padding-inline: 0.15rem;
}

.mud-appbar.fx-appbar .mud-icon-button,
.mud-appbar.fx-appbar .mud-button-root.mud-icon-button,
.mud-appbar.fx-appbar [data-fx-tour="help-button"] .mud-button-root {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 999px;
  color: var(--fx-navy) !important;
  background: transparent;
}

.mud-appbar.fx-appbar .mud-icon-button:hover,
.mud-appbar.fx-appbar [data-fx-tour="help-button"] .mud-button-root:hover {
  background: var(--fx-primary-subtle) !important;
  color: var(--fx-primary) !important;
}

.mud-appbar.fx-appbar .app-avatar.mud-avatar {
  width: 44px;
  height: 44px;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--fx-navy) !important;
  color: var(--fx-on-navy) !important;
}

.mud-appbar.fx-appbar .app-avatar.mud-avatar:hover {
  background: var(--fx-navy-hover) !important;
}

.fx-app-context {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
  margin-left: 0;
  margin-right: 0;
}
.fx-app-context span {
  font-family: var(--fx-font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--fx-ink-muted);
}
.fx-app-context strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--fx-ink);
}

/* ─── Drawer / Sidebar (app-rail) ─── */
.mud-drawer {
  background: var(--fx-sidebar-bg) !important;
  border-right: 1px solid var(--fx-border) !important;
  box-shadow: none !important;
}

.mud-drawer.app-rail {
  --fx-rail-pad-x: 0.8rem;
  position: fixed !important;
  top: 0 !important;
  bottom: 0 !important;
  height: 100dvh !important;
  max-height: 100dvh;
  padding: max(5px, env(safe-area-inset-top)) var(--fx-rail-pad-x) 1.2rem;
  overflow: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  scrollbar-color: var(--fx-border-strong) transparent;
}

.mud-main-content.app-main {
  display: block;
  min-height: 0;
}

.mud-main-content.app-main.mud-main-content {
  padding-top: 3.4rem;
}

.fx-rail-brand {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  margin: 0 calc(var(--fx-rail-pad-x, 0.8rem) * -1) 0.35rem;
  padding: 0 var(--fx-rail-pad-x, 0.8rem) 0.55rem;
  border-bottom: 1px solid var(--fx-border);
}

.fx-rail-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
}

.mud-drawer.app-rail .app-rail-tools {
  position: static;
  z-index: auto;
  background: transparent;
  padding: 0;
}

.fx-rail-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fx-navy);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.fx-rail-toggle:hover {
  background: var(--fx-primary-subtle);
}

.fx-rail-toggle:active {
  background: var(--fx-sidebar-active);
}

.fx-rail-toggle:focus-visible {
  outline: none;
  box-shadow: var(--fx-focus-ring);
}

.fx-rail-mini {
  display: none;
}

@media (min-width: 960px) {
  .app.fx-rail-open .mud-appbar.fx-appbar,
  .app.fx-rail-open .mud-appbar.mud-appbar-fixed-top {
    left: 14rem;
    right: 0;
    width: auto;
    margin-left: 0;
  }

  .app.fx-rail-collapsed .mud-appbar.fx-appbar,
  .app.fx-rail-collapsed .mud-appbar.mud-appbar-fixed-top {
    left: 3.25rem;
    right: 0;
    width: auto;
    margin-left: 0;
  }

  .app.fx-rail-collapsed .mud-main-content.app-main {
    padding-left: 3.25rem;
  }

  .app.fx-rail-collapsed .fx-rail-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3.25rem;
    padding: max(5px, env(safe-area-inset-top)) 0 1rem;
    background: var(--fx-sidebar-bg);
    border-right: 1px solid var(--fx-border);
    z-index: var(--mud-zindex-drawer);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mud-drawer.app-rail {
    transition: none;
  }
}

@media (min-width: 1280px) {
  .app.is-drawer-open.fx-rail-open .mud-appbar.fx-appbar,
  .app.is-drawer-open.fx-rail-collapsed .mud-appbar.fx-appbar {
    right: 20rem;
    margin-left: 0;
  }
}

.fx-rail-menu {
  padding: 0 0 1.2rem;
}

.app-rail-group .app-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.app-rail-group .mud-nav-item {
  margin: 0;
}

.app-rail-group .mud-nav-item .mud-nav-link {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.dock {
  z-index: 1200;
}

@media (max-width: 900px) {
  .fx-float-act-btn {
    bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }

  .fx-appbar__meta {
    border-right: 0;
    padding-right: 0;
    margin-right: 0;
    gap: 0.25rem;
  }

  .mud-appbar.fx-appbar .mud-toolbar {
    padding-inline: 0.55rem 0.7rem;
    gap: 0.25rem;
  }
}

.app .drawer-edge {
  writing-mode: vertical-rl;
}

.app-panel-btn {
  max-width: 14rem;
  min-width: 0;
  flex-shrink: 1;
}

.app-panel-btn > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-rail-group .mud-nav-item .mud-nav-link {
  margin-left: 0;
  margin-right: 0;
}

.fx-nav-section {
  font-family: var(--fx-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fx-ink-muted);
  padding: 1.1rem 0.7rem 0.45rem;
  margin: 0;
  user-select: none;
}

.fx-nav-section:first-child {
  padding-top: 0.35rem;
}

.mud-nav-item .mud-nav-link {
  border-radius: 9px !important;
  margin: 0.05rem 0.35rem;
  padding: 0 0.7rem !important;
  min-height: 44px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fx-ink);
  transition: background var(--fx-duration) var(--fx-ease-out),
              color var(--fx-duration) var(--fx-ease-out);
}

.mud-nav-item .mud-nav-link:hover {
  background: var(--fx-primary-subtle) !important;
  color: var(--fx-primary);
}

.mud-nav-item .mud-nav-link.active,
.app-nav .mud-nav-link.active,
.app-nav a[aria-current="page"] {
  background: var(--fx-sidebar-active) !important;
  color: var(--fx-navy) !important;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--fx-border-strong);
}

.mud-nav-item .mud-nav-link .mud-nav-link-icon {
  font-size: 1.125rem;
  margin-right: 0.625rem;
  opacity: 0.7;
}

.mud-nav-item .mud-nav-link.active .mud-nav-link-icon {
  opacity: 1;
}

.mud-main-content {
  background: var(--fx-bg);
}

.fx-app-page {
  max-width: 74rem;
  padding: 1.1rem clamp(1rem, 2.4vw, 2rem) 4rem;
}

.mud-main-content h1,
.mud-main-content .mud-typography-h3,
.mud-main-content .mud-typography-h4 {
  font-family: var(--fx-font-display);
  font-weight: 400;
  letter-spacing: -0.03em;
}

/* Badge counters on nav */
.fx-nav-badge {
  font-size: 0.625rem;
  font-weight: 600;
  background: var(--fx-error);
  color: white;
  border-radius: 100px;
  padding: 0.1rem 0.4rem;
  margin-left: auto;
  min-width: 1.25rem;
  text-align: center;
  line-height: 1.3;
}

/* ─── Cards / Paper ─── */
.mud-paper {
  border: 1px solid var(--fx-border);
  box-shadow: var(--fx-shadow-xs) !important;
  border-radius: var(--fx-radius-md) !important;
}

.mud-paper.mud-elevation-0 {
  box-shadow: none !important;
}

/* ─── KPI cards ─── */
.fx-kpi-card {
  padding: 1.25rem 1.5rem;
  border-radius: var(--fx-radius-lg);
  border: none;
  position: relative;
  overflow: hidden;
}

.fx-kpi-card .fx-kpi-number {
  font-family: var(--fx-font-body);
  font-size: var(--fx-text-3xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--fx-ink);
}

.fx-kpi-card .fx-kpi-label {
  font-size: var(--fx-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fx-ink-muted);
  margin-top: 0.375rem;
}

.fx-kpi-card .fx-kpi-sub {
  font-size: var(--fx-text-sm);
  color: var(--fx-ink-secondary);
  margin-top: 0.25rem;
}

/* KPI tint variants */
.fx-kpi-card--green  { background: var(--fx-kpi-tint-1); }
.fx-kpi-card--blue   { background: var(--fx-kpi-tint-2); }
.fx-kpi-card--amber  { background: var(--fx-kpi-tint-3); }
.fx-kpi-card--coral  { background: var(--fx-kpi-tint-4); }

/* ─── Page greeting (serif, like "Buongiorno, Maria.") ─── */
.fx-greeting {
  font-family: var(--fx-font-display);
  font-size: var(--fx-text-3xl);
  font-weight: 400;
  color: var(--fx-ink);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.fx-greeting-sub {
  font-size: var(--fx-text-sm);
  color: var(--fx-ink-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 500;
}

/* ─── Action stream (events/tasks) ─── */
.fx-stream-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--fx-border);
  transition: background var(--fx-duration-fast) var(--fx-ease-out);
}

.fx-stream-item:last-child {
  border-bottom: none;
}

.fx-stream-item:hover {
  background: var(--fx-surface-raised);
}

.fx-stream-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.fx-stream-dot--urgent { background: var(--fx-error); }
.fx-stream-dot--warning { background: var(--fx-warning); }
.fx-stream-dot--info { background: var(--fx-info); }
.fx-stream-dot--success { background: var(--fx-success); }

/* ─── Buttons (softer, aligned) ─── */
.mud-button-root:not(.mud-switch-base) {
  border-radius: var(--fx-radius-md) !important;
  box-shadow: none !important;
  font-weight: 600;
  text-transform: none !important;
  min-height: 44px;
  transition: background var(--fx-duration) var(--fx-ease-out),
              border-color var(--fx-duration) var(--fx-ease-out),
              color var(--fx-duration) var(--fx-ease-out);
}

/* MudSwitch uses mud-button-root for the thumb; 44px min-height clips it off-center.
   Geometry: 20px knob inside a 26px pill so the control reads as centered. */
.mud-switch {
  align-items: center;
}

.mud-switch .mud-switch-base.mud-button-root {
  min-height: 0;
  height: auto;
  width: auto;
  border-radius: 50% !important;
  box-shadow: none !important;
}

.mud-switch .mud-switch-span {
  display: inline-flex;
  align-items: center;
}

.mud-switch .mud-switch-span-medium.mud-switch-span {
  width: 46px;
  height: 26px;
  padding: 3px;
}

.mud-switch .mud-switch-span-small.mud-switch-span {
  width: 36px;
  height: 20px;
  padding: 2px;
}

.mud-switch .mud-switch-span-large.mud-switch-span {
  width: 56px;
  height: 32px;
  padding: 3px;
}

.mud-switch .mud-switch-span .mud-switch-track {
  border-radius: 999px;
  opacity: 0.38;
}

.mud-switch .mud-switch-base-medium.mud-switch-base {
  padding: 3px;
}

.mud-switch .mud-switch-base-small.mud-switch-base {
  padding: 2px;
}

.mud-switch .mud-switch-base-large.mud-switch-base {
  padding: 3px;
}

.mud-switch .mud-switch-base-medium.mud-checked {
  transform: translateX(20px);
}

.mud-switch .mud-switch-base-small.mud-checked {
  transform: translateX(16px);
}

.mud-switch .mud-switch-base-large.mud-checked {
  transform: translateX(24px);
}

.mud-switch .mud-switch-base.mud-checked + .mud-switch-track {
  opacity: 0.55;
}

.mud-switch .mud-switch-label {
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.mud-grid-item:has(> .mud-switch) {
  display: flex;
  align-items: center;
}

.mud-button-filled.mud-theme-secondary {
  background: var(--fx-amber) !important;
  color: var(--fx-navy-deep) !important;
}

.mud-button-filled.mud-theme-secondary:hover {
  background: var(--fx-amber-hover) !important;
  color: var(--fx-navy-deep) !important;
}

.mud-button-root.mud-button-filled:hover {
  box-shadow: var(--fx-shadow-sm) !important;
}

/* ─── DataGrid / Tables ─── */
.mud-table .mud-table-head .mud-table-cell {
  font-size: var(--fx-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fx-ink-muted);
  border-bottom: 1px solid var(--fx-border);
}

.mud-table .mud-table-body .mud-table-row:hover {
  background: var(--fx-surface-raised) !important;
}

/* ─── Expansion panels ─── */
.mud-expand-panel {
  border: 1px solid var(--fx-border) !important;
  border-radius: var(--fx-radius-md) !important;
  box-shadow: none !important;
  margin-bottom: 0.5rem;
}

/* ─── Chips ─── */
.mud-chip {
  border-radius: 100px !important;
  font-size: var(--fx-text-sm);
  font-weight: 500;
}

/* ─── Focus ring global ─── */
*:focus-visible {
  outline: none;
  box-shadow: var(--fx-focus-ring);
}

/* ─── Scrollbar (subtle) ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--fx-border-strong);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fx-ink-muted);
}

.app-icon:hover,
.dock a:hover,
.dock button:hover {
  background: var(--fx-primary-subtle);
}

.app-panel-btn:hover {
  background: var(--fx-primary-subtle);
}

.app-panel-badge {
  background: var(--fx-primary-subtle);
  color: var(--fx-navy);
}

[data-mud-theme="dark"] .fx-logo--dark .fx-logo__wordmark {
  color: var(--fx-ink);
}

[data-mud-theme="dark"] .fx-logo--dark .fx-logo__mark-bg,
[data-mud-theme="dark"] .fx-logo--mark-dark .fx-logo__mark-bg {
  fill: oklch(32% 0.06 245);
}

[data-mud-theme="dark"] .fx-logo--dark .fx-logo__mark-f,
[data-mud-theme="dark"] .fx-logo--mark-dark .fx-logo__mark-f {
  fill: oklch(98% 0.004 245);
}

@media (max-width: 620px) {
  .mud-appbar.fx-appbar .fx-clock {
    min-width: 0;
  }
}

/* Sito pubblico / guest: orologio e tema solo dopo l'accesso. */
.fx-landing-layout .fx-clock,
.fx-landing-layout .fx-theme,
.fx-landing-layout .fx-header__chrome,
.fx-header .fx-clock,
.fx-header .fx-theme {
  display: none !important;
}

/* Avanzamento pratica: rosa lacune, giallo attesa, azzurro in corso, verde completata. */
.chip-avanzamento-rosa { background: var(--fx-rose-subtle); color: var(--fx-rose); }
.chip-avanzamento-giallo { background: var(--fx-warning-subtle); color: oklch(0.38 0.1 60); }
.chip-avanzamento-verde { background: var(--fx-success-subtle); color: oklch(0.32 0.1 155); }
.chip-avanzamento-azzurro { background: var(--fx-info-subtle); color: var(--fx-navy); }
[data-mud-theme="dark"] .chip-avanzamento-giallo,
.mud-theme-dark .chip-avanzamento-giallo { color: oklch(0.86 0.08 70); }
[data-mud-theme="dark"] .chip-avanzamento-verde,
.mud-theme-dark .chip-avanzamento-verde { color: oklch(0.82 0.08 155); }

