/* ==========================================================================
   NAVIAR Consult — "veiviser" assistant (chat panel)
   Uses the WEB-28 custom properties from naviar.css.
   ========================================================================== */

/* ------------------------------------------------------- chat toggle */
.nv-chat-toggle {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 85;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--green-900, #0b2c26);
  background: var(--green-900, #0b2c26);
  color: #fff;
  font: inherit;
  font-weight: 760;
  font-size: .88rem;
  letter-spacing: .01em;
  border-radius: var(--radius, 2px);
  box-shadow: 0 18px 50px rgba(3, 28, 24, .28);
  cursor: pointer;
  transition: transform .18s ease, background-color .18s ease;
}
.nv-chat-toggle:hover { background: var(--green-800, #153b33); transform: translateY(-1px); }
.nv-chat-toggle:focus-visible { outline: 2px solid var(--brass, #b88a44); outline-offset: 3px; box-shadow: 0 0 0 3px var(--paper, #fcfbf7), 0 0 0 7px var(--green-900, #0b2c26), 0 18px 50px rgba(3, 28, 24, .28); }
html.nv-chat-open .nv-chat-toggle { display: none; }

/* ------------------------------------------------------- chat panel */
.nv-chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 95;
  width: min(380px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  background: var(--paper, #fcfbf7);
  color: var(--ink, #0b2c26);
  border: 1px solid var(--line, rgba(7,30,25,.14));
  border-top: 5px solid var(--brass-soft, #d8b978);
  border-radius: var(--radius, 2px);
  box-shadow: 0 28px 80px rgba(3, 28, 24, .26);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.nv-chat[hidden] { display: none; }
.nv-chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line, rgba(7,30,25,.14));
}
.nv-chat-title strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.nv-chat-sub { display: block; margin-top: 2px; color: var(--muted, #52635e); font-size: .78rem; }
.nv-chat-close {
  appearance: none; -webkit-appearance: none;
  width: 40px; height: 40px; border: 1px solid transparent; background: transparent; color: var(--ink, #0b2c26);
  border-radius: var(--radius, 2px); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.nv-chat-close:hover { background: var(--warm, #f4f1ea); }
.nv-chat-close:focus-visible { outline: 2px solid var(--brass, #b88a44); outline-offset: 2px; }

.nv-chat-log {
  flex: 1 1 auto;
  min-height: 180px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.nv-msg { max-width: 92%; padding: 10px 13px; font-size: .92rem; line-height: 1.5; border-radius: var(--radius, 2px); }
.nv-msg p { margin: 0; }
.nv-msg-bot { align-self: flex-start; background: #fff; border: 1px solid var(--line, rgba(7,30,25,.14)); }
.nv-msg-user { align-self: flex-end; background: var(--green-900, #0b2c26); color: #fff; }
.nv-msg-link { display: inline-block; margin-top: 8px; color: var(--green-900, #0b2c26); font-weight: 720; text-decoration: none; border-bottom: 1px solid currentColor; }
.nv-msg-link:hover { color: var(--brass, #b88a44); }

.nv-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 18px 10px; }
.nv-chip {
  appearance: none; -webkit-appearance: none;
  padding: 7px 10px; border: 1px solid var(--line, rgba(7,30,25,.14)); background: var(--warm, #f4f1ea); color: var(--ink, #0b2c26);
  font: inherit; font-size: .78rem; font-weight: 650; border-radius: 999px; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.nv-chip:hover { background: var(--mist, #eaf1ed); border-color: var(--brass, #b88a44); }
.nv-chip:focus-visible { outline: 2px solid var(--brass, #b88a44); outline-offset: 2px; }

.nv-chat-form { display: flex; gap: 8px; padding: 8px 18px 6px; border-top: 1px solid var(--line, rgba(7,30,25,.14)); }
.nv-chat-input {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line, rgba(7,30,25,.14)); background: #fff; color: var(--ink, #0b2c26); font: inherit; font-size: .92rem;
  border-radius: var(--radius, 2px);
}
.nv-chat-input:focus-visible { outline: 2px solid var(--brass, #b88a44); outline-offset: 1px; }
.nv-chat-send {
  appearance: none; -webkit-appearance: none;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--green-900, #0b2c26); background: var(--green-900, #0b2c26); color: #fff;
  font: inherit; font-weight: 760; font-size: .88rem; border-radius: var(--radius, 2px); cursor: pointer;
}
.nv-chat-send:hover { background: var(--green-800, #153b33); }
.nv-chat-send:focus-visible { outline: 2px solid var(--brass, #b88a44); outline-offset: 2px; }
.nv-chat-note { margin: 0; padding: 4px 18px 12px; color: var(--muted, #52635e); font-size: .72rem; line-height: 1.4; }

@media (max-width: 560px) {
  .nv-chat { right: 0; bottom: 0; width: 100vw; max-height: 88vh; border-left: 0; border-right: 0; border-bottom: 0; }
  .nv-chat-toggle .nv-chat-toggle-label { display: none; }
  .nv-chat-toggle { padding: 12px 14px; }
}
/* v18 A11Y-03 */
@media (max-height: 500px) { .nv-chat-log { min-height: 0; flex: 0 0 auto; } }
@media (prefers-reduced-motion: reduce) {
  .nv-chat-toggle, .nv-chip { transition: none !important; }
  .nv-chat-log { scroll-behavior: auto; }
}
@media print { .nv-chat, .nv-chat-toggle { display: none !important; } }
