/* ============================================================
   Shell layout — sidebar, topbar, app-shell
   ============================================================ */

/* ── Overlay completamento profilo ─────────────────────────── */
.profile-complete-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.profile-complete-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) * 1.5);
  padding: 32px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 24px 64px hsl(0 0% 0% / 0.15);
}
.profile-complete-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.profile-complete-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-complete-title {
  font-size: 18px;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-bottom: 4px;
}
.profile-complete-sub {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
}

/* ── App shell wrapper ─────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;    /* fixed height → app-shell-body diventa scroll container */
}
.app-shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.app-shell-body {
  flex: 1;
  overflow: auto;
  /* flex column, non solo per estetica: una pagina .split-view dentro usa flex:1 per
     prendere esattamente lo spazio rimasto SOTTO la Toolbar (se presente) — con
     height:100% calcolato sull'intero app-shell-body, Toolbar+pagina superavano
     l'altezza disponibile e faceva scrollare l'intera pagina invece che la tabella. */
  display: flex;
  flex-direction: column;
}

/* ── Toolbar pagina — sticky sotto la topbar, dentro lo scroll container ── */
.page-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 8px;
  padding: 10px var(--page-pad-x);
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
}
.page-toolbar-sep { width: 1px; align-self: stretch; background: hsl(var(--border)); margin: 0 2px; }
.page-toolbar-spacer { flex: 1; }

/* ── Split view — N colonne affiancate in un unico Card, separate da un
   divider verticale, altezza fissa fino in fondo alla pagina con scroll
   interno per colonna (usata da Categorie, Anagrafiche). ── */
.split-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.split-view .split-card {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.split-cols {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.split-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid hsl(var(--border));
}
.split-col:last-child { border-right: none; }
.split-col-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: var(--pad-card) var(--pad-card) calc(var(--pad-card) - 4px);
  flex-shrink: 0;
}
.split-col-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.split-col-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--pad-card);
}
.split-col-body .tbl thead th { position: sticky; top: 0; z-index: 1; }

/* ── Sidebar shared ────────────────────────────────────────── */
.sidebar {
  background: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
  overflow-y: auto;
}

/* ── Sidebar expanded (240 px) ─────────────────────────────── */
.sidebar--expanded {
  width: 240px;
  padding: 14px 12px;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 14px;
  flex: 1;
  min-width: 0;
}
.brand-name  { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub   { font-size: 11px; color: hsl(var(--muted-foreground)); }

/* Logo images in sidebar */
.sidebar-logo {
  height: 30px;
  width: auto;
  display: block;
}
.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

/* Theme-aware logo swap: show dark logo in light mode, white in dark mode */
.sidebar-logo--dark  { display: none; }
[data-theme="dark"] .sidebar-logo--light { display: none; }
[data-theme="dark"] .sidebar-logo--dark  { display: block; }

.sidebar-divider {
  height: 1px;
  margin: 4px 4px 10px;
  background: linear-gradient(
    to right,
    transparent 0%,
    hsl(var(--primary) / 0.5) 25%,
    hsl(var(--primary) / 0.7) 50%,
    hsl(var(--primary) / 0.5) 75%,
    transparent 100%
  );
  box-shadow: 0 0 8px 1px hsl(var(--primary) / 0.2);
  flex-shrink: 0;
}

.sidebar-group-label {
  font-size: 10px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 10px 4px;
}

.sidebar-nav { flex: 1; overflow-y: auto; }

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  width: 100%;
  text-align: left;
  color: hsl(var(--foreground));
  background: transparent;
  transition: background .12s;
}
.sidebar-nav-item:hover  { background: hsl(var(--accent)); }
.sidebar-nav-item.active {
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.08);
}
.sidebar-nav-label { flex: 1; }

