/*
 * Live chat — the floating widget (both skins) and the sysadmin inbox.
 *
 * Kept out of notarium.css deliberately: chat is one workstream's surface,
 * and Propshaft's `stylesheet_link_tag :app` picks up every file under
 * app/assets/stylesheets anyway. Only --nt-* tokens are used, so the widget
 * inherits the wax-seal identity and both themes for free.
 */

/* ── Floating widget ────────────────────────────────────── */

.nt-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.nt-chat-bubble {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: none;
  background: var(--nt-seal);
  color: var(--nt-on-seal);
  box-shadow: var(--nt-shadow-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms var(--nt-ease), background 160ms var(--nt-ease);
}

.nt-chat-bubble:hover { background: var(--nt-seal-hover); transform: translateY(-2px); }
.nt-chat-bubble svg { width: 1.5rem; height: 1.5rem; }

.nt-chat-panel {
  width: min(23rem, calc(100vw - 2.5rem));
  height: min(31rem, calc(100dvh - 8rem));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--nt-surface);
  border: 1px solid var(--nt-hairline);
  border-radius: var(--nt-radius-lg);
  box-shadow: var(--nt-shadow-3);
  transform-origin: bottom right;
  animation: nt-chat-rise 180ms var(--nt-ease);
}

.nt-chat-panel[hidden] { display: none; }

@keyframes nt-chat-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nt-chat-panel { animation: none; }
  .nt-chat-bubble { transition: none; }
}

.nt-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--nt-surface-raised);
  border-bottom: 1px solid var(--nt-hairline);
}

.nt-chat-title {
  font-family: var(--nt-font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
}

.nt-chat-close {
  border: none;
  background: transparent;
  color: var(--nt-ink-faint);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
}

.nt-chat-close:hover { color: var(--nt-ink); background: var(--nt-surface-sunken); }

/* Panel body is a flex column so the log scrolls and the composer pins. */
.nt-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* ── Presence ───────────────────────────────────────────── */

.nt-chat-presence {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--nt-ink-soft);
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--nt-hairline);
}

.nt-chat-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--nt-ink-faint);
  flex: none;
}

.nt-chat-dot.is-online { background: var(--nt-ok); }

/* ── Message log ────────────────────────────────────────── */

.nt-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--nt-paper);
}

.nt-chat-stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.nt-chat-msg {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nt-chat-msg-staff {
  align-self: flex-start;
  background: var(--nt-surface);
  border: 1px solid var(--nt-hairline);
  border-bottom-left-radius: 5px;
}

.nt-chat-msg-customer {
  align-self: flex-end;
  background: var(--nt-seal);
  color: var(--nt-on-seal);
  border-bottom-right-radius: 5px;
}

.nt-chat-msg-meta {
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  opacity: 0.75;
  margin-bottom: 0.15rem;
  display: block;
}

.nt-chat-status {
  font-size: 0.75rem;
  color: var(--nt-ink-soft);
  padding: 0 1rem;
}

.nt-chat-status:empty { display: none; }

.nt-chat-note {
  align-self: center;
  font-size: 0.72rem;
  color: var(--nt-ink-faint);
  background: var(--nt-surface-raised);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
}

/* ── Composer & capture ─────────────────────────────────── */

.nt-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid var(--nt-hairline);
  background: var(--nt-surface);
}

.nt-chat-textarea {
  flex: 1 1 auto;
  resize: none;
  max-height: 8rem;
  min-height: 2.4rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--nt-radius);
  border: 1px solid var(--nt-hairline);
  background: var(--nt-paper);
  color: var(--nt-ink);
  font-family: var(--nt-font-body);
  font-size: 0.9rem;
  line-height: 1.4;
}

.nt-chat-textarea:focus {
  outline: none;
  border-color: var(--nt-seal);
  box-shadow: 0 0 0 3px var(--nt-seal-soft);
}

.nt-chat-send {
  flex: none;
  border: none;
  cursor: pointer;
  background: var(--nt-seal);
  color: var(--nt-on-seal);
  border-radius: var(--nt-radius);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 550;
}

.nt-chat-send:hover { background: var(--nt-seal-hover); }

.nt-chat-capture {
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--nt-hairline);
  background: var(--nt-warn-soft);
  font-size: 0.82rem;
}

.nt-chat-capture form {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.nt-chat-capture input[type="email"] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--nt-hairline);
  background: var(--nt-surface);
  color: var(--nt-ink);
  font-size: 0.85rem;
}

.nt-chat-loading {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--nt-ink-faint);
  font-size: 0.85rem;
}

/* ── "Bestil hjælp" page + sysadmin thread ──────────────── */

.nt-chat-page-log {
  height: min(28rem, 60vh);
  border: 1px solid var(--nt-hairline);
  border-radius: var(--nt-radius-lg);
}

.nt-chat-page-composer {
  border: 1px solid var(--nt-hairline);
  border-top: none;
  border-radius: 0 0 var(--nt-radius-lg) var(--nt-radius-lg);
}

/* ── Sysadmin inbox ─────────────────────────────────────── */

.nt-chat-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.nt-chat-filter {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--nt-hairline);
  font-size: 0.82rem;
  color: var(--nt-ink-soft);
  text-decoration: none;
}

.nt-chat-filter.is-active {
  background: var(--nt-seal);
  border-color: var(--nt-seal);
  color: var(--nt-on-seal);
}

.nt-chat-row {
  display: block;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--nt-hairline);
  text-decoration: none;
  color: inherit;
}

.nt-chat-row:hover { background: var(--nt-surface-raised); }
.nt-chat-row.is-unread { border-left: 3px solid var(--nt-seal); }

.nt-chat-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.nt-chat-row-title { font-weight: 600; font-size: 0.92rem; }
.nt-chat-row-excerpt {
  color: var(--nt-ink-soft);
  font-size: 0.84rem;
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.nt-chat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--nt-seal);
  color: var(--nt-on-seal);
  font-family: var(--nt-font-mono);
  font-size: 0.7rem;
}

.nt-chat-context dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nt-ink-faint);
  margin-top: 0.65rem;
}

.nt-chat-context dd {
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.nt-chat-tripwire {
  background: var(--nt-warn-soft);
  color: var(--nt-warn);
  border-radius: var(--nt-radius);
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}
