/* JU Housing 24/7 AI chat widget — isolated namespace (ju-chat-widget) */
.ju-chat-widget {
  --ju-chat-widget-accent: #059669;
  --ju-chat-widget-accent-dark: #047857;
  --ju-chat-widget-header: #0f172a;
  font-family: "Pretendard Variable", Pretendard, sans-serif;
}

/* index.html 플로팅 버튼은 위젯 런처로 대체 (HTML 구조 변경 없음) */
button[data-ju-chat-open].fixed {
  display: none !important;
}

/* 챗봇 런처: 전화 버튼 위 */
.ju-chat-widget__launcher {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 1050;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 9999px;
  background: var(--ju-chat-widget-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px -8px rgba(5, 150, 105, 0.55);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ju-chat-widget__launcher:hover {
  background: var(--ju-chat-widget-accent-dark);
  transform: scale(1.06);
}

.ju-chat-widget__launcher:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.35);
}

.ju-chat-widget__launcher svg {
  width: 1.5rem;
  height: 1.5rem;
}

@media (min-width: 768px) {
  .ju-chat-widget__launcher {
    bottom: 6.5rem;
    right: 2.5rem;
  }
}

.ju-chat-widget__backdrop {
  position: fixed;
  inset: 0;
  z-index: 1190;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.ju-chat-widget__backdrop--open {
  opacity: 1;
  pointer-events: auto;
}

.ju-chat-widget__panel {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  left: 1rem;
  z-index: 1205;
  width: auto;
  max-width: 24rem;
  margin-left: auto;
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  border-radius: 1.25rem;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 60px -16px rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.35);
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.ju-chat-widget__panel--open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 768px) {
  .ju-chat-widget__panel {
    left: auto;
    right: 2.5rem;
    bottom: 2rem;
    width: min(100vw - 2rem, 400px);
  }
}

.ju-chat-widget__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: #fff;
}

.ju-chat-widget__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  background: var(--ju-chat-widget-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.ju-chat-widget__title {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
}

.ju-chat-widget__subtitle {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 0.1rem;
}

.ju-chat-widget__close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  border: 0;
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.ju-chat-widget__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.ju-chat-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #f8fafc;
  min-height: 240px;
}

.ju-chat-widget__bubble {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.ju-chat-widget__bubble--bot {
  align-self: flex-start;
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 0.25rem;
}

.ju-chat-widget__bubble--user {
  align-self: flex-end;
  background: var(--ju-chat-widget-accent);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.ju-chat-widget__bubble--system {
  align-self: center;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  max-width: 95%;
  text-align: center;
}

.ju-chat-widget__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.5rem;
  background: #f8fafc;
}

.ju-chat-widget__chip {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-weight: 600;
}

.ju-chat-widget__chip:hover {
  border-color: var(--ju-chat-widget-accent);
  color: var(--ju-chat-widget-accent-dark);
}

.ju-chat-widget__footer {
  padding: 0.65rem 0.75rem 0.75rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.ju-chat-widget__input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.ju-chat-widget__input {
  flex: 1;
  resize: none;
  min-height: 2.5rem;
  max-height: 6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  line-height: 1.4;
  font-family: inherit;
}

.ju-chat-widget__input:focus {
  outline: none;
  border-color: var(--ju-chat-widget-accent);
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.ju-chat-widget__send {
  flex-shrink: 0;
  background: var(--ju-chat-widget-accent);
  color: #fff;
  border: 0;
  border-radius: 0.75rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.ju-chat-widget__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ju-chat-widget__send:not(:disabled):hover {
  background: var(--ju-chat-widget-accent-dark);
}

.ju-chat-widget__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.45rem;
  font-size: 0.7rem;
  color: #64748b;
}

.ju-chat-widget__meta a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: underline;
}

.ju-chat-widget__typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.5rem 0.75rem;
  align-self: flex-start;
}

.ju-chat-widget__typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: ju-chat-widget-dot 1s infinite ease-in-out;
}

.ju-chat-widget__typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ju-chat-widget__typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ju-chat-widget-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
