/* NEEMIA RSF - guida operativa contestuale */
.neemia-guide {
  --ng-bg: #08141b;
  --ng-surface: #0d202a;
  --ng-surface-2: #132b36;
  --ng-line: rgba(210, 179, 108, .28);
  --ng-line-soft: rgba(227, 234, 231, .12);
  --ng-gold: #d2b36c;
  --ng-copy: #f3efe6;
  --ng-muted: #aeb9b7;
  position: fixed;
  right: 20px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 890;
  color: var(--ng-copy);
  font-family: "Instrument Sans", Aptos, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.neemia-guide *,
.neemia-guide *::before,
.neemia-guide *::after { box-sizing: border-box; }

.neemia-guide-trigger {
  position: relative;
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  padding: 5px;
  overflow: visible;
  border: 1px solid var(--ng-gold);
  border-radius: 50%;
  background: #071117;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .46), inset 0 0 0 3px rgba(210, 179, 108, .08);
  color: var(--ng-copy);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.neemia-guide-trigger:hover,
.neemia-guide-trigger:focus-visible {
  transform: translateY(-3px);
  border-color: #f2d88f;
  background: #0d202a;
  outline: 2px solid rgba(242, 216, 143, .34);
  outline-offset: 3px;
}

.neemia-guide-trigger img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, .42));
  pointer-events: none;
}

.neemia-guide-trigger::after {
  content: "Guida NEEMIA";
  position: absolute;
  right: 76px;
  top: 50%;
  width: max-content;
  max-width: 180px;
  padding: 7px 9px;
  border: 1px solid var(--ng-line);
  border-radius: 4px;
  background: #071117;
  color: var(--ng-copy);
  font-size: 11px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(5px, -50%);
  transition: opacity .16s ease, transform .16s ease;
}

.neemia-guide-trigger:hover::after,
.neemia-guide-trigger:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.neemia-guide-panel {
  position: absolute;
  right: 0;
  bottom: 82px;
  display: grid;
  width: min(390px, calc(100vw - 32px));
  height: min(610px, calc(100dvh - 118px));
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  border: 1px solid var(--ng-line);
  border-radius: 8px;
  background: var(--ng-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .58);
}

.neemia-guide-panel[hidden] { display: none; }

.neemia-guide-head {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 11px;
  align-items: center;
  min-height: 70px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--ng-line);
  background: #0a1a22;
}

.neemia-guide-head img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.neemia-guide-head strong {
  display: block;
  margin: 0 0 3px;
  color: var(--ng-copy);
  font-size: 14px;
  line-height: 1.2;
}

.neemia-guide-head span {
  display: block;
  color: var(--ng-muted);
  font-size: 10px;
  line-height: 1.3;
  text-transform: uppercase;
}

.neemia-guide-close,
.neemia-guide-reset,
.neemia-guide-send {
  display: grid;
  place-items: center;
  border: 1px solid var(--ng-line-soft);
  background: transparent;
  color: var(--ng-copy);
  cursor: pointer;
}

.neemia-guide-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

.neemia-guide-close:hover,
.neemia-guide-close:focus-visible,
.neemia-guide-reset:hover,
.neemia-guide-reset:focus-visible,
.neemia-guide-send:hover,
.neemia-guide-send:focus-visible {
  border-color: var(--ng-gold);
  background: var(--ng-surface-2);
  outline: 2px solid rgba(210, 179, 108, .22);
  outline-offset: 1px;
}

.neemia-guide-log {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 12px 10px;
  scrollbar-color: var(--ng-gold) transparent;
}

.neemia-guide-message {
  max-width: 90%;
  margin: 0 0 10px;
  padding: 10px 11px;
  border: 1px solid var(--ng-line-soft);
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.52;
}

.neemia-guide-message.guide {
  margin-right: auto;
  background: var(--ng-surface);
  color: var(--ng-copy);
}

.neemia-guide-message.operator {
  margin-left: auto;
  border-color: rgba(210, 179, 108, .38);
  background: #162b31;
  color: #fff;
}

.neemia-guide-message b {
  display: block;
  margin-bottom: 4px;
  color: var(--ng-gold);
  font-size: 11px;
}

.neemia-guide-message p { margin: 0; }
.neemia-guide-message p + p { margin-top: 6px; }

.neemia-guide-suggestions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 10px;
  border-top: 1px solid var(--ng-line-soft);
  scrollbar-width: none;
}

.neemia-guide-suggestions::-webkit-scrollbar { display: none; }

.neemia-guide-chip {
  flex: 0 0 auto;
  min-height: 34px;
  max-width: 230px;
  padding: 7px 9px;
  border: 1px solid var(--ng-line);
  border-radius: 4px;
  background: var(--ng-surface);
  color: var(--ng-copy);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.neemia-guide-chip:hover,
.neemia-guide-chip:focus-visible {
  border-color: var(--ng-gold);
  background: var(--ng-surface-2);
  outline: 0;
}

.neemia-guide-form {
  display: grid;
  grid-template-columns: 36px 1fr 40px;
  gap: 7px;
  align-items: center;
  padding: 9px 10px 10px;
  border-top: 1px solid var(--ng-line);
  background: #071117;
}

.neemia-guide-reset,
.neemia-guide-send {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  font-size: 17px;
}

.neemia-guide-send {
  width: 40px;
  background: var(--ng-gold);
  color: #071117;
  font-size: 20px;
  font-weight: 900;
}

.neemia-guide-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--ng-line-soft);
  border-radius: 4px;
  background: var(--ng-surface);
  color: var(--ng-copy);
  font: inherit;
  font-size: 12px;
  outline: 0;
}

.neemia-guide-input::placeholder { color: #8e9b99; }
.neemia-guide-input:focus { border-color: var(--ng-gold); box-shadow: 0 0 0 2px rgba(210, 179, 108, .16); }

.neemia-guide-note {
  position: absolute;
  right: 0;
  bottom: -18px;
  color: #899492;
  font-size: 8px;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .neemia-guide {
    right: 12px;
    bottom: calc(var(--rd-nav-h, 58px) + 12px + env(safe-area-inset-bottom));
    z-index: 880;
  }

  .neemia-guide-trigger { width: 58px; height: 58px; }
  .neemia-guide-trigger img { width: 44px; height: 44px; }
  .neemia-guide-trigger::after { display: none; }

  .neemia-guide-panel {
    position: fixed;
    inset: 10px 10px calc(var(--rd-nav-h, 58px) + 8px + env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    max-height: none;
  }

  .neemia-guide-note { display: none; }
}

@media (max-width: 420px) {
  .neemia-guide-head { min-height: 62px; grid-template-columns: 42px 1fr auto; padding: 8px 9px; }
  .neemia-guide-head img { width: 40px; height: 40px; }
  .neemia-guide-log { padding: 11px 9px 8px; }
  .neemia-guide-message { max-width: 94%; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .neemia-guide-trigger,
  .neemia-guide-trigger::after { transition: none; }
}

@media print {
  .neemia-guide { display: none !important; }
}
