/* chat.css – Q&A Chat widget */

.chat-widget {
  position: fixed;
  bottom: calc(24px + var(--safe-area-bottom));
  left: calc(24px + var(--safe-area-left));
  z-index: 4900;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: var(--font-body);
}

.chat-toggle {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent3));
  color: #fff;
  font-size: 1.5rem;
  box-shadow: 0 8px 24px var(--accent-glow);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: transform .3s, box-shadow .3s;
}
.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px var(--accent-glow);
}

.chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--error);
  color: #fff;
  font-size: 0.7rem; font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}

/* Chat Panel */
.chat-panel {
  position: absolute;
  bottom: 70px; left: 0;
  width: 320px;
  height: 460px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom left;
  transition: .3s cubic-bezier(.4,0,.2,1);
}
.chat-widget.open .chat-panel {
  opacity: 1; visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-header {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.1), transparent);
  padding: 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.chat-avatar {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-family: var(--font-display);
}
.chat-header-info { flex: 1; }
.chat-header-info strong { display: block; font-size: .95rem; }
.chat-status { display: flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--text2); }
.status-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; display: inline-block; }

.chat-close { color: var(--text2); font-size: 1.2rem; transition: .2s; }
.chat-close:hover { color: var(--error); transform: scale(1.1); }

/* Messages */
.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem; line-height: 1.4;
  animation: scaleIn .2s ease-out;
}
.chat-msg.sys { background: var(--surface2); color: var(--text); border-bottom-left-radius: 10px; align-self: flex-start; border: 1px solid var(--border); }
.chat-msg.user { background: var(--accent); color: #fff; border-bottom-right-radius: 10px; align-self: flex-end; }

/* Quick Replies */
.chat-quick {
  padding: 10px 16px;
  display: flex; gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg3);
  border-top: 1px solid var(--border);
}
.chat-quick::-webkit-scrollbar { display: none; }
.quick-btn {
  white-space: nowrap;
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: .75rem; font-weight: 600;
  transition: .2s;
}
.quick-btn:hover { background: var(--accent); color: #fff; }

/* Input */
.chat-input-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
.chat-input-wrap input {
  flex: 1;
  background: transparent; border: none;
  font-size: .85rem; color: var(--text); outline: none;
}
.chat-input-wrap button {
  color: var(--accent); transition: .2s; display: flex;
}
.chat-input-wrap button:hover { transform: scale(1.1); }
.chat-input-wrap button svg { width: 20px; height: 20px; }

html[data-device="mobile"] .chat-widget {
  left: calc(14px + var(--safe-area-left));
  right: calc(14px + var(--safe-area-right));
  bottom: calc(16px + var(--safe-area-bottom));
  align-items: flex-end;
}

html[data-device="mobile"] .chat-toggle {
  width: 54px;
  height: 54px;
}

html[data-device="mobile"] .chat-panel {
  left: auto;
  right: 0;
  bottom: 66px;
  width: 100%;
  height: min(540px, calc(var(--viewport-height) - 104px - var(--safe-area-top) - var(--safe-area-bottom)));
  max-height: none;
  border-radius: 28px;
  transform-origin: bottom right;
}

html[data-device="mobile"] .chat-header {
  padding: 14px;
}

html[data-device="mobile"] .chat-messages {
  padding: 14px;
}

html[data-device="mobile"] .chat-input-wrap {
  padding: 10px 14px calc(10px + var(--safe-area-bottom));
}

@media (max-width: 480px) {
  .chat-widget { bottom: calc(20px + var(--safe-area-bottom)); left: calc(20px + var(--safe-area-left)); right: calc(20px + var(--safe-area-right)); align-items: flex-end; }
  .chat-panel { width: 100%; bottom: 64px; left: 0; right: 0; height: calc(100svh - 100px - var(--safe-area-top) - var(--safe-area-bottom)); max-height: 500px; transform-origin: bottom right; }
}
