/*
  CLOUVI 데모 챗봇.

  style.css 와 분리해 둔다. 위젯은 모든 페이지 위에 떠 있는 독립 레이어라
  사이트 디자인 토큰만 빌려 쓰고 나머지는 이 파일 안에서 끝낸다.
*/

.sw-clouvi {
  --cl-navy: #1f4e8c;
  --cl-teal: #1e9e8a;
  --cl-line: #e5e7eb;
  --cl-ink: #1f2937;
  --cl-muted: #6b7280;

  position: fixed;
  z-index: 9999;
  right: 24px;
  bottom: 24px;
}

/* ── 런처 ───────────────────────────────────────────────────────── */
.sw-clouvi-launcher {
  display: grid;
  width: 64px;
  height: 64px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--cl-line);
  overflow: hidden;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 16px rgba(31, 78, 140, .18);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.sw-clouvi-launcher:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(31, 78, 140, .26); }
.sw-clouvi-launcher:focus-visible { outline: 2px solid var(--cl-navy); outline-offset: 3px; }
.sw-clouvi-launcher-mark { width: 100%; height: 100%; object-fit: contain; }
.sw-clouvi-launcher-close { width: 26px; height: 26px; color: var(--cl-navy); }

/* 마크와 X 는 같은 자리에서 바뀐다. */
.sw-clouvi-launcher-mark,
.sw-clouvi-launcher-close { grid-area: 1 / 1; }
.sw-clouvi-launcher-close { display: none; }
.sw-clouvi.is-open .sw-clouvi-launcher-mark { display: none; }
.sw-clouvi.is-open .sw-clouvi-launcher-close { display: block; }

/* 한 번만 통통 튄다. 계속 움직이면 읽는 것을 방해한다. */
.sw-clouvi-launcher:hover .sw-clouvi-launcher-mark { animation: sw-clouvi-bounce .5s ease; }
@keyframes sw-clouvi-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
  60% { transform: translateY(2px); }
}

/* ── 말풍선 안내 ─────────────────────────────────────────────────── */
.sw-clouvi-hint {
  position: absolute;
  right: 78px;
  bottom: 18px;
  margin: 0;
  padding: 9px 14px;
  border: 1px solid var(--cl-line);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(31, 78, 140, .14);
  color: var(--cl-ink);
  font-size: calc(13px + 1pt);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  transform: translateX(8px);
  pointer-events: none;
}
.sw-clouvi-hint.is-shown { opacity: 1; transform: none; }

/* ── 패널 ───────────────────────────────────────────────────────── */
.sw-clouvi-panel {
  position: absolute;
  right: 0;
  bottom: 100px;
  display: flex;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 140px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--cl-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(16, 47, 103, .22);
}
.sw-clouvi-panel[hidden] { display: none; }

.sw-clouvi-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(135deg, var(--cl-navy), var(--cl-teal));
  color: #fff;
}
.sw-clouvi-head-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #fff;
}
.sw-clouvi-head-mark img { width: 28px; height: 28px; object-fit: contain; }
.sw-clouvi-head-text { display: flex; min-width: 0; flex-direction: column; }
.sw-clouvi-head-text strong { font-size: calc(16px + 1pt); font-weight: 700; }
.sw-clouvi-head-text span { color: rgba(255, 255, 255, .8); font-size: calc(12px + 1pt); }
.sw-clouvi-head-close {
  width: 30px;
  height: 30px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: calc(17px + 1pt);
  cursor: pointer;
}
.sw-clouvi-head-close:hover { background: rgba(255, 255, 255, .28); }

