.fic-chatbot {
  --fic-accent: #ff5a1f;
  --fic-on-accent: #171717;
  --fic-ink: #171717;
  --fic-muted: #737373;
  --fic-surface: #fff;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 999999;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--fic-ink);
}

.fic-chatbot *, .fic-chatbot *::before, .fic-chatbot *::after { box-sizing: border-box; }

.fic-chatbot__toggle {
  display: grid;
  width: 60px;
  height: 60px;
  padding: 0;
  margin-left: auto;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--fic-accent);
  border-radius: 50%;
  color: #fff;
  background: var(--fic-ink);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .22);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.fic-chatbot__toggle:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(0, 0, 0, .27); }
.fic-chatbot__toggle:focus-visible, .fic-chatbot button:focus-visible, .fic-chatbot textarea:focus-visible, .fic-chatbot a:focus-visible { outline: 3px solid color-mix(in srgb, var(--fic-accent), white 45%); outline-offset: 3px; }
.fic-chatbot__toggle-avatar { width: 100%; height: 100%; max-width: none; border-radius: 50%; object-fit: cover; transform-origin: 50% 50%; animation: fic-tom-idle 3.4s ease-in-out infinite; }
.fic-chatbot__toggle:hover .fic-chatbot__toggle-avatar { animation: fic-tom-greet .65s ease-in-out; }

.fic-chatbot__panel {
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 32px));
  height: min(610px, calc(100vh - 110px));
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(23, 23, 23, .1);
  border-radius: 22px;
  background: var(--fic-surface);
  box-shadow: 0 25px 70px rgba(0, 0, 0, .24);
  animation: fic-enter .2s ease-out;
}

.fic-chatbot__panel[hidden] { display: none; }

.fic-chatbot__header {
  display: flex;
  align-items: center;
  min-height: 70px;
  padding: 16px 18px;
  color: #fff;
  background: var(--fic-ink);
}

