/* ============================================
 * Autais Chat Demo — Reusable Component
 * Class prefix: acd- (Autais Chat Demo)
 * Required CSS variables (set on :root or .autais-chat-demo):
 *   --acd-fg, --acd-fg-2, --acd-muted, --acd-line, --acd-bg
 *   --acd-p, --acd-p-dark, --acd-p-soft, --acd-accent
 * Falls back to autais Pattern F palette if unset.
 * ============================================ */

.autais-chat-demo {
  --acd-fg: var(--fg, #0f172a);
  --acd-fg-2: var(--fg-2, #334155);
  --acd-muted: var(--muted, #64748b);
  --acd-line: var(--line, #e2e8f0);
  --acd-bg: var(--bg, #ffffff);
  --acd-bg-2: var(--bg-2, #f6f8fc);
  --acd-p: var(--p, #2563eb);
  --acd-p-dark: var(--p-dark, #1d4ed8);
  --acd-p-soft: var(--p-soft, #dbeafe);
  --acd-accent: var(--accent, #10b981);
  --acd-warm: var(--warm, #f59e0b);
  --acd-window-h: 320px;

  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  font-family: "Noto Sans JP", "Inter", system-ui, -apple-system, sans-serif;
  color: var(--acd-fg);
  line-height: 1.6;
}
.autais-chat-demo *, .autais-chat-demo *::before, .autais-chat-demo *::after {
  box-sizing: border-box;
}

/* Tabs row with prev/next */
.acd-tabs-wrap {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 6px;
  align-items: center;
  margin-bottom: 14px;
}
.acd-prev,
.acd-next {
  width: 36px;
  height: 36px;
  border: 1px solid var(--acd-line);
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--acd-fg-2);
  transition: 0.2s;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
}
.acd-prev:hover,
.acd-next:hover {
  background: var(--acd-p);
  border-color: var(--acd-p);
  color: #fff;
}
.acd-tabs {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}
.acd-tabs::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(90deg, transparent, var(--acd-bg-2));
  pointer-events: none;
  z-index: 2;
}
.acd-tabs-track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 32px 4px 0;
}
.acd-tabs-track::-webkit-scrollbar { display: none; }
.acd-tab {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  border: 1px solid var(--acd-line);
  background: #fff;
  color: var(--acd-fg-2);
  border-radius: 9999px;
  cursor: pointer;
  transition: 0.2s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.acd-tab:hover {
  border-color: var(--acd-p);
  color: var(--acd-p);
}
.acd-tab.active {
  background: var(--acd-p);
  color: #fff;
  border-color: var(--acd-p);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* Chat card — fixed height window */
.acd-card {
  background: #fff;
  border: 1px solid var(--acd-line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  user-select: none;
}
.acd-bar {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--acd-line);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #94a3b8;
}
.acd-dots {
  display: flex;
  gap: 5px;
  margin-right: 8px;
}
.acd-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.acd-dots span:nth-child(1) { background: #ef4444; }
.acd-dots span:nth-child(2) { background: #f59e0b; }
.acd-dots span:nth-child(3) { background: #10b981; }
.acd-body {
  padding: 20px;
  height: var(--acd-window-h);
  overflow-y: auto;
  scrollbar-width: thin;
  outline: none;
}
.acd-body::-webkit-scrollbar { width: 4px; }
.acd-body::-webkit-scrollbar-thumb { background: var(--acd-line); border-radius: 2px; }
.acd-body:focus-visible { box-shadow: inset 0 0 0 2px var(--acd-p); }

/* Messages */
.acd-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(8px);
  animation: acdMsgIn 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
@keyframes acdMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.acd-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.acd-avatar.user { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.acd-avatar.ai { background: linear-gradient(135deg, var(--acd-p), var(--acd-accent)); }
.acd-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  flex: 1;
  max-width: 80%;
}
.acd-bubble.user {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.acd-bubble.ai {
  background: var(--acd-p-soft);
  color: var(--acd-p-dark);
  border-bottom-left-radius: 4px;
}
.acd-bubble .acd-tag {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--acd-p);
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 4px;
  margin-right: 6px;
}
.acd-bubble .acd-ok {
  color: var(--acd-accent);
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
  font-size: 14px !important;
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 20 !important;
}
.acd-bubble-text::after {
  content: "▍";
  display: inline-block;
  margin-left: 1px;
  color: var(--acd-p);
  animation: acdCaret 0.8s steps(1) infinite;
  opacity: 0.7;
}
.acd-msg:not(:last-child) .acd-bubble-text::after { display: none; }
@keyframes acdCaret {
  0%, 50% { opacity: 0.7; }
  51%, 100% { opacity: 0; }
}

.acd-actions {
  padding: 14px 20px 18px;
  border-top: 1px dashed var(--acd-line);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.acd-actions span {
  padding: 5px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 11.5px;
  color: #475569;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}
.acd-action-ico {
  font-size: 14px !important;
  color: var(--acd-p);
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20 !important;
}
.acd-action-label { line-height: 1; }

/* Info panel below window (AI action + benefit + modules) */
.acd-info {
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--acd-p-soft);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.06);
}
.acd-info.acd-info-pulse {
  animation: acdInfoPulse 0.5s ease;
}
@keyframes acdInfoPulse {
  0% { transform: scale(0.99); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}
.acd-info-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.acd-info-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--acd-p-soft);
}
.acd-info-icon .mi {
  font-size: 18px !important;
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24 !important;
}
.acd-info-action .acd-info-icon { background: var(--acd-p); color: #fff; border-color: var(--acd-p); }
.acd-info-benefit .acd-info-icon { background: var(--acd-warm); border-color: var(--acd-warm); color: #fff; }
.acd-info-content {
  flex: 1;
  min-width: 0;
}
.acd-info-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--acd-p);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.acd-info-benefit .acd-info-label { color: #b45309; }
.acd-action-text,
.acd-benefit-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--acd-fg);
  line-height: 1.65;
}
.acd-benefit-text { font-weight: 700; }
.acd-info-mods {
  padding-top: 10px;
  border-top: 1px dashed var(--acd-p-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.acd-info-mods-label {
  font-size: 10.5px;
  color: var(--acd-muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-right: 4px;
}
.acd-benefit-mods {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.acd-benefit-mod {
  padding: 3px 9px;
  font-size: 10.5px;
  font-weight: 700;
  background: #fff;
  color: var(--acd-p-dark);
  border: 1px solid var(--acd-p-soft);
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.acd-benefit-mod::before {
  content: "✓";
  color: var(--acd-accent);
  font-weight: 800;
}

/* Sliding transition */
.acd-card.acd-leave-left { animation: acdSlideLeft 0.28s ease forwards; }
.acd-card.acd-leave-right { animation: acdSlideRight 0.28s ease forwards; }
.acd-card.acd-enter-left { animation: acdEnterLeft 0.32s ease forwards; }
.acd-card.acd-enter-right { animation: acdEnterRight 0.32s ease forwards; }
@keyframes acdSlideLeft { to { opacity: 0; transform: translateX(-12px); } }
@keyframes acdSlideRight { to { opacity: 0; transform: translateX(12px); } }
@keyframes acdEnterLeft { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes acdEnterRight { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }

@media (max-width: 600px) {
  .autais-chat-demo { --acd-window-h: 280px; }
  .acd-tabs-wrap { grid-template-columns: 32px minmax(0, 1fr) 32px; gap: 4px; }
  .acd-prev, .acd-next { width: 32px; height: 32px; font-size: 16px; }
  .acd-benefit { flex-direction: column; gap: 10px; }
  .acd-benefit-icon { width: 32px; height: 32px; font-size: 16px; }
}
