/*!
 * Mr. B Handyman Services -- support chat styles
 *
 * Everything is scoped under .mrbchat. Nothing here may style a bare element
 * or a site class: this file loads on every page of a live site, and the theme
 * already owns .chat-message and friends from an older widget.
 *
 * Colors track the theme's own tokens (--brand #c83616, --navy #243b63,
 * --blue #006dac) but are redeclared locally so the widget still looks right
 * on the standalone demo page where the theme stylesheet is absent.
 */

.mrbchat {
  --mc-brand: #c83616;
  --mc-navy: #243b63;
  --mc-blue: #006dac;
  --mc-ink: #101828;
  --mc-muted: #586174;
  --mc-line: #d8e0ea;
  --mc-paper: #ffffff;
  --mc-soft: #eef6ff;
  --mc-bot-bg: #f1f5fb;
  --mc-bot-ink: #101828;
  --mc-me-bg: #243b63;
  --mc-me-ink: #ffffff;
  --mc-shadow: 0 18px 45px rgba(16, 24, 40, .22);
  --mc-radius: 12px;

  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2147483000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--mc-ink);
}

/* ------------------------------------------------------------------- themes */

.mrbchat[data-theme="dark"] {
  --mc-ink: #e8edf6;
  --mc-muted: #a7b2c5;
  --mc-line: #2b3650;
  --mc-paper: #151b29;
  --mc-soft: #1d2639;
  --mc-bot-bg: #1d2639;
  --mc-bot-ink: #e8edf6;
  --mc-me-bg: #2f6fb0;
  --mc-me-ink: #ffffff;
  --mc-shadow: 0 18px 45px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
  .mrbchat[data-theme="auto"] {
    --mc-ink: #e8edf6;
    --mc-muted: #a7b2c5;
    --mc-line: #2b3650;
    --mc-paper: #151b29;
    --mc-soft: #1d2639;
    --mc-bot-bg: #1d2639;
    --mc-bot-ink: #e8edf6;
    --mc-me-bg: #2f6fb0;
    --mc-me-ink: #ffffff;
    --mc-shadow: 0 18px 45px rgba(0, 0, 0, .55);
  }
}

.mrbchat-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ----------------------------------------------------------------- launcher */

.mrbchat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--mc-brand);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--mc-shadow);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.mrbchat-launcher:hover { transform: translateY(-2px); background: #b22f12; }
.mrbchat-launcher:focus-visible { outline: 3px solid var(--mc-blue); outline-offset: 3px; }
.mrbchat-launcher-text { white-space: nowrap; }
.mrbchat.is-open .mrbchat-launcher { display: none; }

/* -------------------------------------------------------------------- panel */

.mrbchat-panel {
  width: 376px;
  max-width: calc(100vw - 32px);
  max-height: min(620px, calc(100vh - 36px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--mc-paper);
  border: 1px solid var(--mc-line);
  border-radius: var(--mc-radius);
  box-shadow: var(--mc-shadow);
  animation: mrbchat-rise .2s ease;
}

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

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

@media (prefers-reduced-motion: reduce) {
  .mrbchat-panel { animation: none; }
  .mrbchat-launcher { transition: none; }
}

/* ------------------------------------------------------------------- header */

.mrbchat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: var(--mc-navy);
  color: #fff;
  flex: 0 0 auto;
}

.mrbchat-avatar {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--mc-brand);
  font-weight: 900;
  font-size: 14px;
  letter-spacing: .5px;
}

.mrbchat-head-text { flex: 1 1 auto; min-width: 0; }
.mrbchat-head-text strong { display: block; font-size: 15px; line-height: 1.25; }

.mrbchat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #cfdcf0;
}

.mrbchat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #8a97ad;
  flex: 0 0 auto;
}
.mrbchat-dot.is-open { background: #35c171; box-shadow: 0 0 0 3px rgba(53, 193, 113, .25); }
.mrbchat-dot.is-closed { background: #e0b341; }

.mrbchat-head-actions { display: flex; gap: 2px; flex: 0 0 auto; }

.mrbchat-icon {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dce6f5;
  cursor: pointer;
}
.mrbchat-icon:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.mrbchat-icon:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ------------------------------------------------------------------- notice */

.mrbchat-notice {
  margin: 0;
  padding: 9px 14px;
  background: var(--mc-soft);
  border-bottom: 1px solid var(--mc-line);
  color: var(--mc-muted);
  font-size: 12px;
  line-height: 1.45;
  flex: 0 0 auto;
}

/* ---------------------------------------------------------------------- log */

.mrbchat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--mc-paper);
  min-height: 160px;
}

