/* =====================================================================
   PayBridge — 컴포넌트 스타일
   tokens.css (NICE정보통신 디자인 시스템) 를 먼저 로드한 뒤 이 파일을 로드하세요.
   <link rel="stylesheet" href="/css/tokens.css">
   <link rel="stylesheet" href="/css/paybridge.css">

   원본 PayBridge 시안(PayBridge.dc.html)의 인라인 스타일을 클래스로 추출한 것입니다.
   ===================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&display=swap");

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

:root {
  --font-app: "Pretendard Variable", Pretendard, "Noto Sans JP", "Noto Sans SC",
              -apple-system, system-ui, sans-serif;
  --bar-h: 96px;              /* 하단 음성 바 높이 */
  --tap: 44px;                /* 최소 터치 타깃 */

  /* tokens.css 에 없는 보조 색 — 배너 본문용 (배경 대비 AA 확보) */
  --warning-fg: #8A6100;
  --danger-fg:  #A32626;
}

body {
  font-family: var(--font-app);
  background: var(--gray-100);
  color: var(--fg1);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; }
::selection { background: var(--blue-100); }

/* ── 애니메이션 ─────────────────────────────────────────────── */
@keyframes pbWave   { 0%,100% { transform: scaleY(.28); } 50% { transform: scaleY(1); } }
@keyframes pbOrb    { 0%,100% { transform: scale(1); }    50% { transform: scale(1.08); } }
@keyframes pbRing   { 0%   { box-shadow: 0 0 0 0 rgba(82,148,255,.5); }
                      100% { box-shadow: 0 0 0 16px rgba(82,148,255,0); } }
@keyframes pbFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pbBlink  { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes pbSpin   { to { transform: rotate(360deg); } }
@keyframes pbDot    { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.pb-fade { animation: pbFadeUp .4s cubic-bezier(.22,1,.36,1) both; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── 브랜드 락업 ────────────────────────────────────────────── */
.pb-brand { display: flex; align-items: center; gap: 12px; }
.pb-logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--nice-navy); overflow: hidden; flex: none;
}
.pb-logo::before {                       /* NICE CI 그리드 메타포 */
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.16) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px);
  background-size: 8px 8px;
}
.pb-logo::after {                        /* 중앙의 '빛' */
  content: ""; position: relative; width: 9px; height: 9px; border-radius: 2px;
  background: var(--sky); box-shadow: 0 0 12px rgba(82,148,255,.9);
}
.pb-brand__name { display: flex; align-items: baseline; gap: 7px; line-height: 1; }
.pb-brand__nice { font-size: 20px; font-weight: 800; color: var(--nice-navy); letter-spacing: -.02em; }
.pb-brand__div  { width: 1px; height: 14px; background: var(--border-strong); }
.pb-brand__prod { font-size: 19px; font-weight: 700; color: var(--fg1); letter-spacing: -.02em; }
.pb-brand__tag  { font-size: 11px; color: var(--fg3); font-weight: 500; margin-top: 6px; }

/* ── 공통 버튼 ──────────────────────────────────────────────── */
.pb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--gray-0); color: var(--fg1);
  transition: background .12s, border-color .12s;
}
.pb-btn:hover  { background: var(--gray-50); }
.pb-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.pb-btn--primary { background: var(--primary); border-color: var(--primary); color: var(--gray-0); }
.pb-btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.pb-btn--ghost   { background: transparent; border-color: transparent; }
.pb-btn--danger  { background: var(--danger); border-color: var(--danger); color: var(--gray-0); }
.pb-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* 아이콘 원형 버튼 */
.pb-iconbtn {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: var(--r-full); border: 1px solid var(--border-strong);
  background: var(--gray-0); color: var(--fg1); cursor: pointer;
}
.pb-iconbtn--onbrand { border-color: rgba(255,255,255,.22); background: rgba(255,255,255,.10); color: var(--gray-0); }

/* ── 세그먼트 토글 (입력/받기 모달리티, 언어 등) ─────────────── */
.pb-seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--gray-100); border-radius: var(--r-full);
}
.pb-seg__item {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 16px; border: none; background: transparent;
  border-radius: var(--r-full); font-size: 14px; font-weight: 600;
  color: var(--fg3); cursor: pointer; transition: background .12s, color .12s;
}
.pb-seg__item[aria-selected="true"] {
  background: var(--gray-0); color: var(--fg1); box-shadow: var(--shadow-xs);
}

