.td-chatbot,
.td-chatbot-page {
  --chatbot-primary: #b71922;
  --chatbot-primary-dark: #7f1218;
  --chatbot-accent: #d9b66d;
  --chatbot-ink: #223133;
  --chatbot-muted: #687273;
  --chatbot-border: #e1d4d0;
  --chatbot-surface: #ffffff;
  --chatbot-soft: #fff4f2;
  --chatbot-header: linear-gradient(135deg, #b71922 0%, #7f1218 56%, #263a3a 100%);
  --chatbot-focus: rgba(183, 25, 34, 0.18);
  font-family: Roboto, Arial, sans-serif;
}

.td-chatbot *,
.td-chatbot-page * {
  box-sizing: border-box;
}

.td-chatbot {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1050;
}

.td-chatbot__toggle {
  width: 60px;
  height: 60px;
  border: 1px solid rgba(183, 25, 34, 0.16);
  border-radius: 50%;
  background: #fff;
  color: var(--chatbot-primary);
  box-shadow: 0 12px 28px rgba(55, 24, 26, 0.18);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.td-chatbot__toggle:hover {
  border-color: rgba(183, 25, 34, 0.34);
  box-shadow: 0 16px 34px rgba(55, 24, 26, 0.24);
  transform: translateY(-2px);
}

.td-chatbot__toggle svg {
  width: 28px;
  height: 28px;
}

.arrow_top {
  right: 20px;
  bottom: 92px;
}

.td-chatbot__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 380px;
  height: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
  border: 1px solid rgba(183, 25, 34, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(55, 24, 26, 0.24);
  backdrop-filter: none;
}

.td-chatbot--open .td-chatbot__panel {
  display: flex;
  animation: td-chatbot-slide-up 0.18s ease-out;
}

@keyframes td-chatbot-slide-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.td-chatbot__header,
.td-chatbot-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: #fff;
  background: var(--chatbot-header);
}

.td-chatbot__brand,
.td-chatbot-page__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.td-chatbot__logo,
.td-chatbot-page__logo {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.td-chatbot__title,
.td-chatbot-page__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.td-chatbot__subtitle,
.td-chatbot-page__subtitle {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  line-height: 1.3;
}

.td-chatbot__close,
.td-chatbot__clear {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  color: #fff;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.td-chatbot__close:hover,
.td-chatbot__clear:hover {
  background: rgba(255, 255, 255, 0.14);
}

.td-chatbot__messages,
.td-chatbot-page__messages {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overflow-anchor: none;
  scroll-behavior: auto;
  background: linear-gradient(180deg, #fff8f4 0%, #ffffff 100%);
}

.td-chatbot__message {
  display: flex;
  margin-bottom: 12px;
}

.td-chatbot__message--user {
  justify-content: flex-end;
}

.td-chatbot__bubble {
  width: fit-content;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--chatbot-ink);
  background: var(--chatbot-soft);
  font-size: 14px;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.td-chatbot__message--user .td-chatbot__bubble {
  color: #fff;
  background: var(--chatbot-primary);
}

.td-chatbot__bubble--loading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--chatbot-primary-dark);
  background: #fff;
  border: 1px solid rgba(183, 25, 34, 0.14);
  box-shadow: 0 6px 18px rgba(55, 24, 26, 0.08);
}

.td-chatbot__loading-text {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.td-chatbot__sources {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.td-chatbot__source {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--chatbot-border);
  border-radius: 6px;
  color: var(--chatbot-ink);
  background: #fff;
  text-decoration: none;
}

.td-chatbot__source:hover {
  border-color: var(--chatbot-primary);
  color: var(--chatbot-primary-dark);
  text-decoration: none;
}

.td-chatbot__source-type {
  display: block;
  margin-bottom: 3px;
  color: var(--chatbot-accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.td-chatbot__source-title {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.td-chatbot__form,
.td-chatbot-page__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--chatbot-border);
  background: var(--chatbot-surface);
}

.td-chatbot__input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--chatbot-border);
  border-radius: 6px;
  resize: none;
  color: var(--chatbot-ink);
  font-size: 14px;
  line-height: 1.35;
}

.td-chatbot__input:focus {
  outline: 2px solid var(--chatbot-focus);
  border-color: var(--chatbot-primary);
}

.td-chatbot__send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--chatbot-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.td-chatbot__send:disabled {
  cursor: not-allowed;
  background: #98a2b3;
}

.td-chatbot__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.td-chatbot__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  animation: td-chatbot-dot 1s infinite ease-in-out;
}

.td-chatbot__typing span:nth-child(2) {
  animation-delay: 0.12s;
}

.td-chatbot__typing span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes td-chatbot-dot {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chatbot-page-shell {
  width: min(1120px, calc(100vw - 24px));
  height: clamp(520px, calc(100vh - 220px), 760px);
  height: clamp(520px, calc(100dvh - 220px), 760px);
  margin: 24px auto 40px;
}

.chatbot-full-page {
  height: 100%;
  min-height: 0;
}

.td-chatbot-page {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  border: 1px solid var(--chatbot-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.td-chatbot-page__sidebar {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--chatbot-border);
  background: #fff8f4;
  padding: 16px;
}

.td-chatbot-page__sidebar-title {
  margin: 0 0 12px;
  color: var(--chatbot-ink);
  font-size: 15px;
  font-weight: 700;
}

.td-chatbot-page__conversation {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.td-chatbot-page__history-item {
  padding: 10px;
  border: 1px solid var(--chatbot-border);
  border-radius: 6px;
  background: #fff;
  color: var(--chatbot-muted);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 767px) {
  .chatbot-page-shell {
    width: min(100%, calc(100vw - 16px));
    height: clamp(480px, calc(100vh - 132px), 680px);
    height: clamp(480px, calc(100dvh - 132px), 680px);
    margin: 12px auto 24px;
  }

  .td-chatbot {
    right: 16px;
    bottom: 16px;
  }

  .arrow_top {
    right: 16px;
    bottom: 88px;
  }

  .td-chatbot__panel {
    right: 0;
    bottom: 0;
    width: calc(100vw - 32px);
    height: min(520px, calc(100vh - 32px));
  }

  .td-chatbot-page {
    grid-template-columns: 1fr;
  }

  .td-chatbot-page__sidebar {
    display: none;
  }
}