.mrbchat-msg { display: flex; flex-direction: column; max-width: 86%; }
.mrbchat-msg.mrbchat-bot { align-self: flex-start; align-items: flex-start; }
.mrbchat-msg.mrbchat-visitor { align-self: flex-end; align-items: flex-end; }

.mrbchat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.mrbchat-bot .mrbchat-bubble {
  background: var(--mc-bot-bg);
  color: var(--mc-bot-ink);
  border-bottom-left-radius: 4px;
}

.mrbchat-visitor .mrbchat-bubble {
  background: var(--mc-me-bg);
  color: var(--mc-me-ink);
  border-bottom-right-radius: 4px;
}

.mrbchat-bubble a { color: var(--mc-blue); font-weight: 700; }
.mrbchat-visitor .mrbchat-bubble a { color: #cfe6ff; }
.mrbchat[data-theme="dark"] .mrbchat-bubble a { color: #7fc2ff; }

.mrbchat-time {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--mc-muted);
}

/* typing */
.mrbchat-typing .mrbchat-bubble {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 13px;
}
.mrbchat-typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--mc-muted);
  animation: mrbchat-blink 1.1s infinite ease-in-out;
}
.mrbchat-typing i:nth-child(2) { animation-delay: .18s; }
.mrbchat-typing i:nth-child(3) { animation-delay: .36s; }

@keyframes mrbchat-blink {
  0%, 80%, 100% { opacity: .28; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .mrbchat-typing i { animation: none; opacity: .6; }
}

/* -------------------------------------------------------------------- chips */

.mrbchat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  flex: 0 0 auto;
}
.mrbchat-chips:empty { display: none; }

.mrbchat-chip {
  border: 1px solid var(--mc-line);
  background: var(--mc-paper);
  color: var(--mc-blue);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
}
.mrbchat-chip:hover { background: var(--mc-soft); }
.mrbchat-chip:focus-visible { outline: 2px solid var(--mc-blue); outline-offset: 1px; }

/* ----------------------------------------------------------------- composer */

.mrbchat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--mc-line);
  background: var(--mc-paper);
  flex: 0 0 auto;
}

.mrbchat-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--mc-line);
  border-radius: 10px;
  background: var(--mc-paper);
  color: var(--mc-ink);
  font: inherit;
}
.mrbchat-input:focus { outline: 2px solid var(--mc-blue); outline-offset: -1px; }
.mrbchat-input::placeholder { color: var(--mc-muted); }

.mrbchat-send {
  width: 44px; height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: var(--mc-brand);
  color: #fff;
  cursor: pointer;
}
.mrbchat-send:hover { background: #b22f12; }
.mrbchat-send:disabled { opacity: .55; cursor: default; }
.mrbchat-send:focus-visible { outline: 2px solid var(--mc-blue); outline-offset: 2px; }

/* ------------------------------------------------------------------ actions */

.mrbchat-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
  flex: 0 0 auto;
}
.mrbchat-actions:empty { display: none; }

.mrbchat-action {
  flex: 1 1 auto;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 900;
  font-size: 13.5px;
  border: 2px solid transparent;
  text-align: center;
}
.mrbchat-action-primary { background: var(--mc-brand); color: #fff; }
.mrbchat-action-primary:hover { background: #b22f12; }
.mrbchat-action-secondary {
  background: var(--mc-paper);
  color: var(--mc-navy);
  border-color: var(--mc-navy);
}
.mrbchat[data-theme="dark"] .mrbchat-action-secondary { color: var(--mc-ink); border-color: var(--mc-line); }
.mrbchat-action:focus-visible { outline: 3px solid var(--mc-blue); outline-offset: 2px; }

/* ------------------------------------------------------------------- mobile */

@media (max-width: 560px) {
  .mrbchat { right: 12px; bottom: 12px; left: 12px; }
  .mrbchat-launcher { width: 100%; justify-content: center; }
  .mrbchat-panel {
    width: auto;
    max-width: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .mrbchat-msg { max-width: 92%; }
  .mrbchat-actions { flex-wrap: wrap; }
  .mrbchat-action { flex: 1 1 44%; }
}

@media (max-width: 380px) {
  .mrbchat-launcher-text { display: none; }
  .mrbchat-launcher { width: 56px; height: 56px; padding: 0; justify-content: center; }
}

/* Respect a visitor who wants more contrast. */
@media (prefers-contrast: more) {
  .mrbchat-bubble { border: 1px solid var(--mc-line); }
  .mrbchat-chip { border-width: 2px; }
}