/* ── 칩 ─────────────────────────────────────────────────────── */
.pb-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600;
  background: var(--gray-50); border: 1px solid var(--border); color: var(--fg2);
  cursor: default;
}
.pb-chip--action    { cursor: pointer; background: var(--gray-0); border-color: var(--border-strong); color: var(--fg1); }
.pb-chip--action:hover { background: var(--gray-50); }
.pb-chip--accent    { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-700); }
.pb-chip--live      { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.pb-chip--live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger); animation: pbBlink 1.4s ease-in-out infinite;
}

/* ── 배너 ───────────────────────────────────────────────────── */
.pb-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; line-height: 1.5;
}
.pb-banner--info     { background: var(--info-bg);    color: var(--blue-700); }
.pb-banner--warn     { background: var(--warning-bg); color: var(--warning-fg); }
.pb-banner--critical { background: var(--danger-bg);  color: var(--danger-fg); }

/* ── 대화 스트림 (구글 번역 대화 모드 참조) ──────────────────── */
.pb-stream {
  flex: 1; overflow-y: auto; padding: 16px 20px 8px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}
.pb-turn { padding: 16px 0; border-bottom: 1px solid var(--gray-100); }
.pb-turn:last-child { border-bottom: none; }

/* 방향 칩 — 탭하면 화자 정정 */
.pb-turn__dir {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; color: var(--fg3);
  background: transparent; border: 1px solid transparent; cursor: pointer;
}
.pb-turn__dir:hover { background: var(--gray-50); border-color: var(--border); }
.pb-turn__dir[data-unknown="true"] { color: var(--warning); background: var(--warning-bg); }

/* 원문 — 매장 거리에서 읽혀야 하므로 크게 */
.pb-turn__primary {
  font-size: clamp(22px, 3.4vw, 30px); font-weight: 600;
  line-height: 1.28; letter-spacing: -.02em; color: var(--fg1);
  text-wrap: pretty; word-break: break-word;
}
/* 역번역 — 작게, 회색 */
.pb-turn__secondary {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  font-size: 14px; line-height: 1.5; color: var(--fg3); word-break: break-word;
}
/* 상대(상담원) 발화는 우측 정렬 + 블루 서피스 */
.pb-turn--remote { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.pb-turn--remote .pb-turn__body {
  background: var(--blue-50); border-radius: var(--r-lg);
  padding: 14px 16px; max-width: 88%;
}
/* 스트리밍 중 커서 */
.pb-caret {
  display: inline-block; width: 2px; height: 1em; vertical-align: -2px;
  margin-left: 2px; background: var(--primary);
  animation: pbBlink 1s steps(1) infinite;
}
/* 상대가 말하는 중 */
.pb-typing { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--primary); }
.pb-typing__dots { display: inline-flex; gap: 4px; }
.pb-typing__dots span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pbDot 1.2s infinite; }
.pb-typing__dots span:nth-child(2) { animation-delay: .2s; }
.pb-typing__dots span:nth-child(3) { animation-delay: .4s; }

/* 최신으로 스크롤 FAB */
.pb-scrollfab {
  position: absolute; right: 20px; bottom: calc(var(--bar-h) + 16px);
  width: 48px; height: 48px; border-radius: var(--r-full); border: none;
  background: var(--primary); color: var(--gray-0); cursor: pointer;
  box-shadow: var(--shadow-lg); display: grid; place-items: center;
}

