/* AutoMarketing 웹챗 위젯 — design-system.css 토큰 사용(하드코딩 색 최소·폴백 동반). */
#amChat {
  --amc-brand: var(--brand-600, #4f46e5);
  --amc-brand-700: var(--brand-700, #4338ca);
  --amc-surface: var(--surface, #fff);
  --amc-surface-2: var(--surface-2, #f8fafc);
  --amc-border: var(--border, #e2e8f0);
  --amc-text: var(--text, #0f172a);
  --amc-muted: var(--text-muted, #64748b);
  --amc-radius: var(--radius, 14px);
  font-family: var(--font-sans, "Pretendard", system-ui, sans-serif);
}

/* ── FAB ── */
.amc-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 2147483000;
  width: 60px; height: 60px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff;
  background: linear-gradient(145deg, var(--amc-brand) 0%, var(--amc-brand-700) 100%);
  box-shadow: 0 10px 30px rgba(2, 6, 23, .28), 0 2px 8px rgba(2, 6, 23, .18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
.amc-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 36px rgba(2, 6, 23, .34); }
.amc-fab:active { transform: scale(.96); }
.amc-fab svg { width: 27px; height: 27px; }
.amc-fab .amc-fab-close { display: none; }
#amChat.amc-open .amc-fab .amc-fab-chat { display: none; }
#amChat.amc-open .amc-fab .amc-fab-close { display: block; }

/* ── 패널 ── */
.amc-panel {
  position: fixed; right: 22px; bottom: 94px; z-index: 2147483000;
  width: 384px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 130px);
  background: var(--amc-surface);
  border: 1px solid var(--amc-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, .26), 0 4px 14px rgba(2, 6, 23, .12);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#amChat.amc-open .amc-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ── 헤더 ── */
.amc-head {
  background: linear-gradient(135deg, var(--amc-brand-700) 0%, var(--amc-brand) 70%, var(--accent, var(--amc-brand)) 100%);
  color: #fff; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between;
}
.amc-head-id { display: flex; align-items: center; gap: 11px; }
.amc-dot { width: 9px; height: 9px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .3); flex-shrink: 0; }
.amc-brand { font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.amc-status { font-size: 11.5px; opacity: .82; margin-top: 1px; }
.amc-close { background: rgba(255,255,255,.16); border: none; color: #fff; cursor: pointer; width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.amc-close:hover { background: rgba(255,255,255,.28); }
.amc-close svg { width: 17px; height: 17px; }

/* ── 본문 ── */
.amc-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--amc-surface-2); scroll-behavior: smooth; }
.amc-body::-webkit-scrollbar { width: 7px; }
.amc-body::-webkit-scrollbar-thumb { background: rgba(100,116,139,.32); border-radius: 4px; }

.amc-bubble {
  max-width: 84%; padding: 11px 14px; font-size: 14px; line-height: 1.62;
  border-radius: 16px; word-break: break-word; white-space: normal; animation: amcIn .22s ease-out;
}
@keyframes amcIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.amc-bot { align-self: flex-start; background: var(--amc-surface); color: var(--amc-text); border: 1px solid var(--amc-border); border-bottom-left-radius: 5px; }
.amc-user { align-self: flex-end; background: linear-gradient(135deg, var(--amc-brand) 0%, var(--amc-brand-700) 100%); color: #fff; border-bottom-right-radius: 5px; }
.amc-bubble a { color: var(--amc-brand); font-weight: 700; text-decoration: underline; }
.amc-user a { color: #fff; }

/* 타이핑 */
.amc-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.amc-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--amc-muted); opacity: .5; animation: amcBlink 1.3s infinite both; }
.amc-typing span:nth-child(2) { animation-delay: .2s; }
.amc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes amcBlink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ── 추천 칩(ON 차용: 라벨 + 칩 그리드) ── */
.amc-sug { display: flex; flex-direction: column; gap: 7px; padding: 0 16px 6px; background: var(--amc-surface-2); }
.amc-sug:empty { display: none; }
.amc-sug-label { font-size: 11.5px; font-weight: 700; color: var(--amc-muted); letter-spacing: -.01em; }
.amc-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.amc-chip {
  border: 1px solid var(--amc-border); background: var(--amc-surface); color: var(--amc-brand-700);
  font-family: inherit; font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 999px;
  cursor: pointer; transition: all .15s;
}
.amc-chip:hover { border-color: var(--amc-brand); background: var(--brand-50, #eef2ff); transform: translateY(-1px); }

/* ── 안내 카드(가격·혜택 등) ── */
.amc-card {
  align-self: flex-start; max-width: 88%; background: var(--amc-surface);
  border: 1px solid var(--amc-border); border-radius: 14px; padding: 13px 15px;
  box-shadow: 0 4px 14px rgba(2, 6, 23, .06); animation: amcIn .22s ease-out;
}
.amc-card-t { font-weight: 800; font-size: 13.5px; color: var(--amc-brand-700); margin-bottom: 9px; letter-spacing: -.01em; }
.amc-card-row { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; font-size: 13px; }
.amc-card-k { color: var(--amc-muted); }
.amc-card-v { font-weight: 700; color: var(--amc-text); text-align: right; }
.amc-card-note { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--amc-border); font-size: 11.5px; color: var(--amc-muted); line-height: 1.55; }

/* ── Proactive 넛지(먼저 말 걸기) — FAB 위 말풍선 ── */
.amc-nudge {
  position: fixed; right: 22px; bottom: 94px; z-index: 2147482999;
  max-width: 256px; background: var(--amc-surface); color: var(--amc-text);
  border: 1px solid var(--amc-border); border-radius: 16px; padding: 14px 16px 14px 16px;
  box-shadow: 0 16px 40px rgba(2, 6, 23, .22), 0 3px 10px rgba(2, 6, 23, .12); cursor: pointer;
  opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .22s ease, transform .22s ease;
}
.amc-nudge.amc-nudge-in { opacity: 1; transform: translateY(0) scale(1); }
.amc-nudge::after {
  content: ""; position: absolute; right: 26px; bottom: -7px; width: 14px; height: 14px;
  background: var(--amc-surface); border-right: 1px solid var(--amc-border); border-bottom: 1px solid var(--amc-border);
  transform: rotate(45deg);
}
.amc-nudge-msg { font-size: 13px; line-height: 1.55; font-weight: 600; padding-right: 8px; }
.amc-nudge-x {
  position: absolute; top: 7px; right: 9px; width: 20px; height: 20px; border: none; background: transparent;
  color: var(--amc-muted); font-size: 17px; line-height: 1; cursor: pointer; border-radius: 6px;
}
.amc-nudge-x:hover { background: var(--amc-surface-2); color: var(--amc-text); }
@media (max-width: 480px) { .amc-nudge { right: 16px; bottom: 88px; } }

/* ── 입력 ── */
.amc-input { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px; background: var(--amc-surface); border-top: 1px solid var(--amc-border); }
.amc-textarea {
  flex: 1; resize: none; border: 1px solid var(--amc-border); border-radius: 13px; padding: 11px 13px;
  font-family: inherit; font-size: 14px; line-height: 1.45; color: var(--amc-text); background: var(--amc-surface-2);
  max-height: 120px; outline: none; transition: border-color .15s;
}
.amc-textarea:focus { border-color: var(--amc-brand); background: var(--amc-surface); }
.amc-send {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; border: none; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--amc-brand) 0%, var(--amc-brand-700) 100%);
  display: flex; align-items: center; justify-content: center; transition: transform .12s, opacity .12s;
}
.amc-send:hover { transform: scale(1.06); }
.amc-send:disabled { opacity: .5; cursor: default; transform: none; }
.amc-send svg { width: 19px; height: 19px; }
.amc-foot { font-size: 10.5px; color: var(--amc-muted); text-align: center; padding: 0 14px 10px; background: var(--amc-surface); line-height: 1.5; }

/* ── 신청 폼(동의 게이트) ── */
.amc-leadform {
  align-self: stretch; background: var(--amc-surface); border: 1px solid var(--amc-brand); border-radius: 14px;
  padding: 15px; display: flex; flex-direction: column; gap: 9px; animation: amcIn .25s ease-out;
  box-shadow: 0 6px 20px rgba(79, 70, 229, .12);
}
.amc-lf-title { font-weight: 800; font-size: 13.5px; color: var(--amc-text); }
.amc-lf-in {
  border: 1px solid var(--amc-border); border-radius: 10px; padding: 11px 12px; font-family: inherit;
  font-size: 13.5px; color: var(--amc-text); background: var(--amc-surface-2); outline: none; transition: border-color .15s;
}
.amc-lf-in:focus { border-color: var(--amc-brand); background: var(--amc-surface); }
.amc-lf-consent {
  display: flex; align-items: flex-start; gap: 9px; background: var(--amc-surface-2); border: 1px solid var(--amc-border);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 11.5px; line-height: 1.6; color: var(--amc-muted);
}
.amc-lf-consent input { width: 17px; height: 17px; margin-top: 1px; flex-shrink: 0; accent-color: var(--amc-brand); cursor: pointer; }
.amc-lf-submit {
  border: none; border-radius: 11px; padding: 13px; font-family: inherit; font-size: 14px; font-weight: 800; color: #fff;
  cursor: pointer; background: linear-gradient(135deg, var(--amc-brand) 0%, var(--amc-brand-700) 100%); transition: transform .12s, opacity .12s;
}
.amc-lf-submit:not(:disabled):hover { transform: translateY(-1px); }
.amc-lf-submit:disabled { opacity: .45; cursor: default; }
.amc-lf-err { font-size: 12px; color: var(--danger, #dc2626); min-height: 0; }
.amc-lf-err:empty { display: none; }
.amc-lf-done { display: flex; align-items: center; gap: 11px; font-size: 13.5px; line-height: 1.55; color: var(--amc-text); }
.amc-lf-check { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: #ecfdf5; color: #10b981; font-size: 21px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

/* ── 모바일 ── */
@media (max-width: 480px) {
  .amc-panel { right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%; height: 88vh; max-height: 88vh; border-radius: 18px 18px 0 0; }
  .amc-fab { right: 16px; bottom: 16px; }
}
