/* =====================================================
   KarakolGuide Chat Widget — подключи на любой сайт
   ===================================================== */

#kg-chat { position: fixed; bottom: 24px; right: 24px; z-index: 9999; font-family: 'Segoe UI', Arial, sans-serif; }

.kg-chat-fab {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #2d6a4f;
  color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s, background 0.2s;
  position: relative;
}
.kg-chat-fab svg { width: 24px; height: 24px; }
.kg-chat-fab:hover { background: #1b4332; transform: scale(1.07); }
.kg-chat-fab.open { background: #1b4332; }

.kg-chat-fab-dot {
  position: absolute; top: 10px; right: 10px;
  width: 10px; height: 10px;
  background: #25d366;
  border-radius: 50%;
  border: 2px solid #fff;
}

.kg-chat-box {
  position: absolute; bottom: 68px; right: 0;
  width: 340px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s ease;
  transform-origin: bottom right;
}
.kg-chat-box.open { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }

.kg-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: #2d6a4f;
  color: #fff;
}
.kg-chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}
.kg-chat-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top center; border-radius: 50%; }
.kg-chat-hinfo { flex: 1; line-height: 1.3; }
.kg-chat-hinfo strong { display: block; font-size: 0.95rem; }
.kg-chat-hinfo span { font-size: 0.75rem; opacity: 0.8; }
.kg-chat-close {
  background: none; border: none; color: #fff;
  font-size: 1rem; cursor: pointer; opacity: 0.7; padding: 4px;
  transition: opacity 0.15s;
}
.kg-chat-close:hover { opacity: 1; }

.kg-chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column;
  gap: 10px;
  max-height: 320px; min-height: 200px;
}

.kg-msg { display: flex; }
.kg-msg--bot { justify-content: flex-start; }
.kg-msg--user { justify-content: flex-end; }

.kg-msg-bubble {
  max-width: 82%; padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.87rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.kg-msg--bot .kg-msg-bubble { background: #f0f7ff; color: #1a2a3a; border-bottom-left-radius: 4px; }
.kg-msg--user .kg-msg-bubble { background: #2d6a4f; color: #fff; border-bottom-right-radius: 4px; }

.kg-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.kg-sugg-btn {
  background: #e8f4ee; border: 1px solid #b7d8c8;
  color: #2d6a4f; border-radius: 20px;
  padding: 5px 12px; font-size: 0.78rem;
  cursor: pointer; transition: background 0.15s;
}
.kg-sugg-btn:hover { background: #d0ecdc; }

.kg-confirm-wrap { display: none; padding: 10px 14px; background: #f0f7f3; border-top: 2px solid #b7d8c8; }
.kg-confirm-wrap.visible { display: block; }
.kg-confirm-label { font-size: 0.72rem; color: #5a8a72; font-weight: 600; text-transform: uppercase; text-align: center; margin-bottom: 8px; letter-spacing: 0.03em; }
.kg-confirm-btn {
  width: 100%; background: #2d6a4f; color: #fff;
  border: none; border-radius: 10px; padding: 12px;
  font-size: 0.95rem; font-weight: 800; cursor: pointer;
  transition: background .15s;
  box-shadow: 0 3px 12px rgba(45,106,79,0.25);
}
.kg-confirm-btn:hover { background: #1b4332; }
.kg-confirm-btn:disabled { cursor: default; }

.kg-chat-input-row {
  display: flex; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #eef2f7;
  background: #fafbfc;
}
.kg-chat-input-row input {
  flex: 1; border: 1px solid #dde4ee;
  border-radius: 22px; padding: 8px 14px;
  font-size: 0.87rem; outline: none;
  transition: border-color 0.2s; background: #fff;
}
.kg-chat-input-row input:focus { border-color: #2d6a4f; }
#kgSend {
  width: 38px; height: 38px; border-radius: 50%;
  background: #2d6a4f; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0; transition: background 0.18s;
}
#kgSend:hover { background: #1b4332; }
#kgSend:disabled { background: #ccc; cursor: default; }
#kgSend svg { width: 18px; height: 18px; }

.kg-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.kg-typing span { width: 7px; height: 7px; background: #9ab; border-radius: 50%; animation: kg-bounce 1.2s infinite; }
.kg-typing span:nth-child(2) { animation-delay: 0.2s; }
.kg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes kg-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

@media (max-width: 480px) {
  .kg-chat-box { width: calc(100vw - 32px); right: -8px; }
}
