/* ============ پشتیبانی — چت‌بات کس‌آگلد ============ */

.kg-support {
  position: fixed;
  inset-block-end: 18px;
  inset-inline-start: 18px;
  z-index: 90;
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
}

.kg-support * { box-sizing: border-box; }

.kg-launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f0d090, var(--gold) 45%, var(--gold-2));
  color: #1a1305;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 14px 34px -14px rgba(230, 192, 105, 0.9);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kg-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 38px -14px rgba(230, 192, 105, 1); }
.kg-launcher svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.kg-panel {
  position: absolute;
  inset-block-end: 66px;
  inset-inline-start: 0;
  width: min(374px, calc(100vw - 32px));
  height: min(556px, calc(100dvh - 130px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(230, 192, 105, 0.22);
  background: #0d1017;
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.92);
  animation: kg-pop 0.18s ease;
}
@keyframes kg-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

.kg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  background: linear-gradient(135deg, rgba(230, 192, 105, 0.16), rgba(230, 192, 105, 0.04));
  border-block-end: 1px solid var(--line);
}
.kg-head-dot {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0d090, var(--gold) 45%, var(--gold-2));
  color: #1a1305;
}
.kg-head-dot svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kg-head-id { display: flex; flex-direction: column; line-height: 1.5; }
.kg-head-id b { font-size: 14px; }
.kg-head-id small { color: var(--muted); font-size: 11.5px; }
.kg-close {
  margin-inline-start: auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.kg-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.kg-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13.5px;
  line-height: 1.85;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
.kg-log::-webkit-scrollbar { width: 6px; }
.kg-log::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 99px; }
.kg-log::-webkit-scrollbar-track { background: transparent; }

.kg-msg {
  max-width: 90%;
  padding: 9px 12px;
  border-radius: 15px;
  white-space: pre-line;
  word-break: break-word;
}
.kg-msg a { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.kg-msg ul { list-style: disc; padding-inline-start: 17px; margin-block: 4px; }
.kg-msg li { margin-block: 2px; }
.kg-msg b { color: #f6e3b4; font-weight: 700; }
.kg-src, .kg-note { display: block; margin-block-start: 7px; font-size: 11.5px; line-height: 1.75; color: #8d97a8; }
.kg-src { border-block-start: 1px dashed rgba(255, 255, 255, 0.12); padding-block-start: 6px; }
.kg-src a { color: var(--gold); }
.kg-note { color: #b9a372; }

.kg-msg-bot {
  align-self: flex-start;
  background: #161b25;
  border: 1px solid var(--line);
  border-start-start-radius: 5px;
}
.kg-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(230, 192, 105, 0.22), rgba(230, 192, 105, 0.1));
  border: 1px solid rgba(230, 192, 105, 0.32);
  border-start-end-radius: 5px;
}

.kg-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.kg-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: kg-blink 1s infinite ease-in-out;
}
.kg-typing span:nth-child(2) { animation-delay: 0.15s; }
.kg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes kg-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.kg-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  border-block-start: 1px solid var(--line);
  scrollbar-width: none;
}
.kg-chips::-webkit-scrollbar { display: none; }
.kg-chip {
  flex: none;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.kg-chip:hover { border-color: rgba(230, 192, 105, 0.5); color: var(--gold); }

.kg-form {
  display: flex;
  gap: 7px;
  padding: 10px 12px 12px;
  border-block-start: 1px solid var(--line);
}
.kg-input {
  flex: 1;
  min-width: 0;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0a0d13;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
.kg-input:focus { outline: none; border-color: rgba(230, 192, 105, 0.55); }
.kg-send {
  flex: none;
  width: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f0d090, var(--gold) 45%, var(--gold-2));
  color: #1a1305;
}
.kg-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kg-send:disabled { opacity: 0.5; cursor: default; }

.kg-foot {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 10.5px;
  text-align: center;
  line-height: 1.7;
}

@media (max-width: 520px) {
  .kg-support { inset-block-end: 14px; inset-inline-start: 14px; }
  .kg-launcher { padding: 11px 15px; font-size: 13px; }
  .kg-panel { height: min(70dvh, calc(100dvh - 96px)); }
}

@media (prefers-reduced-motion: reduce) {
  .kg-panel { animation: none; }
  .kg-launcher { transition: none; }
  .kg-typing span { animation: none; opacity: 0.6; }
}

/* دکمهٔ ارسال به پشتیبانی انسانی */
.kg-esc {
  margin: 0 12px 2px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(230, 192, 105, 0.45);
  background: rgba(230, 192, 105, 0.06);
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.kg-esc:hover:not(:disabled) { background: rgba(230, 192, 105, 0.14); }
.kg-esc:disabled { opacity: 0.45; cursor: default; }
