/* ── Chat widget (Kara support) ──────────────────────────────────────────────── */

#chat-widget {
  position: fixed;
  bottom: 48px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── FAB button ─────────────────────────────────────────────────────────────── */

.chat-fab {
  width: 52px;
  height: 52px;
  border-radius: var(--card-radius);
  border: none;
  background: var(--brand-2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  transition: background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
  flex-shrink: 0;
}
.chat-fab:hover  { background: var(--brand-3); transform: scale(1.08); }
.chat-fab:active { transform: scale(0.96); }
.chat-fab svg    { width: 22px; height: 22px; }

/* ── Panel ──────────────────────────────────────────────────────────────────── */

.chat-panel {
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--bg-menu);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  max-height: min(520px, calc(100vh - 110px));
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--brand-2);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.chat-head-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-head-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.35);
}
.chat-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.75;
  transition: opacity var(--dur-fast);
}
.chat-close-btn:hover { opacity: 1; }

/* ── Messages ────────────────────────────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-msg {
  max-width: 86%;
  padding: 8px 11px;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg--kara {
  align-self: flex-start;
  background: var(--hover-bg);
  border: 1px solid var(--border);
  border-radius: 0 var(--r-md, 6px) var(--r-md, 6px) var(--r-md, 6px);
  color: var(--text);
}
.chat-msg--user {
  align-self: flex-end;
  background: var(--brand-2);
  color: #fff;
  border-radius: var(--r-md, 6px) 0 var(--r-md, 6px) var(--r-md, 6px);
}

.chat-ticket-badge {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--brand-2);
  opacity: 0.9;
}

/* ── Typing indicator ────────────────────────────────────────────────────────── */

.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  align-self: flex-start;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim, #888);
  animation: chat-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input row ──────────────────────────────────────────────────────────────── */

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-menu);
}
.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--bg-body);
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.4;
  border-radius: var(--card-radius);
  max-height: 96px;
  overflow-y: auto;
  transition: border-color var(--dur-input);
}
.chat-input:focus { outline: none; border-color: var(--brand-2); }
.chat-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--brand-2);
  color: #fff;
  border-radius: var(--card-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background var(--dur-fast);
}
.chat-send-btn:hover   { background: var(--brand-3); }
.chat-send-btn:disabled { opacity: 0.45; cursor: default; }
.chat-send-btn svg { width: 16px; height: 16px; }

/* ── Mobile ─────────────────────────────────────────────────────────────────── */

@media (max-width: 400px) {
  #chat-widget { bottom: 32px; right: 16px; }
  .chat-panel  { width: calc(100vw - 32px); }
}
