/* B2B AI Agent — 채팅 위젯 */

#b2b-agent-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  cursor: pointer;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
#b2b-agent-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.22); }
#b2b-agent-fab svg { width: 26px; height: 26px; }

#b2b-agent-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}
#b2b-agent-panel[hidden] { display: none; }

#b2b-agent-header {
  background: #1e3a5f;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#b2b-agent-header .title { font-weight: 600; font-size: 15px; }
#b2b-agent-header .subtitle { font-size: 11px; opacity: .75; margin-top: 2px; }
#b2b-agent-header button {
  background: transparent;
  color: #fff;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}
#b2b-agent-header button:hover { background: rgba(255,255,255,.12); }

#b2b-agent-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f7f8fa;
  font-size: 14px;
  line-height: 1.55;
}

.b2b-msg { margin-bottom: 12px; }
.b2b-msg .bubble {
  display: inline-block;
  padding: 9px 13px;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.b2b-msg.user { text-align: right; }
.b2b-msg.user .bubble { background: #1e3a5f; color: #fff; border-bottom-right-radius: 4px; }
.b2b-msg.assistant .bubble { background: #fff; color: #222; border: 1px solid #e3e6ea; border-bottom-left-radius: 4px; }
.b2b-msg.assistant .bubble strong { color: #0a4f1f; }
.b2b-msg.assistant .bubble table { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.b2b-msg.assistant .bubble th,
.b2b-msg.assistant .bubble td { border: 1px solid #ddd; padding: 4px 8px; text-align: left; }
.b2b-msg.assistant .bubble th { background: #f0f2f5; }
.b2b-msg.assistant .bubble ul { margin: 6px 0; padding-left: 18px; }
.b2b-msg.assistant .bubble a { color: #1e3a5f; }
.b2b-msg.assistant .bubble img.b2b-product-img {
  max-width: 80px;
  max-height: 80px;
  border-radius: 6px;
  display: inline-block;
  vertical-align: middle;
  margin: 2px 4px 2px 0;
  border: 1px solid #e3e6ea;
  object-fit: cover;
}
.b2b-msg.assistant .bubble a img.b2b-product-img:hover {
  border-color: #1e3a5f;
  transform: scale(1.04);
  transition: transform .12s ease;
}
.b2b-msg.assistant .bubble td img.b2b-product-img { max-width: 64px; max-height: 64px; }

.b2b-tools {
  font-size: 11px;
  color: #6c7480;
  margin: 4px 0 4px 4px;
  cursor: pointer;
  user-select: none;
}
.b2b-tools-detail {
  margin: 4px 0 8px 4px;
  padding: 8px;
  background: #eef0f3;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: #444;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
.b2b-tools-detail.open { display: block; }
.b2b-tools-detail .t-name { font-weight: 600; color: #1e3a5f; }
.b2b-tools-detail .t-args { color: #555; }
.b2b-tools-detail .t-result { color: #0a4f1f; word-break: break-all; }
.b2b-tools-detail hr { border: 0; border-top: 1px dashed #cdd2d8; margin: 6px 0; }

.b2b-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  margin-left: 2px;
}
.b2b-suggestion-chip {
  padding: 5px 11px;
  border: 1px solid #1e3a5f;
  border-radius: 16px;
  background: #fff;
  color: #1e3a5f;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.b2b-suggestion-chip:hover { background: #1e3a5f; color: #fff; }
.b2b-suggestion-chip:active { transform: translateY(1px); }

.b2b-thinking {
  display: inline-block;
  padding: 9px 13px;
  background: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  color: #888;
  font-style: italic;
}
.b2b-thinking .dot { animation: b2b-blink 1.2s infinite; }
.b2b-thinking .dot:nth-child(2) { animation-delay: .2s; }
.b2b-thinking .dot:nth-child(3) { animation-delay: .4s; }
@keyframes b2b-blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.b2b-error { color: #b3261e; font-size: 12px; margin: 6px 0; }

#b2b-agent-input-area {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid #e3e6ea;
  background: #fff;
}
#b2b-agent-input {
  width: 100%;
  border: 1px solid #d6dae0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
  box-sizing: border-box;
  min-height: 38px;
  max-height: 120px;
}
#b2b-agent-input:focus { outline: 2px solid #1e3a5f; outline-offset: -1px; }
#b2b-agent-send-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
#b2b-agent-hint { font-size: 11px; color: #888; }
#b2b-agent-send {
  background: #1e3a5f;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
#b2b-agent-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 480px) {
  #b2b-agent-panel { width: calc(100vw - 20px); right: 10px; bottom: 80px; height: 70vh; }
  #b2b-agent-fab { right: 14px; bottom: 14px; }
}

/* 전체화면 모드 */
#b2b-agent-panel.b2b-fullscreen {
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100vw; height: 100vh;
  max-width: none; max-height: none;
  border-radius: 0;
  border: 0;
}
#b2b-agent-panel.b2b-fullscreen #b2b-agent-body {
  font-size: 15px;
  padding: 22px max(22px, calc((100vw - 800px) / 2));
}
#b2b-agent-panel.b2b-fullscreen #b2b-agent-input-area {
  padding: 14px max(22px, calc((100vw - 800px) / 2));
}
body.b2b-agent-fs-active #b2b-agent-fab { display: none; }
body.b2b-agent-fs-active { overflow: hidden; }

/* mode toggle 버튼 */
#b2b-agent-mode-toggle { font-size: 14px; }

/* theme drawer 트리거 (🛒/📋) — 풀스크린에서만 노출.
 * mini 모드는 theme 헤더의 trigger 가 그대로 보이므로 panel 안에 둘 필요 없음. */
#b2b-agent-cart-trigger,
#b2b-agent-quote-trigger { display: none; font-size: 14px; }
#b2b-agent-panel.b2b-fullscreen #b2b-agent-cart-trigger,
#b2b-agent-panel.b2b-fullscreen #b2b-agent-quote-trigger { display: inline-block; }

/* 풀스크린 활성 시 theme drawer 가 panel 위로 떠야 함.
 * panel: 99999 / fab: 99998 — drawer 는 평소 1000/1001 이라 가려진다.
 * 풀스크린 동안만 drawer 를 panel 위로 올림 (mini/일반 페이지에서는 기본값 유지). */
body.b2b-agent-fs-active .bsmt-drawer-backdrop { z-index: 100000; }
body.b2b-agent-fs-active .bsmt-drawer { z-index: 100001; }

/* chat 전용 페이지 */
.b2b-agent-chat-page-mount {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.b2b-agent-chat-loading {
  color: #999;
  font-size: 14px;
}
body.b2b-agent-chat-page-body .site-content,
body.b2b-agent-chat-page-body .entry-title,
body.b2b-agent-chat-page-body .entry-header { display: none; }
body.b2b-agent-chat-page-body { background: #f7f8fa; }

/* ───────── v2.x Phase A: 구조화 카드 ───────── */
.b2b-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.b2b-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.b2b-card__img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 6px;
  background: #f4f5f7;
  flex-shrink: 0;
}
.b2b-card__img--blank { background: #f0f1f3; }
.b2b-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.b2b-card__name {
  font-weight: 600;
  font-size: 13px;
  color: #1a1f29;
  text-decoration: none;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.b2b-card__name:hover { text-decoration: underline; }
.b2b-card__price {
  font-size: 16px;
  font-weight: 700;
  color: #1a1f29;
}
.b2b-card__price small { font-size: 11px; font-weight: 500; color: #666; margin-left: 2px; }
.b2b-card__price--na { font-size: 12px; font-weight: 500; color: #888; }
.b2b-card__naver {
  font-size: 11px;
  color: #555;
}
.b2b-card__naver a { color: #03c75a; text-decoration: none; }
.b2b-card__naver a:hover { text-decoration: underline; }
.b2b-card__mall { color: #888; }
.b2b-card__saving {
  font-size: 12px;
  color: #0a6e2a;
  background: #e8f5ec;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  align-self: flex-start;
}
.b2b-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.b2b-card__btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.3;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.b2b-card__btn:hover:not([disabled]) { background: #1d4ed8; color: #fff; }
.b2b-card__btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.b2b-card__btn--ghost {
  background: #fff;
  color: #2563eb;
  border-color: #c7d2fe;
}
.b2b-card__btn--ghost:hover:not([disabled]) { background: #eef2ff; color: #1d4ed8; }

/* order-summary card */
.b2b-card--summary { flex-direction: column; gap: 6px; }
.b2b-card--summary > .b2b-card__body { gap: 8px; }
.b2b-summary__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid #eef0f3;
  border-bottom: 1px solid #eef0f3;
  padding: 6px 0;
}
.b2b-summary__row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.b2b-summary__thumb {
  width: 36px; height: 36px;
  object-fit: contain;
  border-radius: 4px;
  background: #f4f5f7;
  flex-shrink: 0;
}
.b2b-summary__rowbody { flex: 1; min-width: 0; }
.b2b-summary__name {
  font-weight: 600;
  color: #1a1f29;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.b2b-summary__name:hover { text-decoration: underline; }
.b2b-summary__meta { font-size: 11px; color: #666; }
.b2b-summary__sub { font-weight: 600; color: #1a1f29; white-space: nowrap; }
.b2b-summary__totals {
  display: flex;
  justify-content: flex-end;
  font-size: 13px;
}
.b2b-summary__totals > div { display: flex; gap: 12px; align-items: baseline; }
.b2b-summary__totals strong { font-size: 16px; color: #1a1f29; }

/* form card */
.b2b-card--form { flex-direction: column; }
.b2b-card--form > .b2b-card__body { gap: 10px; }
.b2b-form { display: flex; flex-direction: column; gap: 10px; }
.b2b-form__field { display: flex; flex-direction: column; gap: 4px; }
.b2b-form__label { font-size: 12px; color: #444; font-weight: 600; }
.b2b-form__label em { color: #b3261e; font-style: normal; }
.b2b-form__input {
  font: inherit;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #cdd2d8;
  border-radius: 6px;
  background: #fff;
  outline: none;
}
.b2b-form__input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.b2b-form__help { font-size: 11px; color: #777; }

/* status card */
.b2b-card--status { align-items: flex-start; }
.b2b-card--status.is-ok  { border-color: #b6e2c5; background: #f3fbf6; }
.b2b-card--status.is-err { border-color: #f1c2c2; background: #fcf3f3; }
.b2b-card__status-icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  border-radius: 50%;
}
.b2b-card--status.is-ok  .b2b-card__status-icon { background: #d1eedc; color: #0a6e2a; }
.b2b-card--status.is-err .b2b-card__status-icon { background: #f6d7d7; color: #b3261e; }
.b2b-card__detail { font-size: 12px; color: #555; line-height: 1.4; }
.b2b-card__meta   { font-size: 11px; color: #666; margin-top: 2px; }

/* payment card */
.b2b-card--payment { align-items: flex-start; border-color: #c7d2fe; background: #eef2ff; }
.b2b-card--payment .b2b-card__status-icon { background: #c7d2fe; color: #1d4ed8; }
.b2b-card__btn--pay { background: #1d4ed8; }
.b2b-card__btn--pay:hover:not([disabled]) { background: #1e40af; }

/* confirm card */
.b2b-card--confirm { flex-direction: column; border-color: #fcd34d; background: #fffbeb; }
.b2b-card--confirm.is-danger { border-color: #fca5a5; background: #fef2f2; }
.b2b-card__btn--danger { background: #b91c1c; }
.b2b-card__btn--danger:hover:not([disabled]) { background: #991b1b; }
