#kiwl-chat-root {
  --kiwl-green: #25d366;
  --kiwl-green-dark: #1da851;
  --kiwl-blue: #008cd6;
  --kiwl-bg: #f0f2f5;
  --kiwl-text: #1a1a1a;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  z-index: 99999;
}

#kiwl-chat-root * {
  box-sizing: border-box;
}

.kiwl-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--kiwl-green);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}

.kiwl-chat-toggle:hover {
  background: var(--kiwl-green-dark);
  transform: scale(1.05);
}

.kiwl-chat-toggle svg {
  width: 30px;
  height: 30px;
  fill: #fff;
}

.kiwl-chat-panel {
  position: fixed;
  bottom: 94px;
  right: 24px;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.kiwl-chat-panel.is-open {
  display: flex;
}

.kiwl-chat-header {
  background: linear-gradient(135deg, var(--kiwl-blue), #006ba1);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.kiwl-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 13px;
  flex-shrink: 0;
}

.kiwl-chat-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.kiwl-chat-header-info p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.kiwl-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  padding: 0 4px;
}

.kiwl-chat-close:hover {
  opacity: 1;
}

.kiwl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--kiwl-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kiwl-chat-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  word-wrap: break-word;
  animation: kiwlFadeIn 0.3s ease;
}

@keyframes kiwlFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.kiwl-chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--kiwl-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

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

.kiwl-chat-typing {
  align-self: flex-start;
  background: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  display: none;
}

.kiwl-chat-typing.is-visible {
  display: block;
}

.kiwl-chat-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #999;
  border-radius: 50%;
  margin: 0 2px;
  animation: kiwlDot 1.2s infinite;
}

.kiwl-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.kiwl-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes kiwlDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.kiwl-chat-actions {
  padding: 10px 14px 14px;
  background: #fff;
  border-top: 1px solid #e8e8e8;
  flex-shrink: 0;
}

.kiwl-chat-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.kiwl-chat-quick-btns button {
  border: 1px solid var(--kiwl-blue);
  background: #fff;
  color: var(--kiwl-blue);
  border-radius: 18px;
  padding: 7px 13px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}

.kiwl-chat-quick-btns button:hover {
  background: var(--kiwl-blue);
  color: #fff;
}

.kiwl-chat-wa-btn {
  display: none;
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  background: var(--kiwl-green);
  color: #fff;
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.15s;
}

.kiwl-chat-wa-btn.is-visible {
  display: block;
}

.kiwl-chat-wa-btn:hover {
  background: var(--kiwl-green-dark);
  color: #fff;
}

html[dir="rtl"] .kiwl-chat-toggle,
html[dir="rtl"] .kiwl-chat-panel {
  right: auto;
  left: 24px;
}

html[dir="rtl"] .kiwl-chat-close {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .kiwl-chat-msg.bot {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 4px;
}

html[dir="rtl"] .kiwl-chat-msg.user {
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 4px;
}

@media (max-width: 480px) {
  .kiwl-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }

  html[dir="rtl"] .kiwl-chat-panel {
    left: 0;
  }

  .kiwl-chat-toggle {
    bottom: 16px;
    right: 16px;
  }

  html[dir="rtl"] .kiwl-chat-toggle {
    left: 16px;
  }
}
