@import url('theme.css');
@import url('logo.css');
@import url('bot-icon.css');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--surface);
  overflow: hidden;
}

.widget-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 0.5rem;
  max-width: 92%;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.message.bot .message-avatar {
  width: 30px;
  height: 30px;
}

.message.user .message-avatar {
  background: var(--primary-light);
  color: #fff;
  font-weight: 600;
}

.message-bubble {
  padding: 0.6875rem 0.875rem;
  border-radius: 14px;
  font-size: 0.8125rem;
  line-height: 1.6;
  word-break: break-word;
}

.message.bot .message-bubble {
  background: var(--bot-bg);
  border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message-bubble a {
  color: var(--primary);
  text-decoration: underline;
}

.message.user .message-bubble a {
  color: #a9c2de;
}

.sources-section {
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(29, 95, 168, 0.15);
}

.sources-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  line-height: 1.45;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--primary) !important;
  text-decoration: none !important;
  font-size: 0.75rem;
  font-weight: 500;
}

.source-link:hover {
  text-decoration: underline !important;
}

.typing {
  display: flex;
  gap: 4px;
  padding: 0.75rem 0.875rem;
  background: var(--bot-bg);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.typing span {
  width: 7px;
  height: 7px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 1rem 0.5rem;
}

.quick-reply-btn {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--primary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.quick-reply-btn:hover {
  background: var(--bot-bg);
  border-color: var(--primary-light);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

#message-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.6875rem 1rem;
  font-family: inherit;
  font-size: 0.8125rem;
  outline: none;
}

#message-input:focus {
  border-color: var(--primary-light);
}

#send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.widget-powered {
  text-align: center;
  font-size: 0.625rem;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem 0.5rem;
  background: #fafafa;
}
