:root {
  --tbelec-yellow: #ffd400;
  --tbelec-yellow-soft: #fff5b8;
  --tbelec-black: #0b0d0e;
  --tbelec-charcoal: #171a1d;
  --tbelec-white: #ffffff;
  --tbelec-surface: #f3f4f5;
  --tbelec-line: #e0e3e5;
  --tbelec-muted: #62686d;
  --tbelec-danger: #c52424;
}

.tbelec-chat,
.tbelec-chat * {
  box-sizing: border-box;
}

.tbelec-chat {
  position: fixed;
  z-index: 999998;
  right: 24px;
  bottom: 24px;
  color: #17191b;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.tbelec-chat button,
.tbelec-chat textarea,
.tbelec-chat a {
  font: inherit;
}

.tbelec-chat svg {
  display: block;
  width: 22px;
  height: 22px;
}

.tbelec-chat__launcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 214px;
  min-height: 62px;
  margin: 0;
  padding: 8px 17px 8px 9px;
  overflow: visible;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 999px;
  background: var(--tbelec-yellow);
  color: #111;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .28), 0 3px 10px rgba(0, 0, 0, .18);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.tbelec-chat__launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 17px 45px rgba(0, 0, 0, .31), 0 4px 12px rgba(0, 0, 0, .2);
}

.tbelec-chat__launcher-icon {
  position: relative;
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: var(--tbelec-black);
  color: var(--tbelec-yellow);
  font-size: .72rem;
  font-weight: 950;
}

.tbelec-chat__launcher-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.tbelec-chat__launcher-copy {
  display: block;
  flex: 1;
  text-align: left;
  white-space: nowrap;
}

.tbelec-chat__launcher-copy strong,
.tbelec-chat__launcher-copy small {
  display: block;
  color: #111;
}

.tbelec-chat__launcher-copy strong {
  font-size: .96rem;
  font-weight: 900;
  line-height: 1.2;
}

.tbelec-chat__launcher-copy small {
  margin-top: 2px;
  font-size: .73rem;
  font-weight: 700;
  opacity: .72;
}

.tbelec-chat__online {
  position: absolute;
  top: 4px;
  left: 45px;
  width: 12px;
  height: 12px;
  border: 3px solid var(--tbelec-yellow);
  border-radius: 50%;
  background: #22a447;
}

.tbelec-chat__panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(414px, calc(100vw - 32px));
  height: min(700px, calc(100dvh - 118px));
  min-height: 480px;
  overflow: hidden;
  border: 1px solid #25292c;
  border-radius: 22px;
  background: var(--tbelec-white);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .36), 0 6px 20px rgba(0, 0, 0, .16);
  transform-origin: bottom right;
}

.tbelec-chat__panel:not([hidden]) {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto auto;
  animation: tbelec-chat-enter .24s cubic-bezier(.2, .8, .2, 1);
}

@keyframes tbelec-chat-enter {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tbelec-chat__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 14px 14px 14px 16px;
  overflow: hidden;
  background: var(--tbelec-black);
  color: #fff;
}

.tbelec-chat__header::after {
  position: absolute;
  right: -46px;
  bottom: -67px;
  width: 160px;
  height: 120px;
  border: 18px solid rgba(255, 212, 0, .11);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.tbelec-chat__brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.tbelec-chat__advisor,
.tbelec-chat__monogram {
  position: relative;
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--tbelec-yellow);
  border-radius: 50%;
  background: #16191b;
  color: var(--tbelec-yellow);
  object-fit: contain;
  font-size: .86rem;
  font-weight: 950;
}

.tbelec-chat__advisor img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.tbelec-chat__brand strong,
.tbelec-chat__brand span {
  display: block;
  color: #fff;
}

.tbelec-chat__brand strong {
  font-size: 1.04rem;
  font-weight: 900;
  letter-spacing: -.01em;
  line-height: 1.25;
}

.tbelec-chat__brand span {
  margin-top: 4px;
  overflow: hidden;
  font-size: .72rem;
  font-weight: 650;
  opacity: .78;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tbelec-chat__brand i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 6px 1px 0;
  border-radius: 50%;
  background: #30bd5a;
  box-shadow: 0 0 0 3px rgba(48, 189, 90, .14);
}

.tbelec-chat__close {
  position: relative;
  z-index: 2;
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
}

.tbelec-chat__close:hover { background: rgba(255, 255, 255, .16); }
.tbelec-chat__close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }

