/* ===== AI Chat Widget — Premium ===== */
.chat-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  font-family: var(--font-kr);
}

.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, #22d3ee 0%, #0891b2 55%, #06b6d4 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow:
    0 4px 28px rgba(34, 211, 238, 0.4),
    0 0 0 1px rgba(103, 232, 249, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s, box-shadow 0.25s;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow:
    0 8px 40px rgba(34, 211, 238, 0.5),
    0 0 0 1px rgba(196, 181, 253, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.chat-toggle svg {
  width: 26px;
  height: 26px;
}

.chat-panel {
  position: absolute;
  bottom: calc(56px + 14px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 580px;
  max-height: 85vh;
  background: linear-gradient(165deg, rgba(14, 18, 28, 0.97) 0%, rgba(8, 10, 18, 0.98) 100%);
  border: 1px solid rgba(103, 232, 249, 0.14);
  border-radius: 18px;
  box-shadow:
    0 24px 72px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 48px rgba(34, 211, 238, 0.06);
  backdrop-filter: blur(24px) saturate(1.15);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.96);
  transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
  overflow: hidden;
}

.chat-widget.open .chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: rgba(14,16,22,0.6);
}

.chat-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-header-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.chat-header-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

.chat-header-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  padding: 0.2rem 0.45rem;
  background: rgba(34,197,94,0.1);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 100px;
  letter-spacing: 0.04em;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-msg {
  max-width: 85%;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  color: #fff;
  border-radius: 12px 12px 2px 12px;
}

.chat-msg.bot {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px 12px 12px 2px;
}

.chat-msg.typing {
  align-self: flex-start;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.chat-msg.error {
  align-self: flex-start;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-radius: 12px 12px 12px 2px;
}

.chat-input-wrap {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(14,16,22,0.4);
}

.chat-input-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-kr);
  font-size: 0.88rem;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-send:hover {
  box-shadow: 0 2px 12px rgba(6,182,212,0.35);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-send svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 480px) {
  .chat-widget {
    bottom: 1rem;
    right: 1rem;
  }
  .chat-panel {
    width: calc(100vw - 2rem);
    height: 85vh;
  }
}
