/* Chat widget — bisa ditempel di situs lain */

:root {
  --ts-chat-accent: #2f6b4f;
  --ts-chat-accent-dark: #24553e;
  --ts-chat-bg: #ffffff;
  --ts-chat-surface: #f6f3ec;
  --ts-chat-ink: #1c2a22;
  --ts-chat-muted: #66756c;
  --ts-chat-user: #2f6b4f;
  --ts-chat-bot: #ffffff;
  --ts-chat-border: rgba(28, 42, 34, 0.12);
  --ts-chat-shadow: 0 18px 50px rgba(28, 42, 34, 0.18);
  --ts-chat-radius: 18px;
  --ts-chat-font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

#ts-chat-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  font-family: var(--ts-chat-font);
  color: var(--ts-chat-ink);
  line-height: 1.45;
}

#ts-chat-root *,
#ts-chat-root *::before,
#ts-chat-root *::after {
  box-sizing: border-box;
}

.ts-chat-launcher {
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--ts-chat-accent);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--ts-chat-shadow);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.ts-chat-launcher:hover {
  background: var(--ts-chat-accent-dark);
  transform: translateY(-2px);
}

.ts-chat-launcher svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

/* Popup tip bubble */
.ts-chat-popup {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(250px, calc(100vw - 88px));
  background: #fff;
  color: var(--ts-chat-ink);
  border: 1px solid var(--ts-chat-border);
  border-radius: 14px;
  box-shadow: var(--ts-chat-shadow);
  padding: 12px 34px 12px 14px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ts-chat-popup.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ts-chat-popup.is-hidden {
  opacity: 0 !important;
  transform: translateY(8px) scale(0.96) !important;
  pointer-events: none !important;
}

.ts-chat-popup-text {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
}

.ts-chat-popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ts-chat-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.ts-chat-popup-close:hover {
  background: rgba(28, 42, 34, 0.06);
  color: var(--ts-chat-ink);
}

.ts-chat-popup-tail {
  position: absolute;
  right: 22px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-right: 1px solid var(--ts-chat-border);
  border-bottom: 1px solid var(--ts-chat-border);
  transform: rotate(45deg);
}

.ts-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 110px));
  background: var(--ts-chat-bg);
  border: 1px solid var(--ts-chat-border);
  border-radius: var(--ts-chat-radius);
  box-shadow: var(--ts-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#ts-chat-root.is-open .ts-chat-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

#ts-chat-root.is-open .ts-chat-launcher {
  background: var(--ts-chat-accent-dark);
}

.ts-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #2f6b4f, #3d7f5e);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ts-chat-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.ts-chat-header p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.9;
}

.ts-chat-close {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.ts-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(47, 107, 79, 0.04), transparent 120px),
    var(--ts-chat-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ts-chat-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.ts-chat-bubble.bot {
  align-self: flex-start;
  background: var(--ts-chat-bot);
  border: 1px solid var(--ts-chat-border);
  border-bottom-left-radius: 4px;
}

.ts-chat-bubble.user {
  align-self: flex-end;
  background: var(--ts-chat-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ts-chat-bubble.error {
  background: #fde8e8;
  border-color: #f5b5b5;
  color: #8a1f1f;
}

.ts-chat-typing {
  align-self: flex-start;
  color: var(--ts-chat-muted);
  font-size: 0.85rem;
  padding: 4px 2px;
}

.ts-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--ts-chat-border);
  background: #fff;
}

.ts-chat-form input {
  flex: 1;
  border: 1px solid var(--ts-chat-border);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
  background: var(--ts-chat-surface);
}

.ts-chat-form input:focus {
  border-color: var(--ts-chat-accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.15);
}

.ts-chat-form button {
  border: none;
  border-radius: 12px;
  padding: 0 14px;
  background: var(--ts-chat-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ts-chat-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  #ts-chat-root {
    right: 12px;
    bottom: 12px;
  }

  .ts-chat-panel {
    width: calc(100vw - 24px);
    height: min(70vh, 560px);
  }

  .ts-chat-popup {
    width: min(220px, calc(100vw - 80px));
  }
}