.tbelec-chat__trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 35px;
  padding: 6px 10px;
  border-bottom: 1px solid #eadb77;
  background: linear-gradient(90deg, #fff7c8, #fff2a3);
  color: #3a3210;
  font-size: .67rem;
  font-weight: 800;
  white-space: nowrap;
}

.tbelec-chat__trust span + span::before {
  margin: 0 8px;
  color: #a08b18;
  content: "•";
}

.tbelec-chat__messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 15px 10px;
  background:
    radial-gradient(circle at 100% 0, rgba(255, 212, 0, .08), transparent 33%),
    linear-gradient(180deg, #f7f8f8 0%, #f1f3f4 100%);
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: #bec3c6 transparent;
  scrollbar-width: thin;
}

.tbelec-chat__message-row {
  display: flex;
  align-items: flex-end;
  max-width: 100%;
  margin: 0 0 14px;
  gap: 7px;
}

.tbelec-chat__message-row--user { justify-content: flex-end; }
.tbelec-chat__avatar {
  position: relative;
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--tbelec-black);
  color: var(--tbelec-yellow);
  font-size: .58rem;
  font-weight: 950;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .16);
}

.tbelec-chat__avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.tbelec-chat__bot-content { min-width: 0; max-width: calc(100% - 35px); }
.tbelec-chat__bubble {
  width: fit-content;
  max-width: 91%;
  padding: 11px 13px;
  border-radius: 15px;
  overflow-wrap: anywhere;
  font-size: .89rem;
  line-height: 1.48;
  white-space: pre-wrap;
}

.tbelec-chat__bubble p { margin: 0 !important; color: inherit !important; font: inherit !important; line-height: inherit !important; }
.tbelec-chat__bubble p + p { margin-top: 9px !important; }
.tbelec-chat__bubble--bot {
  max-width: 100%;
  border: 1px solid #dce0e2;
  border-bottom-left-radius: 4px;
  background: #fff;
  color: #1b1d1f;
  box-shadow: 0 3px 10px rgba(23, 27, 30, .06);
}

.tbelec-chat__bubble--user {
  border-bottom-right-radius: 4px;
  background: var(--tbelec-charcoal);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .15);
}

.tbelec-chat__follow-up {
  padding-top: 8px;
  border-top: 1px solid #eceeef;
  font-weight: 750 !important;
}

.tbelec-chat__message-row.is-danger .tbelec-chat__bubble--bot {
  border-color: #efb1b1;
  border-left: 4px solid var(--tbelec-danger);
  background: #fffafa;
}

.tbelec-chat__sources {
  width: fit-content;
  max-width: 100%;
  margin: 6px 0 0;
  color: var(--tbelec-muted);
  font-size: .7rem;
}

.tbelec-chat__sources summary {
  width: fit-content;
  padding: 2px 0;
  cursor: pointer;
  font-weight: 750;
}

.tbelec-chat__sources ul { margin: 5px 0 0 16px !important; padding: 0 !important; }
.tbelec-chat__sources li { margin: 4px 0 !important; padding: 0 !important; }
.tbelec-chat__sources a { color: #3c4246 !important; text-decoration: underline !important; text-underline-offset: 2px; }

.tbelec-chat__context-actions,
.tbelec-chat__quick-replies {
  display: flex;
  flex-wrap: wrap;
  margin-top: 8px;
  gap: 6px;
}

.tbelec-chat__context-link,
.tbelec-chat__quick-replies button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid #b9bec1;
  border-radius: 999px;
  background: #fff;
  color: #202326 !important;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none !important;
  cursor: pointer;
}

