/* ===========================================================
   Nordic Farewell / MinErgo — Care Assistant
   Matches the site palette (styles.css): cream, gold, green,
   Fraunces + Public Sans. Fonts are already imported by
   common/styles.css; this file only styles the widget.
   =========================================================== */

:root {
  --nf-bg: #f3efe7;
  --nf-card: #fbf8f2;
  --nf-border: #eae1d1;
  --nf-ink: #1f1b17;
  --nf-text: #3a352b;
  --nf-muted: #55503f;
  --nf-soft: #8a7f6d;
  --nf-gold: #c0801b;
  --nf-gold-dk: #b06f0f;
  --nf-green: #6d8a3e;
  --nf-dark: #211d18;
  --nf-serif: 'Fraunces', Georgia, serif;
  --nf-sans: 'Public Sans', Arial, sans-serif;
}

/* ---------- Floating bubble ---------- */
#chatBubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: linear-gradient(135deg, #211d18, #3a3226);
  border: 1.5px solid rgba(215, 162, 78, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 34px -10px rgba(31, 27, 23, .6);
  z-index: 1002;
  animation: nfPulse 2.8s infinite;
  transition: transform .2s ease;
}
#chatBubble:hover { transform: scale(1.08); }
#chatBubble img { width: 38px; height: 38px; object-fit: contain; }
@keyframes nfPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 128, 27, .45); }
  50% { box-shadow: 0 0 0 12px rgba(192, 128, 27, 0); }
}

/* ---------- Chat window ---------- */
#chatWindow {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 384px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 150px);
  background: var(--nf-card);
  border: 1px solid var(--nf-border);
  border-radius: 20px;
  box-shadow: 0 30px 70px -28px rgba(31, 27, 23, .55);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1001;
  font-family: var(--nf-sans);
  animation: nfRise .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes nfRise {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Header ---------- */
.chat-header {
  background: linear-gradient(135deg, #211d18, #3a3226);
  color: #f3efe7;
  padding: 16px 16px 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header .ch-logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(243, 239, 231, .08);
  border: 1px solid rgba(215, 162, 78, .35);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-header .ch-logo img { width: 30px; height: 30px; object-fit: contain; }
.chat-header .ch-titles { flex: 1; min-width: 0; }
.chat-header .ch-name { font-family: var(--nf-serif); font-size: 1.08rem; font-weight: 600; letter-spacing: .01em; }
.chat-header .ch-status { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.chat-header .ch-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #8fb35a; box-shadow: 0 0 0 3px rgba(143, 179, 90, .25); }
.chat-header .ch-status span { font-size: .74rem; color: #cdbfa6; }
.chat-header .ch-actions { display: flex; align-items: center; gap: 4px; }
.chat-header .lang-btn {
  background: transparent; color: #cdbfa6;
  border: 1px solid transparent; border-radius: 8px;
  padding: 5px 8px; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; cursor: pointer; font-family: var(--nf-sans);
}
.chat-header .lang-btn.active {
  background: rgba(215, 162, 78, .22); color: #f0d9ad;
  border-color: rgba(215, 162, 78, .5);
}
.chat-header .close-btn {
  background: rgba(243, 239, 231, .1); color: #f3efe7; border: none;
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer;
  font-size: 1rem; margin-left: 2px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Message area ---------- */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: var(--nf-bg);
}
#chat::-webkit-scrollbar { width: 8px; }
#chat::-webkit-scrollbar-thumb { background: #e0d6c4; border-radius: 999px; }

.row { margin: 0 0 14px; animation: nfMsg .3s ease; }
.row.bot { display: flex; gap: 8px; align-items: flex-start; }
.row.user { display: flex; justify-content: flex-end; }
@keyframes nfMsg { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #211d18; border: 1px solid rgba(215, 162, 78, .4);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.avatar img { width: 22px; height: 22px; object-fit: contain; }

.bubble-wrap { max-width: 84%; display: flex; flex-direction: column; }
.row.bot .bubble-wrap { align-items: flex-start; }
.row.user .bubble-wrap { align-items: flex-end; }

.bubble {
  padding: 12px 14px; font-size: .9rem; line-height: 1.6;
  white-space: pre-line;
}
.bot .bubble {
  background: var(--nf-card); border: 1px solid var(--nf-border);
  color: var(--nf-text); border-radius: 4px 16px 16px 16px;
  box-shadow: 0 8px 22px -16px rgba(31, 27, 23, .5);
}
.user .bubble {
  background: var(--nf-dark); color: #f3efe7;
  border-radius: 16px 4px 16px 16px;
}

/* Source "Read more" link (indexing) */
.source-link {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 7px; font-size: .76rem; font-weight: 600;
  color: var(--nf-gold-dk); letter-spacing: .01em; text-decoration: none;
}
.source-link:hover { color: #8a560b; }
.source-link .ico {
  width: 14px; height: 14px; border-radius: 4px; background: #f0e6d3;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--nf-gold-dk); font-size: .6rem;
}

/* ---------- Option chips ---------- */
.buttons { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 6px 38px; }
.buttons button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; background: var(--nf-card); color: var(--nf-ink);
  border: 1px solid #e6ddcc; padding: 11px 14px; border-radius: 12px;
  cursor: pointer; font-family: var(--nf-sans); font-size: .86rem;
  font-weight: 600; line-height: 1.35;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.buttons button .odot { width: 7px; height: 7px; border-radius: 50%; background: var(--nf-gold); flex-shrink: 0; transition: background .18s ease; }
.buttons button:hover { background: var(--nf-dark); color: #f3efe7; border-color: var(--nf-dark); }
.buttons button:hover .odot { background: var(--nf-gold); }

/* ---------- Typing indicator ---------- */
.typing { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; }
.typing .bubble-dots {
  display: inline-flex; gap: 4px; align-items: center;
  background: var(--nf-card); border: 1px solid var(--nf-border);
  padding: 12px 14px; border-radius: 4px 16px 16px 16px;
}
.typing .bubble-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--nf-soft); animation: nfDot 1.2s infinite; }
.typing .bubble-dots i:nth-child(2) { animation-delay: .18s; }
.typing .bubble-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes nfDot { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Input ---------- */
.input-area {
  border-top: 1px solid var(--nf-border); background: var(--nf-card);
  padding: 12px 12px 13px; display: flex; align-items: center; gap: 8px;
}
.input-area input {
  flex: 1; border: 1px solid #e0d6c4; background: #fff;
  border-radius: 999px; padding: 11px 16px;
  font-family: var(--nf-sans); font-size: .88rem; color: var(--nf-text); outline: none;
}
.input-area input:focus { border-color: var(--nf-gold); }
.input-area .send-btn {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%;
  background: var(--nf-gold); color: #201a0f; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.input-area .send-btn:hover { background: var(--nf-gold-dk); }

@media (max-width: 480px) {
  #chatWindow { right: 12px; left: 12px; width: auto; bottom: 96px; }
  #chatBubble { right: 18px; bottom: 18px; }
}
