/* ChattarBattar widget — BF-1346 Phase 1. First surface: general apex.
 * Dark panel by default (matches the site's dark theme); light override
 * via [data-theme="light"]. Fixed bottom-right bubble; on small
 * screens (BF-1639) the panel goes full-viewport — 100vw/100dvh,
 * top 0, no radius — and the launcher hides while it is open.
 */
.bf-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: #e8b33c;
  color: #0a0f1e;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.bf-chat-bubble:hover { background: #f5d67b; }
.bf-chat-bubble svg { width: 30px; height: 30px; display: block; margin: 0 auto; }

.bf-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 40px));
  height: min(480px, calc(100vh - 120px));
  background: #111a30;
  color: #e8eefc;
  border: 1px solid #26355c;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
/* The hide utility must win over every later single-class display
 * rule in this file (.bf-chat-preview / .bf-chat-listening set
 * display:flex after it): without !important the preview strip and
 * the listening bar render on open even with this class on them —
 * the exact defect the 2026-11-14 staging visual check found. */
.bf-chat-hidden { display: none !important; }

/* v1.4.0 (§2.5): embed mode — the panel fills its host element instead
 * of floating fixed. The host shell (e.g. the JEE overlay) owns
 * position and size; the panel is a static flex column inside it.
 */
.bf-chat-panel.bf-chat-embed {
  position: static;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* v1.4.0 (§2.6): the ticket-status receipt renders as a message row
 * with separate ticket / status / resolution spans (M-26).
 */
.bf-chat-receipt {
  align-self: flex-start;
  background: #1e293b;
  color: #e8eefc;
}

/* v1.4.0 (§3): retry button on transport/display errors. */
.bf-chat-retry {
  display: block;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #e8b33c;
  color: #1a1206;
}

.bf-chat-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #0a0f1e;
  border-bottom: 1px solid #26355c;
  flex-shrink: 0;
}
.bf-chat-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* v1.5.0 note 6: the header names who you are chatting with — the
 * bot's sparkle avatar + title + bot name, stacked. */
.bf-chat-avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%;
  background: #1e293b;
  display: flex; align-items: center; justify-content: center;
}
.bf-chat-avatar svg { width: 20px; height: 20px; display: block; }
.bf-chat-titlewrap { display: flex; flex-direction: column; flex: 1; min-width: 0; margin-left: 10px; }
/* v1.5.0 (BF-1577 item 1): three-dots menu in the header. The menu
 * is absolutely positioned under the button; the header is relative. */
.bf-chat-menu-btn {
  border: 0;
  background: none;
  color: #8fa1c4;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.bf-chat-menu-btn:hover { color: #e8eefc; }
.bf-chat-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 12px;
  z-index: 1001;
  min-width: 150px;
  background: #111a30;
  border: 1px solid #26355c;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 4px;
}
.bf-chat-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: #e8eefc;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.bf-chat-menu-item:hover { background: #1e293b; }
/* v1.5.0 (BF-1185 Phase 2 §13): the AI disclaimer — a static line
 * under the header, visible without scrolling. Small, muted. */
.bf-chat-disclaimer {
  padding: 8px 14px;
  font-size: 11px;
  line-height: 1.4;
  color: #8fa1c4;
  background: #0a0f1e;
  border-bottom: 1px solid #26355c;
  flex-shrink: 0;
}
/* BF-1526: reachability status ("Connecting..." / "Reconnecting...").
 * Empty by default; :empty hides it so the header is unchanged until
 * the backend fails to answer. */