/* ── Icone animate alla selezione ────────────────────────────────
   Ogni icona "recita" qualcosa legato al suo significato invece di un generico ingrandimento —
   l'occhio strizza, l'ingranaggio gira, il tag oscilla come appeso... Riparte ogni volta che la
   classe .active viene aggiunta (cambio pagina), non mentre resta semplicemente selezionata.
   [data-icon] è impostato da Icon.razor su ogni <svg> — un selettore per icona, niente da fare
   nelle pagine consumer. Fallback generico (salto+torsione) per le icone senza un'animazione dedicata. */
.sidebar-nav-item.active svg,
.sidebar-icon-btn.active svg {
  animation: sidebarIconPop .5s cubic-bezier(.34, 1.56, .64, 1);
  transform-origin: center;
}

.sidebar-nav-item.active [data-icon="eye"],
.sidebar-icon-btn.active [data-icon="eye"] {
  animation: sidebarIconBlink .65s ease-in-out;
}

.sidebar-nav-item.active [data-icon="settings"],
.sidebar-icon-btn.active [data-icon="settings"] {
  animation: sidebarIconSpin .6s cubic-bezier(.45, 0, .55, 1);
}

.sidebar-nav-item.active [data-icon="calendar"],
.sidebar-icon-btn.active [data-icon="calendar"] {
  animation: sidebarIconFlip .55s ease;
  transform-origin: top center;
}

.sidebar-nav-item.active [data-icon="tags"],
.sidebar-icon-btn.active [data-icon="tags"] {
  animation: sidebarIconSwing .6s ease;
  transform-origin: 20% 0%;
}

.sidebar-nav-item.active [data-icon="users"],
.sidebar-nav-item.active [data-icon="user"],
.sidebar-icon-btn.active [data-icon="users"],
.sidebar-icon-btn.active [data-icon="user"] {
  animation: sidebarIconBounce .5s ease;
}

.sidebar-nav-item.active [data-icon="file-text"],
.sidebar-icon-btn.active [data-icon="file-text"] {
  animation: sidebarIconBounce .5s ease;
}

@keyframes sidebarIconPop {
  0%   { transform: scale(1) rotate(0deg); }
  40%  { transform: scale(1.32) rotate(-8deg); }
  65%  { transform: scale(.92) rotate(4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* occhio che strizza — schiaccia solo in verticale, come una palpebra */
@keyframes sidebarIconBlink {
  0%, 70%, 100% { transform: scaleY(1); }
  82%           { transform: scaleY(.12); }
  92%           { transform: scaleY(1); }
}

/* ingranaggio che gira una volta */
@keyframes sidebarIconSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(330deg); }
}

/* pagina di calendario che si "sfoglia" */
@keyframes sidebarIconFlip {
  0%, 100% { transform: perspective(60px) rotateX(0deg); }
  35%      { transform: perspective(60px) rotateX(38deg); }
  65%      { transform: perspective(60px) rotateX(-10deg); }
}

/* etichetta appesa che oscilla */
@keyframes sidebarIconSwing {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-16deg); }
  55%      { transform: rotate(11deg); }
  80%      { transform: rotate(-4deg); }
}

/* piccolo saltello */
@keyframes sidebarIconBounce {
  0%, 100% { transform: translateY(0); }
  35%      { transform: translateY(-4px); }
  60%      { transform: translateY(1px); }
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid hsl(var(--sidebar-border));
}
.sidebar-sync-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: hsl(var(--muted-foreground));
  padding: 4px 2px 6px;
  opacity: 0.75;
}
.sidebar-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: hsl(var(--success));
  margin-bottom: 6px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  cursor: default;
  transition: background .12s;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; }
.user-role { font-size: 11px; color: hsl(var(--muted-foreground)); }

.sidebar-logout-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.sidebar-logout-btn:hover {
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}

.sidebar-compact-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid hsl(var(--sidebar-border));
}

