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

.sirtv-chat {
  --sirtv-chat-primary: #7c3aed;
  --sirtv-chat-shadow: 0 20px 55px rgba(19, 15, 33, 0.2);
  position: fixed;
  z-index: 999999;
  bottom: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2937;
  line-height: 1.45;
}

.sirtv-chat--right { right: 22px; }
.sirtv-chat--left { left: 22px; }

.sirtv-chat__panel {
  position: absolute;
  bottom: 78px;
  width: min(380px, calc(100vw - 28px));
  height: min(610px, calc(100vh - 120px));
  min-height: 430px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 22px;
  box-shadow: var(--sirtv-chat-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.sirtv-chat--right .sirtv-chat__panel { right: 0; }
.sirtv-chat--left .sirtv-chat__panel { left: 0; transform-origin: bottom left; }

.sirtv-chat[data-open="true"] .sirtv-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.sirtv-chat__header {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--sirtv-chat-primary), color-mix(in srgb, var(--sirtv-chat-primary) 74%, #111827));
}

.sirtv-chat__avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  color: var(--sirtv-chat-primary);
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.sirtv-chat__heading {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sirtv-chat__heading strong {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sirtv-chat__heading span {
  font-size: 11.5px;
  opacity: 0.88;
}

.sirtv-chat__close,
.sirtv-chat__clear {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #fff;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.sirtv-chat__close:hover,
.sirtv-chat__clear:hover,
.sirtv-chat__close:focus-visible,
.sirtv-chat__clear:focus-visible { background: rgba(255, 255, 255, 0.16); }

.sirtv-chat__messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 14px 8px;
  background:
    radial-gradient(circle at 10% 0, color-mix(in srgb, var(--sirtv-chat-primary) 7%, transparent), transparent 35%),
    #f7f7fb;
  scrollbar-width: thin;
}

.sirtv-chat__message {
  display: flex;
  margin: 0 0 12px;
  animation: sirtv-chat-in 180ms ease both;
}

.sirtv-chat__message--user { justify-content: flex-end; }
.sirtv-chat__message--assistant { justify-content: flex-start; }

.sirtv-chat__bubble {
  max-width: 84%;
  padding: 10px 12px 7px;
  background: #fff;
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 7px 16px 16px 16px;
  box-shadow: 0 3px 12px rgba(17, 24, 39, 0.055);
}

.sirtv-chat__message--user .sirtv-chat__bubble {
  color: #fff;
  background: var(--sirtv-chat-primary);
  border-color: transparent;
  border-radius: 16px 7px 16px 16px;
}

.sirtv-chat__bubble p {
  margin: 0;
  color: inherit;
  font-size: 14px;
  line-height: 1.46;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sirtv-chat__bubble time {
  display: block;
  margin-top: 4px;
  color: #6b7280;
  font-size: 9.5px;
  line-height: 1;
  text-align: right;
}

.sirtv-chat__source {
  display: block;
  margin-top: 7px;
  color: var(--sirtv-chat-primary);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.sirtv-chat__source:hover,
.sirtv-chat__source:focus-visible { color: #4c1d95; }

.sirtv-chat__message--user .sirtv-chat__bubble time { color: rgba(255, 255, 255, 0.75); }

.sirtv-chat__typing .sirtv-chat__bubble {
  display: flex;
  gap: 4px;
  padding: 13px 15px;
}

.sirtv-chat__typing span {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: sirtv-chat-bounce 1.2s infinite ease-in-out;
}

.sirtv-chat__typing span:nth-child(2) { animation-delay: 120ms; }
.sirtv-chat__typing span:nth-child(3) { animation-delay: 240ms; }

.sirtv-chat__suggestions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 7px 12px 10px;
  background: #f7f7fb;
  scrollbar-width: none;
}

.sirtv-chat__suggestions:empty { display: none; }
.sirtv-chat__suggestions::-webkit-scrollbar { display: none; }

.sirtv-chat__suggestion {
  flex: 0 0 auto;
  max-width: 250px;
  padding: 7px 10px;
  color: var(--sirtv-chat-primary);
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--sirtv-chat-primary) 30%, #e5e7eb);
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 150ms ease, color 150ms ease;
}

.sirtv-chat__suggestion:hover,
.sirtv-chat__suggestion:focus-visible {
  color: #fff;
  background: var(--sirtv-chat-primary);
}

.sirtv-chat__human {
  padding: 9px 12px 8px;
  text-align: center;
  background: #fff;
  border-top: 1px solid #eef0f3;
}

.sirtv-chat__whatsapp {
  width: 100%;
  min-height: 39px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  color: #fff;
  background: #20b958;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(32, 185, 88, 0.2);
  transition: transform 150ms ease, background-color 150ms ease;
}

.sirtv-chat__whatsapp:hover,
.sirtv-chat__whatsapp:focus-visible { background: #169b48; transform: translateY(-1px); }

.sirtv-chat__human small {
  display: block;
  margin-top: 5px;
  color: #737a87;
  font-size: 9px;
  line-height: 1.25;
}

.sirtv-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 11px;
  background: #fff;
  border-top: 1px solid #eef0f3;
}

.sirtv-chat__form textarea {
  min-width: 0;
  min-height: 40px;
  max-height: 96px;
  flex: 1;
  resize: none;
  padding: 10px 12px;
  color: #1f2937;
  background: #f3f4f6;
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
}

.sirtv-chat__form textarea:focus {
  background: #fff;
  border-color: color-mix(in srgb, var(--sirtv-chat-primary) 52%, #fff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sirtv-chat-primary) 10%, transparent);
}

.sirtv-chat__form button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #fff;
  background: var(--sirtv-chat-primary);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 150ms ease, transform 150ms ease;
}

.sirtv-chat__form button:hover { transform: translateY(-1px); }
.sirtv-chat__form button:disabled { opacity: 0.48; cursor: wait; transform: none; }

.sirtv-chat__launcher {
  position: relative;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  margin-left: auto;
  padding: 0;
  color: #fff;
  background: var(--sirtv-chat-primary);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--sirtv-chat-primary) 35%, transparent);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.sirtv-chat--left .sirtv-chat__launcher { margin-left: 0; margin-right: auto; }
.sirtv-chat__launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px color-mix(in srgb, var(--sirtv-chat-primary) 42%, transparent); }
.sirtv-chat__launcher-icon { display: grid; place-items: center; transition: opacity 150ms ease, transform 150ms ease; }
.sirtv-chat__launcher-icon--close { position: absolute; opacity: 0; transform: rotate(-30deg) scale(0.7); }
.sirtv-chat[data-open="true"] .sirtv-chat__launcher-icon--open { opacity: 0; transform: rotate(30deg) scale(0.7); }
.sirtv-chat[data-open="true"] .sirtv-chat__launcher-icon--close { opacity: 1; transform: rotate(0) scale(1); }

.sirtv-chat__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #ef4444;
  border: 2px solid #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.sirtv-chat__badge[hidden] { display: none; }

.sirtv-chat button:focus-visible,
.sirtv-chat textarea:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

@keyframes sirtv-chat-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sirtv-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

@media (max-width: 480px) {
  .sirtv-chat { bottom: 14px; }
  .sirtv-chat--right { right: 14px; }
  .sirtv-chat--left { left: 14px; }
  .sirtv-chat__panel {
    position: fixed;
    inset: 10px 10px 88px;
    width: auto;
    height: auto;
    min-height: 0;
    border-radius: 18px;
    transform-origin: bottom center;
  }
  .sirtv-chat__launcher { width: 58px; height: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .sirtv-chat__panel,
  .sirtv-chat__launcher,
  .sirtv-chat__message,
  .sirtv-chat__typing span { animation: none !important; transition: none !important; }
}
