/* ════════════════════════════════════════════════════════════════════════════
 * nh-toolbar.css — toolbar uniforme per tutte le pagine NH
 * 6 elementi: [Logo] [Back] [Title] [Search] [Cliente+Country] [Phone] [Profile]
 * Compatibile con tema light + dark (usa CSS vars del tema esistente).
 * 🚫 NO HARDCODED · 2026-05-02
 * ════════════════════════════════════════════════════════════════════════════ */

.nh-tb {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface, #fff);
  border-bottom: 1px solid var(--border, #e2e8f0);
  padding: 9px 16px;
  width: 100%;
  min-height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* 0. Logo NH */
.nh-tb-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(59,130,246,.25);
  cursor: pointer;
  transition: transform .15s;
}
.nh-tb-logo:hover { transform: scale(1.05); }

/* 1. Back button */
.nh-tb-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-2, var(--text-1, #334155));
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  flex-shrink: 0;
}
.nh-tb-back:hover {
  background: var(--accent-soft, rgba(59,130,246,.08));
  color: var(--accent-strong, var(--accent, #2563eb));
  border-color: rgba(59,130,246,.2);
}
.nh-tb-back .arrow { font-size: 14px; line-height: 1; }
.nh-tb-back.home {
  background: var(--accent-soft, rgba(59,130,246,.08));
  color: var(--accent-strong, var(--accent, #2563eb));
}

/* 2. Title chip */
.nh-tb-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(59,130,246,.10), rgba(139,92,246,.08));
  border: 1px solid rgba(59,130,246,.20);
  border-radius: 999px;
  color: var(--text-1, var(--text, #0f172a));
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.1px;
  flex-shrink: 0;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nh-tb-title .icon { font-size: 14px; }
.nh-tb-title.root {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  border-color: transparent;
}

/* 3. Search */
.nh-tb-search {
  flex: 0 1 220px;
  min-width: 180px;
  max-width: 220px;
  position: relative;
  transition: all .25s;
}
.nh-tb-search.expanded {
  flex: 1 1 auto;
  max-width: 100%;
}
.nh-tb-search input {
  width: 100%;
  padding: 8px 32px 8px 34px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  background: var(--surface-2, #f8fafc);
  font-size: 13px;
  color: var(--text-1, var(--text, #0f172a));
  transition: all .15s;
  outline: none;
  font-family: inherit;
}
.nh-tb-search input:focus {
  background: var(--surface, #fff);
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.nh-tb-search input::placeholder { color: var(--text-3, #64748b); }
.nh-tb-search .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-3, #64748b);
  pointer-events: none;
}
.nh-tb-search .clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--border, #e2e8f0);
  color: var(--text-3, #64748b);
  font-size: 10px;
  cursor: pointer;
  display: none;
}
.nh-tb-search.has-value .clear { display: flex; align-items: center; justify-content: center; }
.nh-tb-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}
.nh-tb-search-results.open { display: block; }
.nh-tb-search-results .group {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.nh-tb-search-results .group:last-child { border-bottom: none; }
.nh-tb-search-results .group-title {
  padding: 4px 14px;
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--text-3, #64748b);
  letter-spacing: .5px;
  font-weight: 700;
}
.nh-tb-search-results .item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12.5px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.nh-tb-search-results .item:hover { background: var(--surface-2, #f8fafc); }
.nh-tb-search-results .empty {
  padding: 18px;
  text-align: center;
  color: var(--text-3, #64748b);
  font-size: 12px;
}

.nh-tb-spacer { flex: 1 1 auto; }

/* 4. Cliente+Country widget */
.nh-tb-cc { position: relative; flex-shrink: 0; }
.nh-tb-cc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  color: var(--text-1, var(--text, #0f172a));
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.nh-tb-cc-btn:hover { border-color: var(--accent, #3b82f6); background: var(--accent-soft, rgba(59,130,246,.08)); }
.nh-tb-cc-btn.open {
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.nh-tb-cc-btn .name {
  font-weight: 600;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nh-tb-cc-btn .sep { color: var(--text-3, #64748b); }
.nh-tb-cc-btn .caret { font-size: 9px; color: var(--text-3, #64748b); margin-left: 2px; }

.nh-tb-cc-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 320px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  padding: 16px;
  z-index: 1000;
  display: none;
}
.nh-tb-cc-popover.open { display: block; }
.nh-tb-cc-popover h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-3, #64748b);
  letter-spacing: .5px;
  font-weight: 700;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nh-tb-cc-popover h4:not(:first-child) { margin-top: 14px; }
.nh-tb-cc-popover select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 7px;
  background: var(--surface, #fff);
  font-size: 13px;
  color: var(--text-1, var(--text, #0f172a));
  cursor: pointer;
  font-family: inherit;
}
.nh-tb-cc-popover .hint {
  font-size: 11px;
  color: var(--text-3, #64748b);
  margin-top: 4px;
}
.nh-tb-cc-popover .actions {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.nh-tb-cc-popover button {
  padding: 7px 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 7px;
  background: var(--surface, #fff);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-1, #0f172a);
  font-family: inherit;
}
.nh-tb-cc-popover button.primary {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: var(--accent, #3b82f6);
}

/* 5. Phone/Chat status */
.nh-tb-phone { position: relative; flex-shrink: 0; }
.nh-tb-phone-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  position: relative;
  transition: all .15s;
}
.nh-tb-phone-btn:hover { border-color: var(--accent, #3b82f6); }
.nh-tb-phone-btn .dots {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  gap: 1px;
}
.nh-tb-phone-btn .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--surface-2, #f8fafc);
}
.nh-tb-phone-btn .dot.green { background: var(--success, #10b981); }
.nh-tb-phone-btn .dot.red { background: var(--danger, #ef4444); }
.nh-tb-phone-btn .dot.yellow { background: var(--warn, #f59e0b); }
.nh-tb-phone-btn .dot.gray { background: var(--text-3, #64748b); }

.nh-tb-phone-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  padding: 14px;
  z-index: 1000;
  display: none;
}
.nh-tb-phone-popover.open { display: block; }
.nh-tb-phone-popover .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12.5px;
}
.nh-tb-phone-popover .divider {
  height: 1px;
  background: var(--border, #e2e8f0);
  margin: 8px 0;
}
.nh-tb-phone-popover h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-3, #64748b);
  margin-bottom: 6px;
  letter-spacing: .5px;
  font-weight: 700;
}
.nh-tb-phone-popover select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 7px;
  background: var(--surface, #fff);
  font-size: 12.5px;
  cursor: pointer;
  margin-top: 4px;
  font-family: inherit;
}

/* 6. Profile widget */
.nh-tb-profile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--surface-2, #f8fafc);
  transition: all .15s;
  position: relative;
}
.nh-tb-profile:hover { border-color: var(--accent, #3b82f6); }
.nh-tb-profile .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent, #3b82f6), var(--purple, #8b5cf6));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  position: relative;
}
.nh-tb-profile .presence-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success, #10b981);
  border: 2px solid var(--surface-2, #f8fafc);
}
.nh-tb-profile .presence-dot.busy { background: var(--danger, #ef4444); }
.nh-tb-profile .presence-dot.away { background: var(--warn, #f59e0b); }
.nh-tb-profile .presence-dot.offline { background: var(--text-3, #64748b); }
.nh-tb-profile .name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-1, var(--text, #0f172a));
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nh-tb-profile .caret { font-size: 9px; color: var(--text-3, #64748b); }

.nh-tb-profile-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  padding: 14px;
  z-index: 1000;
  display: none;
}
.nh-tb-profile-popover.open { display: block; }
.nh-tb-profile-popover .header {
  padding: 6px 4px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  margin-bottom: 8px;
}
.nh-tb-profile-popover .header .name { font-weight: 700; font-size: 13.5px; color: var(--text-1, #0f172a); }
.nh-tb-profile-popover .header .role { font-size: 11px; color: var(--text-3, #64748b); margin-top: 2px; }
.nh-tb-profile-popover .menu-item {
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-1, #0f172a);
}
.nh-tb-profile-popover .menu-item:hover { background: var(--surface-2, #f8fafc); }
.nh-tb-profile-popover .menu-item.active { background: var(--accent-soft, rgba(59,130,246,.08)); color: var(--accent-strong, #2563eb); font-weight: 600; }
.nh-tb-profile-popover .divider {
  height: 1px;
  background: var(--border, #e2e8f0);
  margin: 6px 0;
}
.nh-tb-profile-popover .menu-item.danger { color: var(--danger, #ef4444); }

/* Responsive: narrow viewport collapses non-essential */
@media (max-width: 900px) {
  .nh-tb-search { display: none; }
  .nh-tb-back .label { display: none; }
  .nh-tb-cc-btn .name { max-width: 80px; }
  .nh-tb-profile .name { display: none; }
}
@media (max-width: 600px) {
  .nh-tb-title { max-width: 140px; font-size: 11.5px; }
  .nh-tb-cc-btn .sep, .nh-tb-cc-btn .name { display: none; }
}