/* ── Sidebar compact (60 px) ───────────────────────────────── */
.sidebar--compact {
  width: 60px;
  padding: 14px 8px;
  align-items: center;
  gap: 4px;
}
.sidebar-compact-nav {
  flex: 1;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.sidebar-icon-btn:hover  { background: hsl(var(--accent)); }
.sidebar-icon-btn.active {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}
.sidebar-icon-btn.active svg { animation: sidebarIconPop .5s cubic-bezier(.34, 1.56, .64, 1); }

/* ── Toggle button (shared) ────────────────────────────────── */
.sidebar-toggle-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  transition: background .12s, color .12s;
}
.sidebar--compact .sidebar-toggle-btn {
  width: 28px;
  height: 28px;
  margin-top: 8px;
  margin-bottom: 0;
}
.sidebar-toggle-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

/* ── Brand mark ────────────────────────────────────────────── */
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: hsl(var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  font-family: 'Geist Mono', monospace;
  flex-shrink: 0;
}

/* ── Avatar ────────────────────────────────────────────────── */
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h, 56px);
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: hsl(var(--background));
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
}
.topbar-breadcrumb-current {
  color: hsl(var(--foreground));
  font-weight: 500;
}
.topbar-sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: hsl(var(--primary) / .1);
  color: hsl(var(--primary));
  font-size: 11.5px;
  font-weight: 500;
  animation: topbarSyncFade .25s ease-out;
}
.topbar-sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(var(--primary));
  animation: topbarSyncPulse 1s ease-in-out infinite;
}
@keyframes topbarSyncFade {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes topbarSyncPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.7); }
}
.topbar-bc-link {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color .12s;
}
.topbar-bc-link:hover { color: hsl(var(--foreground)); }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* kbd shortcut badge (sidebar nav items) */
.kbd {
  font-size: 10px;
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  margin-left: auto;
  line-height: 1.6;
  flex-shrink: 0;
  letter-spacing: 0;
}
.topbar-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: hsl(var(--foreground));
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.topbar-icon-btn:hover { background: hsl(var(--accent)); }

/* ── Notification wrap (bell / truck) ──────────────────────── */
.topbar-notif-wrap {
  position: relative;
}
.topbar-notif-btn {
  position: relative;
}
/* numeric badge on the icon button */
.topbar-notif-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border: 2px solid hsl(var(--background));
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
/* --warn: used for expired-offer notifications (hourglass-broken) */
.topbar-notif-badge--warn {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.topbar-notif-badge--info {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* invisible full-screen overlay to catch outside clicks */
.topbar-notif-overlay {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: transparent;
}

/* panel card */
.topbar-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  width: 320px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 8px 24px hsl(0 0% 0% / 0.12), 0 2px 6px hsl(0 0% 0% / 0.06);
  overflow: hidden;
}

/* panel header */
.topbar-notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid hsl(var(--border));
}
.tnp-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--foreground));
}
.topbar-notif-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
}
.topbar-notif-count--warn {
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}
.topbar-notif-count--info {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

/* empty state */
.topbar-notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}

/* notification list */
.topbar-notif-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

/* notification item row */
.topbar-notif-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: calc(var(--radius));
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background .1s;
}
.topbar-notif-item:hover {
  background: hsl(var(--accent));
}

/* colored dot indicator */
.tni-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.tni-dot--warn  { background: hsl(var(--destructive)); }
.tni-dot--info  { background: hsl(var(--primary)); }

/* text body */
.tni-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tni-cod {
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tni-cliente {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* right meta column */
.tni-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}
.tni-date {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
.tni-date--warn {
  background: hsl(var(--destructive) / 0.12);
  color: hsl(var(--destructive));
}
.tni-totale {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}

/* ── Help / contacts panel ──────────────────────────────────── */
.topbar-help-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.topbar-help-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius);
  transition: background .1s;
}
.topbar-help-item:hover {
  background: hsl(var(--accent));
}
.thi-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.thi-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.thi-nome {
  font-size: 13px;
  font-weight: 600;
  color: hsl(var(--foreground));
}
.thi-ruolo {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}
.thi-links {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}
.thi-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: hsl(var(--primary));
  text-decoration: none;
  transition: opacity .1s;
}
.thi-link:hover { opacity: 0.75; }