.tbelec-chat__context-link.is-call { border-color: var(--tbelec-black); background: var(--tbelec-black); color: #fff !important; }
.tbelec-chat__context-link.is-quote { border-color: #b79a00; background: var(--tbelec-yellow); color: #111 !important; }
.tbelec-chat__context-link.is-emergency { border-color: #9c1818; background: var(--tbelec-danger); color: #fff !important; }
.tbelec-chat__quick-replies button:hover { border-color: #72630f; background: #fff9d9; }

.tbelec-chat__typing { display: flex; align-items: center; min-width: 62px; min-height: 40px; gap: 5px; }
.tbelec-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #72777a;
  animation: tbelec-chat-dot 1.15s infinite ease-in-out;
}
.tbelec-chat__typing span:nth-child(2) { animation-delay: .15s; }
.tbelec-chat__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes tbelec-chat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

.tbelec-chat__suggestions {
  display: flex;
  min-height: 47px;
  padding: 7px 11px;
  overflow-x: auto;
  border-top: 1px solid var(--tbelec-line);
  background: #fff;
  gap: 6px;
  scrollbar-width: none;
}
.tbelec-chat__suggestions::-webkit-scrollbar { display: none; }
.tbelec-chat__suggestions button {
  flex: 0 0 auto;
  min-height: 31px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #c8ccce;
  border-radius: 999px;
  background: #fff;
  color: #272a2c;
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
}
.tbelec-chat__suggestions button:hover { border-color: #a48b00; background: #fff8cd; }

.tbelec-chat__form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  min-height: 65px;
  padding: 9px 11px;
  border-top: 1px solid var(--tbelec-line);
  background: #fff;
  gap: 8px;
}

.tbelec-chat__form textarea {
  display: block;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 112px;
  margin: 0;
  padding: 10px 12px;
  resize: none;
  border: 1px solid #b7bdc0;
  border-radius: 12px;
  outline: none;
  background: #fbfbfb;
  color: #151719;
  font-size: .85rem;
  line-height: 1.35;
}

.tbelec-chat__form textarea:focus {
  border-color: #a88e00;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 212, 0, .23);
}

.tbelec-chat__form button[type="submit"] {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--tbelec-yellow);
  color: #111;
  cursor: pointer;
}
.tbelec-chat__form button[type="submit"]:hover { filter: brightness(.96); }
.tbelec-chat__form button[type="submit"]:disabled { cursor: wait; filter: grayscale(.25); opacity: .55; }
.tbelec-chat__form button svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.tbelec-chat__website { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }

.tbelec-chat__actions {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  padding: 0 11px 9px;
  background: #fff;
  gap: 7px;
}

.tbelec-chat__actions a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 8px 9px;
  border-radius: 10px;
  font-size: .73rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none !important;
}

.tbelec-chat__actions svg { width: 16px; height: 16px; margin-right: 6px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.tbelec-chat__call { background: var(--tbelec-black); color: #fff !important; }
.tbelec-chat__quote { border: 2px solid var(--tbelec-black); background: #fff; color: var(--tbelec-black) !important; }

.tbelec-chat__privacy {
  margin: 0 !important;
  padding: 0 13px 10px !important;
  background: #fff;
  color: #707579 !important;
  font-size: .61rem !important;
  line-height: 1.35 !important;
  text-align: center;
}
.tbelec-chat__privacy a { color: #505559 !important; text-decoration: underline !important; }

.tbelec-chat button:focus-visible,
.tbelec-chat textarea:focus-visible,
.tbelec-chat a:focus-visible,
.tbelec-chat summary:focus-visible {
  outline: 3px solid #2879bd;
  outline-offset: 2px;
}

@media (max-width: 782px) {
  body.tbelec-chat-open { overflow: hidden; }
  .tbelec-chat {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .tbelec-chat__launcher {
    min-width: 170px;
    min-height: 54px;
    padding: 6px 14px 6px 7px;
  }
  .tbelec-chat__launcher-icon { flex-basis: 42px; width: 42px; height: 42px; }
  .tbelec-chat__launcher-copy strong { font-size: .85rem; }
  .tbelec-chat__launcher-copy small { font-size: .66rem; }
  .tbelec-chat__online { top: 3px; left: 39px; }
  .tbelec-chat__panel {
    position: fixed;
    inset: max(8px, env(safe-area-inset-top)) 8px calc(74px + env(safe-area-inset-bottom)) 8px;
    width: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    border-radius: 18px;
    transform-origin: bottom center;
  }
  .tbelec-chat__messages { padding: 15px 12px 8px; }
  .tbelec-chat__header { min-height: 76px; padding: 11px 12px; }
  .tbelec-chat__advisor,
  .tbelec-chat__monogram { flex-basis: 44px; width: 44px; height: 44px; }
}

@media (max-width: 390px) {
  .tbelec-chat__panel { right: 5px; left: 5px; }
  .tbelec-chat__trust { font-size: .61rem; }
  .tbelec-chat__trust span + span::before { margin: 0 5px; }
  .tbelec-chat__bubble { font-size: .84rem; }
  .tbelec-chat__launcher { min-width: 54px; width: 54px; padding: 6px; }
  .tbelec-chat__launcher-copy { display: none; }
  .tbelec-chat__online { left: 39px; }
}

@media (prefers-reduced-motion: reduce) {
  .tbelec-chat *,
  .tbelec-chat *::before,
  .tbelec-chat *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
