/* ============================================================
   Shell layout — sidebar, topbar, app-shell
   ============================================================ */

/* ── 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;
}

/* ── 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; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid hsl(var(--sidebar-border));
}
.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));
}

/* ── 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-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;
}
.topbar-search {
  position: relative;
  width: 260px;
}
/* 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-search--trigger { cursor: pointer; }
.topbar-search--trigger .topbar-search-input {
  cursor: pointer;
  pointer-events: none;
  padding-right: 36px;
  user-select: none;
}
.topbar-search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  pointer-events: none;
  line-height: 1.6;
}
.topbar-search-input {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  font-family: inherit;
  font-size: 13px;
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.topbar-search-input::placeholder { color: hsl(var(--muted-foreground)); }
.topbar-search-input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.18);
  background: hsl(var(--background));
}
.topbar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}
.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));
}
/* keep modifier classes for potential future differentiation */
.topbar-notif-badge--warn,
.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,
.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,
.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-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; }
