/* ============================================================
   NGOBOYI GROUP — AI Assistant widget
   Palette/type inherited from styles.css (:root variables)
   ============================================================ */

.chat-root { font-family: var(--font-body); }

/* Hidden state — author display rules below must not override [hidden].
   Fixes: panel open on load, tabs showing both panes, close not hiding. */
.chat-root [hidden] { display: none !important; }

/* ---------- Floating button ---------- */
.chat-fab {
  position: fixed;
  left: 26px;
  bottom: 26px;
  z-index: 95;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 18px 40px -14px rgba(11, 42, 74, 0.55);
  transition: transform 0.25s ease, filter 0.2s ease;
}
.chat-fab:hover { transform: translateY(-3px); filter: brightness(1.06); }
.chat-fab svg { width: 26px; height: 26px; grid-area: 1 / 1; transition: opacity 0.2s ease, transform 0.25s ease; }
.chat-fab .chat-fab-close { opacity: 0; transform: rotate(-45deg) scale(0.6); }
.chat-fab.open .chat-fab-close { opacity: 1; transform: none; }
.chat-fab.open svg:not(.chat-fab-close) { opacity: 0; transform: rotate(45deg) scale(0.6); }

/* ---------- Panel ---------- */
.chat-panel {
  position: fixed;
  left: 26px;
  bottom: 98px;
  z-index: 130;
  width: min(392px, calc(100vw - 40px));
  height: min(620px, calc(100vh - 130px));
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 80px -30px rgba(11, 42, 74, 0.55);
}

/* ---------- Header ---------- */
.chat-head { background: var(--deep); color: #fff; flex-shrink: 0; }
.chat-head-row { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; }
.chat-avatar {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 3px;
  background: rgba(0, 160, 224, 0.16);
  color: var(--cyan);
  display: grid; place-items: center;
}
.chat-avatar svg { width: 20px; height: 20px; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; display: block; }
.chat-head-txt { flex: 1; min-width: 0; }
.chat-head-txt strong { display: block; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.2; }
.chat-head-txt span { display: flex; align-items: center; gap: 7px; font-size: 0.72rem; color: rgba(255, 255, 255, 0.65); margin-top: 2px; }
.chat-status { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); animation: chat-pulse 2.4s ease-out infinite; }
@keyframes chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.chat-close {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border: 0; border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  display: grid; place-items: center;
  transition: background 0.2s ease, color 0.2s ease;
}
.chat-close:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
.chat-close svg { width: 14px; height: 14px; }

/* ---------- Tabs ---------- */
.chat-tabs { display: flex; gap: 4px; padding: 0 14px; }
.chat-tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 9px 12px 11px;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.chat-tab:hover { color: #fff; }
.chat-tab.active { color: #fff; border-color: var(--cyan); }

/* ---------- Panes ---------- */
.chat-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- Messages ---------- */
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px 16px 8px; background: var(--paper-2); scroll-behavior: smooth; }
.chat-msg { display: flex; margin-bottom: 12px; }
.chat-msg.is-user { justify-content: flex-end; }
.chat-bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 3px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
}
.is-bot .chat-bubble { background: #fff; color: var(--slate); border: 1px solid var(--line-soft); }
.is-user .chat-bubble { background: var(--grad); color: #fff; }
.is-error .chat-bubble { background: #fdf1f0; border-color: rgba(180, 60, 50, 0.25); color: #8c3a32; }

/* typing indicator */
.is-typing .chat-bubble { display: flex; gap: 5px; align-items: center; padding: 14px 16px; }
.is-typing .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); opacity: 0.4; animation: chat-bounce 1.2s infinite; }
.is-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.is-typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-bounce {
  0%, 60%, 100% { transform: none; opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Quick chips ---------- */
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 4px; background: var(--paper-2); }
.chat-chip {
  appearance: none;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--blue-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chat-chip:hover { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- Input row ---------- */
.chat-input-row { display: flex; gap: 10px; align-items: center; padding: 12px 14px 6px; background: var(--paper-2); }
.chat-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--ink);
  transition: border-color 0.2s ease;
}
.chat-input:focus { outline: none; border-color: var(--blue); }
.chat-input:disabled { background: var(--paper-2); }
.chat-send {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 2px;
  background: var(--grad);
  color: #fff;
  display: grid; place-items: center;
  transition: filter 0.2s ease, opacity 0.2s ease;
}
.chat-send svg { width: 16px; height: 16px; }
.chat-send:hover { filter: brightness(1.06); }
.chat-send:disabled { opacity: 0.55; cursor: default; }

.chat-note { padding: 4px 16px 12px; font-size: 0.68rem; line-height: 1.5; color: var(--muted); background: var(--paper-2); margin: 0; }

/* ---------- Enquiry pane ---------- */
.chat-enquiry { flex: 1; overflow-y: auto; padding: 18px 18px 14px; background: var(--paper-2); display: grid; gap: 12px; align-content: start; }
.chat-enquiry-lead { font-size: 0.88rem; line-height: 1.6; color: var(--slate); margin-bottom: 2px; }
.ce-field { display: grid; gap: 5px; }
.ce-field label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; color: var(--ink); }
.ce-field input, .ce-field select, .ce-field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.2s ease;
}
.ce-field textarea { min-height: 88px; resize: vertical; }
.ce-field input:focus, .ce-field select:focus, .ce-field textarea:focus { outline: none; border-color: var(--blue); }
.ce-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ce-submit { width: 100%; justify-content: center; margin-top: 4px; font-size: 0.8rem; padding: 14px 20px; }
.chat-enquiry .chat-note { padding: 0; background: none; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .chat-fab { left: 16px; bottom: 16px; width: 54px; height: 54px; }
  .chat-panel {
    left: 12px;
    right: 12px;
    bottom: 84px;
    width: auto;
    height: min(560px, calc(100vh - 110px));
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-fab, .chat-fab svg, .chat-status, .is-typing .dot { animation: none !important; transition: none !important; }
}

/* ---------- Group palette (gold/ink) ----------
   Maps the widget's accent variables onto the Ngoboyi Group palette. */
.chat-root {
  --cyan: #D4AE30;      /* accent */
  --blue: #B8952A;      /* accent-strong */
  --blue-2: #9A7D22;    /* hover-strong */
  --deep: #1D252A;      /* header / deep backgrounds */
  --deep-2: #000000;
  --grad: linear-gradient(120deg, #E3C24B 0%, #D4AE30 48%, #B8952A 100%);
}

/* Dark ink text on gold surfaces for contrast (matches .btn-primary) */
.chat-fab, .chat-send { color: var(--ink); }
.chat-chip:hover { color: var(--ink); }
.chat-root .is-user .chat-bubble { color: var(--ink); }
