:root {
  --chat-surface: #fbfcff;
  --chat-surface-raised: #fff;
  --chat-surface-muted: #f2f4fa;
  --chat-ink: #171a28;
  --chat-muted: #777d90;
  --chat-line: rgba(31, 39, 67, .1);
  --chat-accent: #6959e8;
  --chat-accent-2: #a274f5;
  --chat-accent-soft: rgba(105, 89, 232, .1);
  --chat-shadow: 0 30px 90px rgba(9, 14, 35, .24);
  --chat-header: #171929;
}

html[data-theme="dark"] {
  --chat-surface: #11131c;
  --chat-surface-raised: #171a25;
  --chat-surface-muted: #1d202c;
  --chat-ink: #f2f2fa;
  --chat-muted: #a2a5b6;
  --chat-line: rgba(228, 230, 255, .1);
  --chat-accent: #9c8bff;
  --chat-accent-2: #c58eff;
  --chat-accent-soft: rgba(156, 139, 255, .13);
  --chat-shadow: 0 30px 90px rgba(0, 0, 0, .52);
  --chat-header: #131522;
}

.chatbot-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: 'Poppins', sans-serif;
}

.chatbot-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(140deg, #6d5bea, #a277f4 58%, #6ccdb8);
  box-shadow: 0 12px 36px rgba(76, 57, 191, .34), inset 0 1px rgba(255,255,255,.35);
  cursor: pointer;
  transition: transform .24s ease, box-shadow .24s ease;
}

.chatbot-toggle:hover {
  transform: translateY(-4px) scale(1.035);
  box-shadow: 0 18px 42px rgba(76, 57, 191, .4), inset 0 1px rgba(255,255,255,.35);
}

.chatbot-toggle__icon, .chatbot-toggle__icon svg { width: 28px; height: 28px; }
.chatbot-toggle__badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #6be0b6;
  box-shadow: 0 0 0 4px rgba(107,224,182,.18);
  animation: chatBadgePulse 2.6s ease infinite;
}

.chatbot-panel {
  position: fixed;
  right: 24px;
  bottom: 102px;
  display: flex;
  flex-direction: column;
  width: min(790px, calc(100vw - 40px));
  height: min(690px, calc(100vh - 135px));
  min-width: 580px;
  min-height: 430px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 130px);
  resize: both;
  overflow: hidden;
  color: var(--chat-ink);
  background: color-mix(in srgb, var(--chat-surface) 94%, transparent);
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 22px;
  box-shadow: var(--chat-shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: chatPanelIn .28s cubic-bezier(.2,.8,.2,1) both;
}

.chatbot-panel[hidden], [hidden] { display: none !important; }
.chatbot-panel.chatbot-panel--fullscreen {
  inset: 3vh 3vw;
  width: 94vw;
  height: 94vh;
  max-width: none;
  max-height: none;
  min-width: 0;
  min-height: 0;
  resize: none;
  border-radius: 24px;
}