.fic-chatbot__header strong { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.fic-chatbot__avatar-shell { position: relative; flex: 0 0 43px; width: 43px; height: 43px; margin-right: 11px; overflow: visible; border: 2px solid var(--fic-accent); border-radius: 50%; background: #2b2b2b; }
.fic-chatbot__header-avatar { width: 100%; height: 100%; max-width: none; border-radius: 50%; object-fit: cover; transform-origin: 50% 72%; animation: fic-tom-idle 3.8s ease-in-out infinite reverse; }
.fic-chatbot__status { position: absolute; right: -1px; bottom: -1px; z-index: 1; width: 9px; height: 9px; border: 2px solid var(--fic-ink); border-radius: 50%; background: #57d68d; box-shadow: 0 0 0 3px rgba(87, 214, 141, .15); }
.fic-chatbot__close { width: 38px; height: 38px; margin-left: auto; border: 0; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .1); font: 300 27px/1 sans-serif; cursor: pointer; }

.fic-chatbot__messages {
  flex: 1;
  min-height: 0;
  padding: 20px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f6f6f4;
}

.fic-chatbot__message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 13px; }
.fic-chatbot__message--user { align-items: flex-end; }
.fic-chatbot__bubble { max-width: 86%; padding: 11px 14px; border-radius: 16px 16px 16px 5px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.fic-chatbot__message--user .fic-chatbot__bubble { color: var(--fic-on-accent); border-radius: 16px 16px 5px 16px; background: var(--fic-accent); }
.fic-chatbot__message.is-pending .fic-chatbot__bubble { color: var(--fic-muted); animation: fic-pulse 1.2s ease-in-out infinite; }
.fic-chatbot__message.is-error .fic-chatbot__bubble { color: #9f1d1d; background: #fff0f0; }

.fic-chatbot__products { display: grid; width: min(94%, 345px); margin-top: 7px; gap: 7px; }
.fic-chatbot__product-card { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 58px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .09); border-radius: 12px; color: var(--fic-ink); background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); text-decoration: none; }
.fic-chatbot__product-card.has-image { grid-template-columns: 58px minmax(0, 1fr); }
.fic-chatbot__product-card:hover { border-color: var(--fic-accent); box-shadow: 0 4px 14px rgba(0, 0, 0, .1); }
.fic-chatbot__product-card img { width: 58px; height: 100%; min-height: 58px; max-height: 76px; object-fit: cover; }
.fic-chatbot__product-body { display: flex; min-width: 0; padding: 8px 10px; flex-direction: column; justify-content: center; gap: 2px; }
.fic-chatbot__product-body strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.fic-chatbot__product-price { color: var(--fic-ink); font-size: 13px; font-weight: 750; }
.fic-chatbot__product-availability { color: #287a38; font-size: 11px; }
.fic-chatbot__product-availability.fic-stock-outofstock { color: #a12727; }
.fic-chatbot__product-availability.fic-stock-onbackorder { color: #8a6500; }
.fic-chatbot__sources { width: min(86%, 320px); margin-top: 6px; padding: 8px 11px; border-radius: 10px; color: var(--fic-muted); background: rgba(255, 255, 255, .72); font-size: 12px; }
.fic-chatbot__sources summary { cursor: pointer; font-weight: 650; }
.fic-chatbot__sources a { display: block; margin-top: 6px; overflow: hidden; color: var(--fic-accent); text-overflow: ellipsis; white-space: nowrap; }

.fic-chatbot__feedback { display: flex; align-items: center; gap: 5px; margin: 5px 0 0 4px; color: var(--fic-muted); font-size: 12px; }
.fic-chatbot__feedback button { width: 30px; height: 28px; padding: 0; border: 1px solid #ddd; border-radius: 9px; background: #fff; cursor: pointer; }
.fic-chatbot__feedback button:hover { border-color: var(--fic-accent); }
.fic-chatbot__feedback button:disabled { opacity: .55; cursor: default; }

.fic-chatbot__lead-area { padding: 0 12px; border-top: 1px solid #e9e9e7; background: #fff; }
.fic-chatbot__lead-toggle { margin: 8px 0; padding: 7px 11px; border: 1px solid var(--fic-accent); border-radius: 10px; color: var(--fic-ink); background: #fff; font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.fic-chatbot__lead-form { display: grid; padding: 4px 2px 16px; gap: 10px; }
.fic-chatbot__lead-form[hidden] { display: none; }
.fic-chatbot__lead-form > strong { margin: 2px 0 4px; font-size: 20px; line-height: 1.2; }
.fic-chatbot__lead-form input:not([type="checkbox"]) { width: 100%; min-height: 38px; margin: 0; padding: 8px 10px; border: 1px solid #d9d9d6; border-radius: 9px; background: #fff; font: inherit; font-size: 13px; }
.fic-chatbot__lead-form label { color: var(--fic-muted); font-size: 11px; line-height: 1.35; }
.fic-chatbot__lead-form button[type="submit"] { min-height: 38px; border: 0; border-radius: 9px; color: var(--fic-on-accent); background: var(--fic-accent); font-weight: 700; cursor: pointer; }

.fic-chatbot__panel.is-lead-mode .fic-chatbot__messages,
.fic-chatbot__panel.is-lead-mode > .fic-chatbot__form { display: none; }
.fic-chatbot__panel.is-lead-mode .fic-chatbot__lead-area { flex: 1; min-height: 0; padding: 10px 14px 14px; overflow-y: auto; border-top: 0; background: #f8f8f6; }
.fic-chatbot__panel.is-lead-mode .fic-chatbot__lead-toggle { margin: 0 0 10px; border-color: #d4d4d0; background: transparent; }
.fic-chatbot__panel.is-lead-mode .fic-chatbot__lead-form { padding: 16px; border: 1px solid #e4e4df; border-radius: 16px; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .06); }

.fic-chatbot__form { position: relative; display: flex; align-items: flex-end; min-height: 72px; padding: 11px 12px; gap: 8px; border-top: 1px solid #e9e9e7; background: #fff; }
.fic-chatbot__form textarea { flex: 1; min-height: 46px; max-height: 110px; margin: 0; padding: 12px 14px; resize: none; border: 1px solid #d9d9d6; border-radius: 14px; color: var(--fic-ink); background: #fff; font: inherit; font-size: 14px; line-height: 1.45; box-shadow: none; }
.fic-chatbot__form button { flex: 0 0 46px; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 13px; color: var(--fic-on-accent); background: var(--fic-accent); font-size: 21px; cursor: pointer; }
.fic-chatbot__form button:disabled, .fic-chatbot__form textarea:disabled { opacity: .55; cursor: wait; }
.fic-chatbot__trap { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@keyframes fic-enter { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fic-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes fic-tom-idle { 0%, 100% { transform: rotate(-.8deg); } 50% { transform: rotate(.8deg); } }
@keyframes fic-tom-greet { 0%, 100% { transform: rotate(0) scale(1); } 35% { transform: rotate(-7deg) scale(1.08); } 70% { transform: rotate(6deg) scale(1.08); } }

@media (max-width: 520px) {
  .fic-chatbot { right: 12px; bottom: 12px; }
  .fic-chatbot__panel { width: calc(100vw - 24px); height: min(650px, calc(100dvh - 88px)); margin-bottom: 10px; border-radius: 18px; }
  .fic-chatbot__toggle { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .fic-chatbot__panel, .fic-chatbot__toggle, .fic-chatbot__toggle-avatar, .fic-chatbot__header-avatar, .fic-chatbot__message.is-pending .fic-chatbot__bubble { animation: none; transition: none; }
}