.bf-chat-status { font-size: 12px; color: #8fa1c4; white-space: nowrap; }
.bf-chat-status:empty { display: none; }
.bf-chat-close {
  border: 0;
  background: none;
  color: #8fa1c4;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.bf-chat-close:hover { color: #e8eefc; }
/* BF-1670 (Sundar #2): Start New Conversation in the persistent
 * header — Close alone, no Minimize. A small pill so it fits
 * next to the title on a 360px panel; the title truncates
 * (ellipsis) before this button ever squeezes. */
.bf-chat-newchat {
  flex-shrink: 0;
  border: 1px solid #e8b33c;
  border-radius: 16px;
  background: none;
  color: #e8b33c;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  padding: 6px 10px;
  cursor: pointer;
}
.bf-chat-newchat:hover { background: #1e293b; }

.bf-chat-log {
  flex: 1;
  /* BF-1667: min-height: 0 — the flexbox trap. Without it the
   * log's min-height is auto (its content height), so on a short
   * viewport (keyboard open, 100dvh shrunk) the log refuses to
   * shrink and the composer below it is pushed out of the panel
   * and clipped by overflow: hidden — the "white thing" not
   * showing. With min-height: 0 the log absorbs the shrink and
   * the composer always stays visible. */
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* v1.5.0 note 4: smooth, touch-friendly scrolling. */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
/* BF-1639: initial suggestion chips ("WAYS I CAN HELP", Erica).
 * A fixed section under the log, above the composer — not part of
 * the scrollable log, so the chips stay put until the first ask.
 * Chips are right-aligned pills; MORE opens the second row. */
.bf-chat-suggestions {
  padding: 10px 12px 8px;
  border-top: 1px solid #26355c;
  background: #0a0f1e;
  flex-shrink: 0;
}
.bf-chat-suggestions-label {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #8fa1c4;
  margin-bottom: 8px;
}
.bf-chat-suggestions-chips,
.bf-chat-suggestions-more {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.bf-chat-suggestions-more { margin-top: 8px; }
.bf-chat-suggestion {
  border: 1.5px solid #e8b33c;
  border-radius: 20px;
  background: transparent;
  color: #e8eefc;
  font-size: 13px;
  line-height: 1.35;
  padding: 8px 14px;
  cursor: pointer;
  max-width: 100%;
  text-align: right;
}
.bf-chat-suggestion:hover { background: #1e293b; }
.bf-chat-suggestions-more-btn {
  /* display:block + margin-left:auto: the parent is a block div,
   * so align-self would be dead — this right-aligns MORE under
   * the right-aligned chips (caught in the render proof). */
  display: block;
  margin-left: auto;
  border: 0;
  background: none;
  color: #8fa1c4;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 6px 2px;
}
/* BF-1669: "Browse Full Help Center" — the full FAQ in a new tab.
 * Right-aligned under MORE, in the suggestions section, so it
 * shows pre-conversation and returns on New chat, like the chips. */
.bf-chat-help-center {
  display: block;
  margin: 8px 2px 0 auto;
  width: fit-content;
  color: #e8b33c;
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bf-chat-help-center:hover { color: #f5d67b; }
/* BF-1639: screen-reader-only live region for the mic voice
 * toggle (Sundar BF-1603 condition 2). Visually hidden. */
.bf-chat-voice-status {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.bf-chat-msg {
  max-width: 92%;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.bf-chat-user {
  align-self: flex-end;
  background: #e8b33c;
  color: #1a1206;
  /* v1.5.0 note 1: crisper 1px borders keep the two-tone
   * bubbles distinct at a glance. */
  border: 1px solid #c99a2e;
}
.bf-chat-answer {
  align-self: flex-start;
  background: #1e293b;
  color: #e8eefc;
  border: 1px solid #2b3a5c;
}
/* BF-1637: the Tess avatar above each bot message; the name "Tess" only on the welcome row. */
.bf-chat-agent-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.bf-chat-agent-avatar {
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 50%;
  background: #0a0f1e;
  display: flex; align-items: center; justify-content: center;
}
.bf-chat-agent-avatar img { width: 20px; height: 20px; border-radius: 50%; display: block; }
.bf-chat-agent-name { font-size: 12px; font-weight: 600; color: #f5d67b; }
/* v1.5.0 note 5: per-message local-time timestamp (+ "replied
 * after …" on answers that followed a wait). Small, subtle. */
.bf-chat-time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #8fa1c4;
}
.bf-chat-user .bf-chat-time { color: #6b5312; text-align: right; }
/* v1.5.0 note 5: muted notice lines (upload guards, mic states,
 * the first-use STT disclosure). No bubble, no ticket number. */
.bf-chat-notice {
  align-self: center;
  background: none;
  color: #8fa1c4;
  font-size: 12px;
  padding: 2px 4px;
  max-width: 96%;
  text-align: center;
}
.bf-chat-working {
  align-self: flex-start;
  background: none;
  color: #8fa1c4;
  font-style: italic;
}
/* v1.5.0 note 2: the typing indicator — three animated dots +
 * a live wait clock. */
.bf-chat-dots { margin-left: 6px; }
.bf-chat-dot { animation: bf-chat-blink 1.2s infinite; }
.bf-chat-dot:nth-child(2) { animation-delay: 0.2s; }
.bf-chat-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bf-chat-blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.bf-chat-wait { margin-left: 6px; font-size: 12px; font-style: normal; }
.bf-chat-ticket {
  align-self: flex-start;
  background: none;
  color: #8fa1c4;
  font-size: 12px;
  padding: 0 4px;
}
.bf-chat-followup {
  align-self: flex-start;
  background: none;
  padding: 0 4px;
}
.bf-chat-followup a {
  color: #f5d67b;
  text-decoration: underline;
  font-size: 13px;
  font-weight: 600;
}
.bf-chat-confirm {
  align-self: flex-start;
  background: #1e293b;
  color: #e8eefc;
  max-width: 96%;
}
.bf-chat-echo {
  margin: 6px 0;
  padding: 6px 8px;
  background: #0a0f1e;
  border-radius: 6px;
  font-style: italic;
}
.bf-chat-confirm-row { display: flex; gap: 8px; margin-top: 8px; }
.bf-chat-confirm-row button {
  border: 0;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.bf-chat-confirm-yes { background: #e8b33c; color: #1a1206; }
.bf-chat-confirm-no { background: #334155; color: #e8eefc; }

.bf-chat-form {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-top: 1px solid #26355c;
  background: #0a0f1e;
  /* BF-1667: the composer never shrinks — the log (min-height: 0)
   * absorbs every viewport squeeze instead. */
  flex-shrink: 0;
}
.bf-chat-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1e293b;
  color: #e8eefc;
  padding: 9px 10px;
  font-size: 16px;
}
/* Placeholder text is shorter than the input text size so the full
 * prompt reads in the narrow composer. Measured 2026-11-14 (round 2):
 * the 360px panel leaves ~102px of input content width at gap 6px, so
 * "Ask a question…" at 14px (106px Arial-metric, 117px DejaVu) still
 * clipped its third dot on the staging check. Round 2: text without
 * the ellipsis at 13px (85px Arial-metric, 96px DejaVu) plus a wider
 * input (gap 4px, Send/mute padding trimmed) leaves ~122px of content
 * width — >=26px clearance even on the wide DejaVu metric. */
.bf-chat-input::placeholder { font-size: 13px; }
.bf-chat-input:disabled { opacity: 0.6; }
.bf-chat-send {
  border: 0;
  border-radius: 8px;
  background: #e8b33c;
  color: #1a1206;
  font-weight: 700;
  padding: 9px 10px;
  font-size: 16px;
  cursor: pointer;
}
.bf-chat-send:disabled { opacity: 0.6; cursor: default; }

/* v1.5.0: composer buttons — "+" attach, mic. BF-1639: the mic
 * is the voice toggle (Mute button removed); its listening state
 * is the gold aria-pressed background + stop-square icon. */
.bf-chat-attach,
.bf-chat-mic {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: #1e293b;
  color: #e8eefc;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.bf-chat-attach:hover, .bf-chat-mic:hover { background: #2b3a5c; }
.bf-chat-mic svg { width: 20px; height: 20px; display: block; }
.bf-chat-mic[aria-pressed="true"] { background: #e8b33c; color: #1a1206; }
.bf-chat-file { display: none; }

/* v1.5.0: file preview strip — thumbnail for images, name + size
 * for documents, plus Jeff's PII banner line. */
.bf-chat-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #26355c;
  background: #0a0f1e;
}
.bf-chat-preview-img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.bf-chat-preview-name { font-size: 13px; color: #e8eefc; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bf-chat-preview-remove {
  border: 0; border-radius: 6px;
  background: #334155; color: #e8eefc;
  font-size: 12px; font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
}
.bf-chat-pii {
  flex-basis: 100%;
  font-size: 11px;
  font-style: italic;
  color: #8fa1c4;
}

/* v1.5.0: listening bar — shown while speech recognition runs. */
.bf-chat-listening {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid #26355c;
  background: #0a0f1e;
}
.bf-chat-listening-label { color: #e8b33c; font-weight: 600; font-size: 13px; flex: 1; }
.bf-chat-stop {
  border: 0; border-radius: 6px;
  background: #334155; color: #e8eefc;
  font-size: 12px; font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}

[data-theme="light"] .bf-chat-panel {
  background: #ffffff;
  color: #17233d;
  border-color: #cbd5e1;
}
[data-theme="light"] .bf-chat-header,
[data-theme="light"] .bf-chat-form { background: #f2f5fa; border-color: #cbd5e1; }
[data-theme="light"] .bf-chat-answer,
[data-theme="light"] .bf-chat-confirm { background: #eef2f7; color: #17233d; }
[data-theme="light"] .bf-chat-echo { background: #e2e8f0; }
[data-theme="light"] .bf-chat-input { background: #ffffff; color: #17233d; border-color: #cbd5e1; }
[data-theme="light"] .bf-chat-working,
[data-theme="light"] .bf-chat-ticket,
[data-theme="light"] .bf-chat-close { color: #55648a; }
[data-theme="light"] .bf-chat-status { color: #55648a; }
[data-theme="light"] .bf-chat-receipt { background: #eef2f7; color: #17233d; }
[data-theme="light"] .bf-chat-followup a { color: #96690d; }
[data-theme="light"] .bf-chat-disclaimer { background: #f2f5fa; border-color: #cbd5e1; color: #55648a; }
[data-theme="light"] .bf-chat-agent-name { color: #96690d; }
[data-theme="light"] .bf-chat-time { color: #55648a; }
[data-theme="light"] .bf-chat-user .bf-chat-time { color: #6b5312; }
[data-theme="light"] .bf-chat-notice { color: #55648a; }
[data-theme="light"] .bf-chat-menu { background: #ffffff; border-color: #cbd5e1; }
[data-theme="light"] .bf-chat-menu-item { color: #17233d; }
[data-theme="light"] .bf-chat-menu-item:hover { background: #eef2f7; }
[data-theme="light"] .bf-chat-menu-btn { color: #55648a; }
[data-theme="light"] .bf-chat-attach,
[data-theme="light"] .bf-chat-mic { background: #eef2f7; color: #17233d; }
[data-theme="light"] .bf-chat-suggestions { background: #f2f5fa; border-color: #cbd5e1; }
[data-theme="light"] .bf-chat-suggestions-label,
[data-theme="light"] .bf-chat-suggestions-more-btn { color: #55648a; }
[data-theme="light"] .bf-chat-suggestion { border-color: #96690d; color: #17233d; }
[data-theme="light"] .bf-chat-suggestion:hover { background: #eef2f7; }
[data-theme="light"] .bf-chat-preview,
[data-theme="light"] .bf-chat-listening { background: #f2f5fa; border-color: #cbd5e1; }
[data-theme="light"] .bf-chat-newchat { border-color: #96690d; color: #96690d; }
[data-theme="light"] .bf-chat-newchat:hover { background: #eef2f7; }
[data-theme="light"] .bf-chat-help-center { color: #96690d; }
[data-theme="light"] .bf-chat-preview-name { color: #55648a; }
[data-theme="light"] .bf-chat-pii { color: #55648a; }

/* BF-1639: small screens go FULL-SCREEN (Raj Nov 15, Erica) — the
 * panel fills the viewport, composer pinned at the bottom (flex
 * column, form last). This also fixes BF-1633 (panel jumps, top
 * blocked/out of range on phones): there is no floating panel
 * edge left to jump to. Matches the site's own 560px breakpoint
 * (main.css). Desktop is untouched. */
@media (max-width: 560px) {
  .bf-chat-panel {
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; max-width: 100%;
    height: 100vh;          /* fallback */
    height: 100dvh;         /* tracks the keyboard as it opens/closes */
    border: 0;
    border-radius: 0;
  }
  /* The launcher hides while the full-screen panel is open —
   * aria-expanded is set by setOpen, so this is mobile-only. */
  .bf-chat-bubble[aria-expanded="true"] {
    display: none;
  }
  .bf-chat-bubble {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .bf-chat-form {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .bf-chat-send { flex-shrink: 0; }
  /* BF-1670: the header button compacts on phones so it fits next
   * to the title; the full "Start New Conversation" label stays. */
  .bf-chat-newchat { font-size: 11px; padding: 5px 8px; }
}