/* ── 하단 음성 바 (navy) ────────────────────────────────────── */
.pb-voicebar {
  display: flex; align-items: center; gap: 14px;
  min-height: var(--bar-h); padding: 16px 20px;
  background: var(--nice-navy); color: var(--gray-0); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.pb-voicebar__meta { flex: 1; min-width: 0; }
.pb-voicebar__label { font-size: 15px; font-weight: 700; }
.pb-voicebar__sub   { font-size: 12px; color: var(--blue-200); margin-top: 3px; }

/* 파형 — 7개 바. JS 로 --h 를 넣거나 기본값 사용 */
.pb-wave { display: flex; align-items: center; gap: 3px; height: 30px; flex: none; }
.pb-wave i {
  display: block; width: 4px; height: 28px; border-radius: 2px;
  background: rgba(255,255,255,.25); transform-origin: center; transform: scaleY(.28);
}
.pb-wave[data-active="true"] i { background: var(--sky); animation: pbWave 1s ease-in-out infinite; }
.pb-wave[data-active="true"] i:nth-child(1) { animation-duration: .88s; animation-delay: 0s;    transform: scaleY(.45); }
.pb-wave[data-active="true"] i:nth-child(2) { animation-duration: 1.02s; animation-delay: .08s; transform: scaleY(.80); }
.pb-wave[data-active="true"] i:nth-child(3) { animation-duration: 1.10s; animation-delay: .16s; transform: scaleY(1);   }
.pb-wave[data-active="true"] i:nth-child(4) { animation-duration: .92s; animation-delay: .24s;  transform: scaleY(.55); }
.pb-wave[data-active="true"] i:nth-child(5) { animation-duration: 1.08s; animation-delay: .32s; transform: scaleY(.95); }
.pb-wave[data-active="true"] i:nth-child(6) { animation-duration: .86s; animation-delay: .40s;  transform: scaleY(.40); }
.pb-wave[data-active="true"] i:nth-child(7) { animation-duration: 1.00s; animation-delay: .48s; transform: scaleY(.75); }

/* 마이크 FAB — 잡음 레벨은 --pb-noise (0~1) 로 링 세기 조절 */
.pb-mic {
  position: relative; width: 64px; height: 64px; flex: none;
  border-radius: var(--r-full); border: none; cursor: pointer;
  background: var(--primary); color: var(--gray-0); display: grid; place-items: center;
}
.pb-mic[data-state="listening"] { animation: pbRing 1.6s ease-out infinite; }
.pb-mic[data-state="speaking"]  { animation: pbOrb .9s ease-in-out infinite; }
.pb-mic[data-state="off"]       { background: var(--danger); }

/* ── 상담원 콘솔 레이아웃 ───────────────────────────────────── */
.pb-console { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
@media (max-width: 900px) { .pb-console { grid-template-columns: 1fr; } }

.pb-console__list { border-right: 1px solid var(--border); background: var(--gray-0); overflow-y: auto; }
.pb-console__main { display: flex; flex-direction: column; min-width: 0; background: var(--gray-50); }

.pb-sessionitem {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px; border: none; border-bottom: 1px solid var(--gray-100);
  background: transparent;
}
.pb-sessionitem:hover { background: var(--gray-50); }
.pb-sessionitem[aria-selected="true"] { background: var(--blue-50); box-shadow: inset 3px 0 0 var(--primary); }
.pb-sessionitem__id   { font-size: 13px; font-weight: 700; color: var(--fg1); }
.pb-sessionitem__meta { font-size: 12px; color: var(--fg3); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.pb-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pb-dot--calling { background: var(--danger); animation: pbBlink 1.4s ease-in-out infinite; }
.pb-dot--waiting { background: var(--warning); }
.pb-dot--active  { background: var(--success); }
.pb-dot--idle    { background: var(--gray-300); }

/* 세션 헤더 (navy) */
.pb-sessionhead {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 20px; background: var(--nice-navy); color: var(--gray-0);
}
.pb-sessionhead__avatar {
  width: 40px; height: 40px; border-radius: var(--r-full); flex: none;
  display: grid; place-items: center; background: rgba(255,255,255,.14);
  font-size: 13px; font-weight: 800; letter-spacing: .02em;
}

/* 답변 작성 */
.pb-composer { border-top: 1px solid var(--border); background: var(--gray-0); padding: 16px 20px; }
.pb-composer__quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pb-composer__input {
  width: 100%; min-height: 88px; resize: vertical;
  padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 15px; line-height: 1.5; color: var(--fg1); background: var(--gray-50);
}
.pb-composer__input:focus { outline: none; background: var(--gray-0); box-shadow: var(--shadow-focus); }
.pb-composer__foot {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.pb-composer__hint { flex: 1; min-width: 200px; font-size: 12px; color: var(--fg3); }
.pb-composer__hint strong { color: var(--fg2); }

/* ── 카드 / 패널 ────────────────────────────────────────────── */
.pb-card {
  background: var(--gray-0); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.pb-card__head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--fg1);
  display: flex; align-items: center; gap: 8px;
}

/* ── 모드 배지 (LIVE / HYBRID / SCRIPT) ─────────────────────── */
.pb-mode {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
}
.pb-mode--live   { background: var(--success-bg); color: var(--success); }
.pb-mode--hybrid { background: var(--warning-bg); color: var(--warning-fg); }
.pb-mode--script { background: var(--gray-100);   color: var(--fg3); }

/* ── 유틸 ───────────────────────────────────────────────────── */
.pb-row    { display: flex; align-items: center; gap: 12px; }
.pb-col    { display: flex; flex-direction: column; }
.pb-spacer { flex: 1; }
.pb-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
