@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(--bg);
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(29, 95, 168, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(237, 113, 0, 0.06) 0%, transparent 50%),
    var(--bg);
  z-index: -1;
}

.header {
  background: var(--header-gradient);
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.header h1 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.logo-text p {
  font-size: 0.8125rem;
  opacity: 0.9;
  font-weight: 500;
}

.header p {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 2px;
}

.home-link {
  color: white;
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.2s;
}

.home-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

.main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.hero-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.875rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

.hero h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.chat-container {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 280px);
  min-height: 480px;
  max-height: 680px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to right, var(--bot-bg), #fff);
}

.bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header strong {
  display: block;
  font-size: 0.9375rem;
}

.status {
  font-size: 0.75rem;
  color: #22c55e;
  font-weight: 500;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 0.625rem;
  max-width: 88%;
  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: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.message.bot .message-avatar {
  width: 32px;
  height: 32px;
}

.message.user .message-avatar {
  background: var(--primary-light);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
}

.message.bot .message-bubble {
  background: var(--bot-bg);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.message.user .message-bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message-bubble strong {
  font-weight: 600;
}

.message-bubble em {
  font-style: italic;
  opacity: 0.85;
}

.message-bubble a {
  color: var(--primary);
  text-decoration: underline;
}

.message.user .message-bubble a {
  color: #a9c2de;
}

.message-bubble ul,
.message-bubble ol {
  margin: 0.5rem 0 0 1.25rem;
}

.message-bubble li {
  margin-bottom: 0.25rem;
}

.sources-section {
  margin-top: 1rem;
  padding-top: 0.875rem;
  border-top: 1px solid rgba(29, 95, 168, 0.15);
}

.sources-title {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
  line-height: 1.5;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--primary) !important;
  text-decoration: none !important;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.125rem 0;
  transition: color 0.15s;
}

.source-link:hover {
  color: var(--primary-dark) !important;
  text-decoration: underline !important;
}

.source-icon {
  flex-shrink: 0;
  opacity: 0.75;
}

.typing {
  display: flex;
  gap: 4px;
  padding: 0.875rem 1rem;
  background: var(--bot-bg);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.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.5rem;
  padding: 0 1.25rem 0.75rem;
}

.quick-reply-btn {
  background: white;
  border: 1.5px solid var(--border);
  color: var(--primary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4375rem 0.875rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-reply-btn:hover {
  background: var(--bot-bg);
  border-color: var(--primary-light);
}

.chat-form {
  display: flex;
  gap: 0.625rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

#message-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.75rem 1.125rem;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

#message-input:focus {
  border-color: var(--primary-light);
}

#send-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

#send-btn:hover {
  transform: scale(1.05);
}

#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.admin-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.6875rem;
}

.admin-link:hover {
  color: var(--primary);
}

@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero h2 {
    font-size: 1.125rem;
  }

  .chat-container {
    height: calc(100vh - 320px);
    min-height: 420px;
  }

  .message {
    max-width: 95%;
  }
}
