/**
 * nh-bottom-dock.css — Dock unificato bottom-center (NH unified L1/L2-3).
 * ════════════════════════════════════════════════════════════════════════
 *
 * 2026-05-22 v1 — Sostituisce: phone bar + chat widget + AI copilot widget
 *                              + top dock (Editor/View/New) + footer shortcut.
 * UNA sola superficie. NH #4 integrare, #5 riuso, #14 simplicità.
 */

.nh-bdock {
  position: fixed;
  bottom: 18px;
  left: 50%;
  /* 🆕 2026-05-23 — Dock ridotto del 40% (decisione UX). scale(0.6) + translateX
     mantiene centratura orizzontale; transform-origin bottom center evita drift
     verticale. NH #14: 1 sola modifica CSS, no refactor invasivo. */
  transform: translateX(-50%) scale(0.6);
  transform-origin: bottom center;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.88);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 22px;
  box-shadow:
    0 20px 50px rgba(0,0,0,0.30),
    0 4px 12px rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.10);
  z-index: 1500;
  color: white;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
}
.nh-bdock-group { display: flex; align-items: center; gap: 4px; }
.nh-bdock-sep { width: 1px; height: 28px; background: rgba(255,255,255,0.12); margin: 0 6px; }
.nh-bdock-btn {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  border: 0;
  cursor: pointer;
  font-size: 17px;
  color: white;
  background: rgba(255,255,255,0.08);
  position: relative;
  transition: transform 0.16s cubic-bezier(.34,1.56,.64,1), background 0.16s;
}
.nh-bdock-btn:hover { transform: translateY(-5px) scale(1.08); background: rgba(255,255,255,0.18); }
.nh-bdock-btn:active { transform: translateY(-2px) scale(1.02); }
.nh-bdock-btn.danger  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.nh-bdock-btn.success { background: linear-gradient(135deg, #10b981, #059669); }
.nh-bdock-btn.warn    { background: linear-gradient(135deg, #f59e0b, #d97706); }
.nh-bdock-btn.editor  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.nh-bdock-btn.view    { background: linear-gradient(135deg, #06b6d4, #0e7490); }
.nh-bdock-btn.new     { background: linear-gradient(135deg, #2563eb, #1e40af); }
.nh-bdock-btn.chat    { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.nh-bdock-btn.ai      { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.nh-bdock-btn.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* Tooltip */
.nh-bdock-btn .nh-bd-tip {
  position: absolute;
  bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  background: #1f2937; color: white;
  padding: 4px 9px; border-radius: 6px;
  font-size: 11px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.14s;
  font-family: -apple-system, system-ui, sans-serif;
  font-weight: normal;
  border: 1px solid rgba(255,255,255,0.06);
}
.nh-bdock-btn:hover .nh-bd-tip { opacity: 1; }
.nh-bdock-btn .nh-bd-tip kbd {
  background: rgba(255,255,255,0.12); padding: 0 4px;
  margin-left: 4px; border-radius: 3px;
  font-family: ui-monospace, monospace; font-size: 10px;
}
.nh-bdock-btn .nh-bd-tip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #1f2937;
}

/* Badge */
.nh-bdock-btn .nh-bd-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: #ef4444; color: white;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  padding: 0 5px;
  border: 2px solid rgba(15,23,42,0.88);
  font-family: ui-monospace, monospace;
}
.nh-bdock-btn .nh-bd-badge:empty,
.nh-bdock-btn .nh-bd-badge[data-empty="1"] { display: none; }

/* Pulse ringing */
.nh-bdock-btn.nh-bd-ringing { animation: nh-bd-ring 1.2s ease-in-out infinite; }
@keyframes nh-bd-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.7); }
  50%      { box-shadow: 0 0 0 12px rgba(16,185,129,0); }
}

/* ACD status pill */
.nh-bd-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: rgba(16,185,129,0.18);
  border: 1px solid rgba(16,185,129,0.4);
  border-radius: 14px;
  font-size: 11px;
}
.nh-bd-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 6px #10b981; }
.nh-bd-status[data-state="busy"] { background: rgba(245,158,11,0.18); border-color: rgba(245,158,11,0.4); }
.nh-bd-status[data-state="busy"] .dot { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.nh-bd-status[data-state="away"] { background: rgba(107,114,128,0.18); border-color: rgba(107,114,128,0.4); }
.nh-bd-status[data-state="away"] .dot { background: #9ca3af; box-shadow: none; }
.nh-bd-status[data-state="offline"] { background: rgba(107,114,128,0.18); border-color: rgba(107,114,128,0.4); }
.nh-bd-status[data-state="offline"] .dot { background: #6b7280; box-shadow: none; }
.nh-bd-status select {
  background: transparent; border: 0; color: white;
  font-size: 11px; cursor: pointer; font-family: inherit; outline: none;
}
.nh-bd-status select option { background: #1f2937; color: white; }

/* Call timer */
.nh-bd-timer {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  padding: 0 8px;
  min-width: 56px;
  text-align: center;
}
.nh-bd-timer.active { color: #10b981; }

/* Panels (chat / AI / dialpad / notifications) */
.nh-bd-panel {
  position: fixed;
  bottom: 78px;
  background: white;
  color: #111827;
  border: 1px solid #e3e7ec;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  display: none;
  flex-direction: column;
  z-index: 1600;
  overflow: hidden;
  animation: nh-bd-pan-in 0.18s cubic-bezier(.34,1.56,.64,1);
  font-family: -apple-system, system-ui, sans-serif;
}
.nh-bd-panel.open { display: flex; }
@keyframes nh-bd-pan-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.nh-bd-panel.right { right: 24px; }
.nh-bd-panel.center { left: 50%; transform: translateX(-50%); }
.nh-bd-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #e3e7ec;
  background: #f7f9fc;
}
.nh-bd-panel-head h3 { font-size: 13px; flex: 1; margin: 0; }
.nh-bd-panel-head .x {
  width: 24px; height: 24px;
  border: 0; background: transparent;
  cursor: pointer; font-size: 14px; color: #6b7280;
  border-radius: 5px;
}
.nh-bd-panel-head .x:hover { background: #eef1f5; color: #111827; }
.nh-bd-panel-body { flex: 1; overflow-y: auto; padding: 14px; font-size: 12.5px; line-height: 1.5; color: #374151; }

/* ─── VIEWER MODAL (📄 anteprima + print + export) ──────────── */
/* Stili spostati da nh-dock.css (rimosso 2026-05-22). */
.nh-viewer-back {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.nh-viewer-back.open { display: flex; }
.nh-viewer {
  background: #fff; color: #111827;
  border-radius: 14px;
  width: 880px; max-width: 94vw; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  overflow: hidden;
  font-family: -apple-system, system-ui, sans-serif;
}
.nh-viewer-head {
  padding: 14px 18px;
  border-bottom: 1px solid #e3e7ec;
  display: flex; align-items: center; gap: 12px;
  background: #f7f9fc;
}
.nh-viewer-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.nh-viewer-head .vk { font-family: ui-monospace, monospace; color: #2563eb; font-weight: 600; font-size: 13px; }
.nh-viewer-head .vsp { flex: 1; }
.nh-viewer-head .vx {
  width: 28px; height: 28px; border-radius: 6px;
  border: 0; background: transparent; font-size: 18px; cursor: pointer; color: #6b7280;
}
.nh-viewer-head .vx:hover { background: #eef1f5; color: #111827; }
.nh-viewer-tools {
  padding: 8px 18px;
  border-bottom: 1px solid #e3e7ec;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.nh-viewer-tools .vbtn {
  padding: 6px 12px; background: #f7f9fc; border: 1px solid #e3e7ec; border-radius: 6px;
  font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.nh-viewer-tools .vbtn:hover { background: #eef1f5; border-color: #2563eb; }
.nh-viewer-tools .vbtn.primary { background: #2563eb; color: white; border-color: #2563eb; font-weight: 600; }
.nh-viewer-body { padding: 20px 26px; overflow-y: auto; flex: 1; }

.nh-doc { background: white; padding: 22px 26px; border: 1px solid #e3e7ec; border-radius: 6px; font-size: 12.5px; line-height: 1.5; }
.nh-doc-head { display: flex; justify-content: space-between; border-bottom: 2px solid #111827; padding-bottom: 10px; margin-bottom: 14px; }
.nh-doc-head .l .brand { font-size: 18px; font-weight: 700; }
.nh-doc-head .l .sub { font-size: 11px; color: #6b7280; margin-top: 2px; }
.nh-doc-head .r { text-align: right; font-size: 11px; color: #6b7280; }
.nh-doc h1 { font-size: 17px; margin: 12px 0 8px; }
.nh-doc .dm { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 12px; background: #f7f9fc; padding: 10px 14px; border-radius: 6px; margin: 10px 0 16px; }
.nh-doc .dm .k { color: #6b7280; font-weight: 500; }
.nh-doc h2.s { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #6b7280; margin: 18px 0 6px; border-bottom: 1px solid #e3e7ec; padding-bottom: 4px; }
.nh-doc p { margin-bottom: 8px; }
.nh-doc table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 6px 0; }
.nh-doc table th, .nh-doc table td { border: 1px solid #e3e7ec; padding: 5px 8px; text-align: left; vertical-align: top; }
.nh-doc table th { background: #f7f9fc; font-weight: 600; }
.nh-doc-footer { border-top: 1px solid #e3e7ec; margin-top: 18px; padding-top: 8px; font-size: 10px; color: #9ca3af; display: flex; justify-content: space-between; }

/* Print: solo il documento, niente toolbar/dock/altro */
@media print {
  body * { visibility: hidden !important; }
  .nh-viewer-back, .nh-viewer-back * { visibility: visible !important; }
  .nh-viewer-back { position: absolute; inset: 0; background: white; }
  .nh-viewer { border: 0; box-shadow: none; max-height: none; width: 100%; }
  .nh-viewer-head, .nh-viewer-tools { display: none !important; }
  .nh-viewer-body { padding: 0; }
  .nh-doc { border: 0; padding: 0; }
}

/* 🆕 2026-05-22 — Host per NHPresence widget inline nel dock dark */
.nh-bd-presence-host { display: inline-flex; align-items: center; }
.nh-bd-presence-host .nh-tb-phone { display: inline-flex; align-items: center; position: relative; }
.nh-bd-presence-host .nh-tb-phone-btn {
  background: rgba(255,255,255,0.08); color: white;
  border: 0; padding: 6px 10px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; font-family: inherit; font-size: 14px;
  transition: background 0.14s;
}
.nh-bd-presence-host .nh-tb-phone-btn:hover { background: rgba(255,255,255,0.16); }
.nh-bd-presence-host .nh-tb-phone-btn .dots { display: inline-flex; gap: 3px; }
.nh-bd-presence-host .nh-tb-phone-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: #6b7280; }
.nh-bd-presence-host .nh-tb-phone-btn .dot.green { background: #10b981; box-shadow: 0 0 4px #10b981; }
.nh-bd-presence-host .nh-tb-phone-btn .dot.red { background: #ef4444; }
.nh-bd-presence-host .nh-tb-phone-btn .dot.yellow { background: #f59e0b; }
.nh-bd-presence-host .nh-tb-phone-btn .dot.gray { background: #6b7280; }
/* Popover si apre sopra il dock (bottom-up) */
.nh-bd-presence-host .nh-tb-phone-popover {
  position: absolute;
  bottom: calc(100% + 10px); left: 0;
  display: none;
  background: white; color: #111827;
  border: 1px solid #e3e7ec; border-radius: 10px;
  padding: 12px 14px;
  min-width: 280px; max-width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.30), 0 4px 12px rgba(0,0,0,0.18);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 12.5px;
  z-index: 2000;
}
.nh-bd-presence-host .nh-tb-phone-popover.open { display: block; }
.nh-bd-presence-host .nh-tb-phone-popover h4 { font-size: 11px; text-transform: uppercase; color: #6b7280; letter-spacing: 0.4px; margin: 0 0 6px; font-weight: 600; }
.nh-bd-presence-host .nh-tb-phone-popover .row { display: flex; justify-content: space-between; padding: 3px 0; }
.nh-bd-presence-host .nh-tb-phone-popover .row > span:first-child { color: #6b7280; }
.nh-bd-presence-host .nh-tb-phone-popover .divider { height: 1px; background: #e3e7ec; margin: 8px 0; }
.nh-bd-presence-host .nh-tb-phone-popover select {
  width: 100%; padding: 5px 8px; border: 1px solid #e3e7ec;
  border-radius: 5px; font-size: 12px; background: white;
}

/* Toast */
.nh-bd-toast {
  position: fixed; bottom: 86px; right: 24px;
  padding: 8px 14px; border-radius: 6px;
  color: white; font-size: 12px;
  z-index: 3000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: nh-bd-pan-in 0.2s;
}
.nh-bd-toast.ok   { background: #10b981; }
.nh-bd-toast.err  { background: #dc2626; }
.nh-bd-toast.info { background: #2563eb; }