.chatbot-header {
  display: flex;
  flex: 0 0 70px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  color: #f7f6ff;
  background:
    radial-gradient(ellipse at 2% 5%, rgba(128, 101, 245, .5), transparent 36%),
    linear-gradient(108deg, #191a2d, #222039 56%, #282243);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.chatbot-header__identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.chatbot-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 14px;
  color: white;
  background: linear-gradient(145deg, #8b70f2, #ac7bf0 58%, #54c8ba);
  box-shadow: 0 0 24px rgba(146, 111, 240, .35);
  animation: chatAvatarBreathe 4s ease-in-out infinite;
}
.chatbot-avatar span { font-size: 20px; }
.chatbot-header__copy { min-width: 0; }
.chatbot-header__identity strong { display: block; overflow: hidden; font-size: .92rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.chatbot-header__identity small { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: #b6b5c8; font-size: .7rem; }
.chatbot-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #65d9ad; box-shadow: 0 0 8px #65d9ad; }
.chatbot-actions { display: flex; align-items: center; gap: 7px; }
.chatbot-icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 10px;
  color: #e5e3f0;
  background: rgba(255,255,255,.07);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.chatbot-icon-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.15); }
.chatbot-close { font-size: 1.35rem; }
.chatbot-history-toggle { display: none; }

.chatbot-workspace { display: flex; flex: 1; min-height: 0; background: var(--chat-surface); }
.chatbot-sidebar {
  display: flex;
  width: 218px;
  flex: 0 0 218px;
  flex-direction: column;
  min-height: 0;
  padding: 14px 11px 10px;
  background: var(--chat-surface-muted);
  border-right: 1px solid var(--chat-line);
}
.chatbot-sidebar__top { flex: 0 0 auto; }
.chatbot-new-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid var(--chat-line);
  border-radius: 11px;
  color: var(--chat-ink);
  background: var(--chat-surface-raised);
  font: inherit;
  font-size: .76rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border .18s ease, box-shadow .18s ease;
}
.chatbot-new-button:hover { border-color: var(--chat-accent); box-shadow: 0 5px 16px var(--chat-accent-soft); }
.chatbot-new-button span { color: var(--chat-accent); font-size: 1.15rem; }
.chatbot-search { display: flex; align-items: center; gap: 8px; margin: 11px 0 17px; padding: 8px 9px; border: 1px solid var(--chat-line); border-radius: 9px; color: var(--chat-muted); background: var(--chat-surface-raised); }
.chatbot-search > span:not(.sr-only) { font-size: 1.1rem; }
.chatbot-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--chat-ink); background: transparent; font: inherit; font-size: .69rem; }
.chatbot-search input::placeholder { color: var(--chat-muted); }
.chatbot-sidebar__label { padding: 0 6px 6px; color: var(--chat-muted); font-size: .58rem; font-weight: 700; letter-spacing: .14em; }
.chatbot-history { flex: 1; min-height: 0; overflow-y: auto; }
.chatbot-history__empty { padding: 9px 7px; color: var(--chat-muted); font-size: .68rem; line-height: 1.6; }
.chatbot-history__item { position: relative; display: flex; width: 100%; align-items: center; gap: 6px; margin: 2px 0; padding: 8px 7px; border: 1px solid transparent; border-radius: 9px; color: var(--chat-muted); background: transparent; font: inherit; text-align: left; cursor: pointer; }
.chatbot-history__item:hover, .chatbot-history__item.is-active { color: var(--chat-ink); border-color: var(--chat-line); background: var(--chat-surface-raised); }
.chatbot-history__title { flex: 1; overflow: hidden; font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.chatbot-history__menu { opacity: 0; border: 0; color: var(--chat-muted); background: transparent; cursor: pointer; }
.chatbot-history__item:hover .chatbot-history__menu, .chatbot-history__item:focus-within .chatbot-history__menu { opacity: 1; }
.chatbot-history__actions { position: absolute; z-index: 3; top: calc(100% - 2px); right: 4px; display: flex; min-width: 126px; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--chat-line); border-radius: 9px; background: var(--chat-surface); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.chatbot-history__actions button { padding: 6px 8px; border: 0; border-radius: 6px; color: var(--chat-ink); background: var(--chat-surface-raised); font: inherit; font-size: .68rem; text-align: left; cursor: pointer; }
.chatbot-history__actions button:hover { color: var(--chat-accent); }
.chatbot-history__actions input { width: 100%; padding: 6px; border: 1px solid var(--chat-line); border-radius: 6px; color: var(--chat-ink); background: var(--chat-surface); font: inherit; }
.chatbot-sidebar__foot { padding-top: 10px; border-top: 1px solid var(--chat-line); }
.chatbot-human-link { display: flex; width: 100%; justify-content: space-between; padding: 8px 6px; border: 0; color: var(--chat-muted); background: transparent; font: inherit; font-size: .68rem; text-align: left; cursor: pointer; }
.chatbot-human-link:hover { color: var(--chat-accent); }

.chatbot-main { position: relative; display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.chatbot-main::before { position: absolute; top: -160px; right: -120px; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(150,124,251,.11), transparent 72%); content: ""; pointer-events: none; }
.chatbot-welcome { position: relative; flex: 1; overflow-y: auto; padding: 32px clamp(18px, 4vw, 46px) 20px; text-align: center; }
.chatbot-welcome__orb { display: grid; width: 48px; height: 48px; margin: 0 auto 13px; place-items: center; border: 1px solid var(--chat-line); border-radius: 17px; color: white; background: linear-gradient(145deg, #806aee, #a37beb 58%, #62c9b8); box-shadow: 0 9px 25px rgba(105,89,232,.23); animation: chatAvatarBreathe 4s ease-in-out infinite; }
.chatbot-welcome__orb span { font-size: 22px; }
.chatbot-eyebrow { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--chat-accent); font-size: .59rem; font-weight: 700; letter-spacing: .16em; }
.chatbot-spark { width: 5px; height: 5px; border-radius: 50%; background: var(--chat-accent); box-shadow: 0 0 9px var(--chat-accent); }
.chatbot-welcome h2 { margin: 9px 0 6px; color: var(--chat-ink); font-size: clamp(1.2rem, 2vw, 1.55rem); font-weight: 600; letter-spacing: -.035em; }
.chatbot-welcome > p { max-width: 490px; margin: 0 auto 22px; color: var(--chat-muted); font-size: .75rem; line-height: 1.65; }
.chatbot-suggestions { display: grid; max-width: 555px; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; margin: 0 auto; text-align: left; }
.chatbot-suggestion { display: flex; min-height: 61px; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--chat-line); border-radius: 13px; color: var(--chat-ink); background: var(--chat-surface-raised); font: inherit; cursor: pointer; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.chatbot-suggestion:hover { transform: translateY(-2px); border-color: rgba(105,89,232,.4); box-shadow: 0 9px 25px var(--chat-accent-soft); }
.chatbot-suggestion__icon { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; border-radius: 10px; color: var(--chat-accent); background: var(--chat-accent-soft); font-size: .95rem; }
.chatbot-suggestion > span:nth-child(2) { flex: 1; min-width: 0; }
.chatbot-suggestion b { display: block; font-size: .68rem; font-weight: 600; }
.chatbot-suggestion small { display: block; margin-top: 2px; overflow: hidden; color: var(--chat-muted); font-size: .58rem; text-overflow: ellipsis; white-space: nowrap; }
.chatbot-suggestion i { color: var(--chat-muted); font-size: .8rem; font-style: normal; }
.chatbot-suggestion--consult { grid-column: 1 / -1; }
.chatbot-welcome__note { margin: 16px auto 0; color: var(--chat-muted); font-size: .58rem; }

.chatbot-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 22px clamp(16px, 4vw, 42px) 18px; scroll-behavior: smooth; }
.chatbot-message { display: flex; margin: 0 auto 17px; max-width: 680px; animation: chatMessageIn .22s ease both; }
.chatbot-message--user { justify-content: flex-end; }
.chatbot-message__stack { max-width: 88%; min-width: 0; }
.chatbot-message--user .chatbot-message__stack { max-width: 82%; }
.chatbot-message__author { margin: 0 0 4px 3px; color: var(--chat-muted); font-size: .59rem; font-weight: 600; }
.chatbot-message--user .chatbot-message__author { text-align: right; }
.chatbot-message__bubble { padding: 11px 14px; border: 1px solid var(--chat-line); border-radius: 15px; color: var(--chat-ink); background: var(--chat-surface-raised); font-size: .77rem; line-height: 1.7; overflow-wrap: anywhere; }
.chatbot-message--assistant .chatbot-message__bubble { border-top-left-radius: 5px; box-shadow: 0 4px 16px rgba(20,24,46,.035); }
.chatbot-message--user .chatbot-message__bubble { border-color: transparent; border-top-right-radius: 5px; color: white; background: linear-gradient(135deg, #7564e9, #9769de); }
.chatbot-message__bubble p { margin: 0 0 8px; }
.chatbot-message__bubble p:last-child { margin-bottom: 0; }
.chatbot-message__bubble ul { margin: 5px 0; padding-left: 20px; }
.chatbot-message__bubble a { color: var(--chat-accent); text-decoration: underline; text-underline-offset: 2px; }
.chatbot-message--user .chatbot-message__bubble a { color: white; }
.chatbot-message__time { margin: 4px 4px 0; color: var(--chat-muted); font-size: .55rem; }
.chatbot-message--user .chatbot-message__time { text-align: right; }
.chatbot-message__tools { display: flex; gap: 5px; margin: 5px 0 0 2px; opacity: .7; }
.chatbot-message__tool { padding: 3px 6px; border: 0; border-radius: 5px; color: var(--chat-muted); background: transparent; font: inherit; font-size: .58rem; cursor: pointer; }
.chatbot-message__tool:hover { color: var(--chat-accent); background: var(--chat-accent-soft); }
.chatbot-service-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 8px; margin-top: 10px; }
.chatbot-service-card { padding: 10px; border: 1px solid var(--chat-line); border-radius: 11px; background: var(--chat-surface-raised); }
.chatbot-service-card b { display: block; font-size: .68rem; }
.chatbot-service-card p { margin: 4px 0 9px; color: var(--chat-muted); font-size: .6rem; line-height: 1.5; }
.chatbot-service-card a { font-size: .61rem; font-weight: 600; text-decoration: none; }
.chatbot-generating { display: flex; align-items: center; gap: 9px; padding: 0 25px 10px; color: var(--chat-muted); font-size: .64rem; }
.chatbot-generating__spinner { width: 13px; height: 13px; border: 2px solid var(--chat-line); border-top-color: var(--chat-accent); border-radius: 50%; animation: chatSpin .8s linear infinite; }
.chatbot-typing { display: flex; align-items: center; gap: 4px; padding: 2px 25px 12px; }
.chatbot-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--chat-accent); animation: chatDot 1s ease-in-out infinite; }
.chatbot-typing span:nth-child(2) { animation-delay: .14s; }.chatbot-typing span:nth-child(3) { animation-delay: .28s; }
.chatbot-error { margin: 0 18px 8px; padding: 8px 10px; border: 1px solid rgba(226,80,89,.25); border-radius: 8px; color: #c6444b; background: rgba(226,80,89,.08); font-size: .68rem; }

.chatbot-form { position: relative; display: flex; flex: 0 0 auto; align-items: flex-end; gap: 8px; margin: 0 16px; padding: 8px 8px 8px 13px; border: 1px solid var(--chat-line); border-radius: 15px; background: var(--chat-surface-raised); box-shadow: 0 6px 25px rgba(30,34,65,.06); transition: border-color .18s ease, box-shadow .18s ease; }
.chatbot-form:focus-within { border-color: rgba(105,89,232,.52); box-shadow: 0 0 0 3px var(--chat-accent-soft), 0 6px 25px rgba(30,34,65,.06); }
.chatbot-form textarea { flex: 1; min-width: 0; max-height: 105px; min-height: 35px; padding: 7px 0; resize: none; border: 0; outline: 0; color: var(--chat-ink); background: transparent; font: inherit; font-size: .73rem; line-height: 1.5; }
.chatbot-form textarea::placeholder { color: var(--chat-muted); }
.chatbot-voice, .chatbot-send, .chatbot-stop { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; padding: 0; border: 0; border-radius: 10px; color: var(--chat-muted); background: transparent; cursor: pointer; transition: background .16s ease, color .16s ease, transform .16s ease; }
.chatbot-voice { font-size: 1.2rem; }
.chatbot-voice:hover, .chatbot-voice.is-listening { color: var(--chat-accent); background: var(--chat-accent-soft); }
.chatbot-send { color: #fff; background: linear-gradient(135deg, #7664ec, #a16fe2); box-shadow: 0 5px 13px rgba(105,89,232,.25); }
.chatbot-send:hover { transform: translateY(-1px); }
.chatbot-send span { font-size: 1.25rem; line-height: 1; }
.chatbot-stop { width: auto; flex-basis: auto; padding: 0 10px; color: var(--chat-accent); background: var(--chat-accent-soft); font-size: .64rem; }
.chatbot-disclaimer { flex: 0 0 auto; padding: 7px 18px 11px; color: var(--chat-muted); font-size: .54rem; text-align: center; }
.chatbot-welcome[hidden], .chatbot-body[hidden] { display: none; }
.chatbot-message--editing textarea { width: min(100%, 440px); min-height: 70px; padding: 9px; border: 1px solid var(--chat-line); border-radius: 8px; color: var(--chat-ink); background: var(--chat-surface); font: inherit; font-size: .75rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.chatbot-widget button:focus-visible, .chatbot-widget input:focus-visible, .chatbot-widget textarea:focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 2px; }

@keyframes chatPanelIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes chatMessageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes chatSpin { to { transform: rotate(360deg); } }
@keyframes chatDot { 0%,80%,100% { transform: translateY(0); opacity: .42; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes chatAvatarBreathe { 0%,100% { box-shadow: 0 9px 25px rgba(105,89,232,.2); } 50% { box-shadow: 0 9px 30px rgba(105,89,232,.4); } }
@keyframes chatBadgePulse { 0%,100% { box-shadow: 0 0 0 3px rgba(107,224,182,.1); } 50% { box-shadow: 0 0 0 6px rgba(107,224,182,.05); } }

@media (max-width: 700px) {
  .chatbot-widget { right: 14px; bottom: 14px; }
  .chatbot-toggle { width: 58px; height: 58px; }
  .chatbot-panel { inset: auto 0 0; width: 100vw; height: 100dvh; min-width: 0; min-height: 0; max-width: 100vw; max-height: 100dvh; border: 0; border-radius: 0; resize: none; }
  .chatbot-panel.chatbot-panel--fullscreen { inset: 0; width: 100vw; height: 100dvh; border-radius: 0; }
  .chatbot-header { flex-basis: 64px; padding: 0 12px; }
  .chatbot-history-toggle { display: grid; }
  .chatbot-workspace { position: relative; }
  .chatbot-sidebar { position: absolute; z-index: 2; inset: 0 auto 0 0; display: none; width: min(290px, 82vw); box-shadow: 12px 0 30px rgba(0,0,0,.14); }
  .chatbot-sidebar.is-open { display: flex; }
  .chatbot-welcome { padding: 25px 15px 16px; }
  .chatbot-welcome > p { margin-bottom: 17px; }
  .chatbot-suggestions { gap: 7px; }
  .chatbot-suggestion { min-height: 56px; gap: 7px; padding: 7px; }
  .chatbot-suggestion__icon { width: 27px; height: 27px; flex-basis: 27px; }
  .chatbot-suggestion b { font-size: .61rem; }
  .chatbot-suggestion small { font-size: .52rem; }
  .chatbot-body { padding: 17px 13px; }
  .chatbot-message__stack { max-width: 94%; }
  .chatbot-form { margin: 0 10px; }
  .chatbot-disclaimer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (max-width: 390px) {
  .chatbot-suggestions { grid-template-columns: 1fr; }
  .chatbot-suggestion--consult { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-widget *, .chatbot-widget *::before, .chatbot-widget *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
