/* LETHER chat widget — minimal editorial theme.
   Palette: warm white #FAF9F7, charcoal #1A1A1A, violet accent #643AAF,
   bot bubble #F5F4F1. Font: Pretendard. */

:root {
  --sw-bg: #faf9f7;
  --sw-text: #1a1a1a;
  --sw-violet: #643aaf;
  --sw-bot-bubble: #f5f4f1;
  --sw-border: #e7e5e1;
  --sw-muted: #8c8880;
  --sw-radius: 12px;
  --sw-font: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui,
    "Apple SD Gothic Neo", sans-serif;
}

/* --- Demo page (backdrop only) --- */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--sw-font);
  color: var(--sw-text);
  background: var(--sw-bg);
}
.demo-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.demo-eyebrow {
  color: var(--sw-violet);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.demo-title {
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 12px;
}
.demo-desc {
  color: var(--sw-muted);
  font-size: 15px;
  margin: 0;
}

/* --- Launcher button (bottom-right) --- */
.sw-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sw-violet);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(100, 58, 175, 0.35);
  z-index: 2147483000;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sw-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(100, 58, 175, 0.42);
}
.sw-launcher svg {
  width: 26px;
  height: 26px;
}

/* --- Chat panel --- */
.sw-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--sw-bg);
  border: 1px solid var(--sw-border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(26, 26, 26, 0.16);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483000;
}
.sw-panel.sw-open {
  display: flex;
}

/* Resize handles (thin invisible grab zones along the panel edges) */
.sw-rh {
  position: absolute;
  z-index: 10;
  touch-action: none;
}
.sw-rh-n {
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
}
.sw-rh-s {
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
}
.sw-rh-e {
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}
.sw-rh-w {
  top: 0;
  left: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}
.sw-rh-ne {
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
  z-index: 11;
}
.sw-rh-nw {
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 11;
}
.sw-rh-se {
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 11;
}
.sw-rh-sw {
  bottom: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
  z-index: 11;
}

/* Header */
.sw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--sw-border);
  cursor: grab; /* draggable to move the panel */
  user-select: none;
}
.sw-header:active {
  cursor: grabbing;
}
.sw-header-titles {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.sw-header-eyebrow {
  color: var(--sw-violet);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  font-weight: 500;
}
.sw-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--sw-text);
}
.sw-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--sw-muted);
  display: flex;
  border-radius: 8px;
}
.sw-close:hover {
  background: var(--sw-bot-bubble);
  color: var(--sw-text);
}
.sw-close svg {
  width: 18px;
  height: 18px;
}

/* Messages area */
.sw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Bubbles */
.sw-row {
  display: flex;
}
.sw-row.sw-bot {
  justify-content: flex-start;
}
.sw-row.sw-user {
  justify-content: flex-end;
}
.sw-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--sw-radius);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.sw-bot .sw-bubble {
  background: var(--sw-bot-bubble);
  color: var(--sw-text);
  border-bottom-left-radius: 4px;
}
.sw-user .sw-bubble {
  background: var(--sw-violet);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Product cards */
.sw-products {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  max-width: 90%;
  width: 100%;
}
.sw-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
}
/* Only cards with a product_url are clickable */
.sw-card-link {
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.sw-card-link:hover {
  border-color: var(--sw-violet);
  box-shadow: 0 2px 10px rgba(100, 58, 175, 0.14);
}
.sw-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--sw-bot-bubble);
  flex-shrink: 0;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sw-muted);
}
.sw-thumb svg {
  width: 22px;
  height: 22px;
}
.sw-card-body {
  flex: 1;
  min-width: 0;
}
.sw-card-category {
  font-size: 11px;
  color: var(--sw-muted);
  margin-bottom: 2px;
}
.sw-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--sw-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sw-card-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--sw-violet);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Typing indicator */
.sw-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
  background: var(--sw-bot-bubble);
  border-radius: var(--sw-radius);
  border-bottom-left-radius: 4px;
}
.sw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sw-muted);
  animation: sw-blink 1.2s infinite ease-in-out both;
}
.sw-typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.sw-typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes sw-blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

/* Footer / input */
.sw-footer {
  border-top: 1px solid var(--sw-border);
  padding: 12px 14px;
}
.sw-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end; /* send button stays at the bottom as the box grows */
}
.sw-input {
  flex: 1;
  border: 1px solid var(--sw-border);
  border-radius: 18px;
  padding: 9px 16px;
  font-size: 14px;
  line-height: 1.4;
  font-family: var(--sw-font);
  color: var(--sw-text);
  background: #fff;
  outline: none;
  /* multiline auto-resize: starts at one line, grows, then scrolls */
  resize: none;
  overflow-y: auto;
  max-height: 120px; /* ~5–6 lines, then scrolls inside the box */
  box-sizing: border-box;
}
.sw-input:focus {
  border-color: var(--sw-violet);
}
.sw-input:disabled {
  background: var(--sw-bot-bubble);
}
.sw-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sw-violet);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sw-send:disabled {
  opacity: 0.45;
  cursor: default;
}
.sw-send svg {
  width: 18px;
  height: 18px;
}
.sw-disclaimer {
  margin: 8px 2px 0;
  font-size: 11px;
  color: var(--sw-muted);
  text-align: center;
}

/* Responsive: near-fullscreen panel on narrow screens.
   !important overrides any inline geometry left over from desktop resizing. */
@media (max-width: 480px) {
  .sw-panel {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0;
    border: none;
  }
  .sw-launcher {
    right: 16px;
    bottom: 16px;
  }
  /* No resizing on mobile — hide the grab handles entirely. */
  .sw-rh {
    display: none;
  }
}