/* ── 대화 ───────────────────────────────────────────────────────── */
.sw-clouvi-log { flex: 1; padding: 18px 16px; overflow-y: auto; scroll-behavior: smooth; }
.sw-clouvi-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 14px; }
.sw-clouvi-row.is-me { justify-content: flex-end; }
.sw-clouvi-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--cl-line);
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
}
.sw-clouvi-bubble {
  max-width: 250px;
  padding: 11px 14px;
  border-radius: 16px 16px 16px 16px;
  border-top-left-radius: 4px;
  background: #f3f4f6;
  color: var(--cl-ink);
  font-size: calc(15px + 1pt);
  line-height: 1.6;
}
.sw-clouvi-row.is-me .sw-clouvi-bubble {
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
  background: var(--cl-navy);
  color: #fff;
}

/* 추천 칩 */
.sw-clouvi-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px 40px; }
.sw-clouvi-chips button {
  padding: 8px 13px;
  border: 1px solid var(--cl-line);
  border-radius: 999px;
  background: #fff;
  color: var(--cl-navy);
  font: inherit;
  font-size: calc(13px + 1pt);
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.sw-clouvi-chips button:hover { border-color: var(--cl-teal); background: #f0fbf8; }

/* 상품 카드 */
.sw-clouvi-cards {
  display: flex;
  gap: 10px;
  margin: 0 0 14px 40px;
  padding-bottom: 6px;
  overflow-x: auto;
}
.sw-clouvi-card {
  display: block;
  width: 132px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--cl-line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease, transform .2s ease;
}
.sw-clouvi-card:hover { transform: translateY(-3px); border-color: var(--cl-teal); }
.sw-clouvi-card img { display: block; width: 100%; height: 96px; background: #f3f4f6; object-fit: cover; }
.sw-clouvi-card b { display: block; padding: 9px 10px 0; color: var(--cl-ink); font-size: calc(13px + 1pt); font-weight: 600; line-height: 1.4; }
.sw-clouvi-card span { display: block; padding: 4px 10px 10px; color: var(--cl-navy); font-size: calc(13px + 1pt); font-weight: 700; }

/* 타이핑 표시 */
.sw-clouvi-typing { display: flex; gap: 4px; padding: 14px; border-radius: 16px; border-top-left-radius: 4px; background: #f3f4f6; }
.sw-clouvi-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--cl-muted); animation: sw-clouvi-dot 1.2s infinite ease-in-out; }
.sw-clouvi-typing i:nth-child(2) { animation-delay: .15s; }
.sw-clouvi-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sw-clouvi-dot {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── 입력 ───────────────────────────────────────────────────────── */
.sw-clouvi-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--cl-line); }
.sw-clouvi-form input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--cl-line);
  border-radius: 999px;
  color: var(--cl-ink);
  font: inherit;
  font-size: calc(14px + 1pt);
}
.sw-clouvi-form input:focus { outline: 2px solid var(--cl-teal); outline-offset: -1px; }
.sw-clouvi-form button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--cl-teal);
  color: #fff;
  font-size: calc(19px + 1pt);
  cursor: pointer;
  transition: background .2s ease;
}
.sw-clouvi-form button:hover { background: #17806f; }

.sw-clouvi-foot { margin: 0; padding: 0 14px 12px; color: var(--cl-muted); font-size: calc(11px + 1pt); text-align: center; }

/* ── 좁은 화면 ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sw-clouvi { right: 16px; bottom: 16px; }
  .sw-clouvi-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .sw-clouvi-hint { right: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .sw-clouvi-launcher,
  .sw-clouvi-hint,
  .sw-clouvi-card { transition: none; }
  .sw-clouvi-launcher:hover .sw-clouvi-launcher-mark,
  .sw-clouvi-typing i { animation: none; }
}

/* 2026-10-14: 런처 확대 64 → 88px (모바일 72px), 다람쥐 그림이 꽉 차게 */
.sw-clouvi-launcher { width: 88px; height: 88px; box-shadow: 0 6px 20px rgba(31, 78, 140, .22); }
.sw-clouvi-launcher-mark { padding: 3px; }
.sw-clouvi-launcher-close { width: 30px; height: 30px; }
@media (max-width: 600px) { .sw-clouvi-launcher { width: 72px; height: 72px; } }
