@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700&display=swap');

:root {
  --bg: #f9fbf8;
  --card: #ffffff;
  --text: #0c1a12;
  --muted: #6a7c6f;
  --accent-start: #0d9c53;
  --accent-mid: #58c56c;
  --accent-end: #b7f171;
  --border: rgba(12, 26, 18, 0.08);
  --shadow: 0 20px 40px rgba(11, 44, 24, 0.12);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(13, 156, 83, 0.12), transparent 55%), var(--bg);
  color: var(--text);
  font-family: 'Sarabun', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 1.1rem;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: none;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ghost-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.ghost-button {
  background: transparent;
  border: 1px solid rgba(13, 156, 83, 0.3);
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  color: var(--accent-start);
  font-size: 0.9rem;
  transition: background 0.2s ease;
}

.ghost-button:hover {
  background: rgba(13, 156, 83, 0.08);
}

button.primary {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-mid));
  color: #f5fffa;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 45px rgba(13, 156, 83, 0.2);
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero-text h1 {
  font-size: clamp(2.5rem, 6vw, 3.8rem);
  margin: 0 0 16px;
  line-height: 1.1;
}

.hero-text .accent {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-mid), var(--accent-end));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-text .lead {
  color: var(--muted);
  max-width: 600px;
  margin: 0;
}

.cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.cta-buttons button {
  background: rgba(13, 156, 83, 0.08);
  border: 1px solid rgba(13, 156, 83, 0.2);
  border-radius: 18px;
  padding: 10px 18px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.cta-buttons button:hover {
  background: rgba(13, 156, 83, 0.18);
  transform: translateY(-1px);
}

.chat-panel {
  margin-top: auto;
  border: 1px solid rgba(12, 26, 18, 0.08);
  border-radius: 32px;
  padding: 32px;
  background: var(--card);
  box-shadow: 0 35px 70px rgba(11, 44, 24, 0.14);
}

.chat-output {
  min-height: 420px;
  max-height: 640px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.65;
  background: transparent;
  border-radius: 30px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.chat-output.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px;
  border-radius: 22px;
  box-shadow: 0 12px 30px rgba(12, 26, 18, 0.08);
  max-width: 90%;
  animation: floatIn 0.5s ease;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-mid));
  color: #f6fff0;
}

.message.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid rgba(13, 156, 83, 0.15);
}

.chat-output pre {
  background: #eff7ef;
  padding: 12px 16px;
  border-radius: 16px;
  overflow-x: auto;
}
.chat-output .answer {
  font-size: 1.2rem;
  margin-bottom: 16px;
}
.trace {
  margin-top: 18px;
}
.trace h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.table-wrapper {
  border: 1px solid rgba(13, 156, 83, 0.2);
  border-radius: 12px;
  overflow-x: auto;
}
.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table-wrapper th,
.table-wrapper td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(13, 156, 83, 0.12);
  text-align: left;
}
.table-wrapper tr:last-child td {
  border-bottom: none;
}
.muted {
  color: var(--muted);
}
.error {
  color: #ff7f9f;
}

.chat-form {
  margin-top: 18px;
}

label.chat-field {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: #f0f7f1;
  border: 1px solid rgba(13, 156, 83, 0.15);
  border-radius: 999px;
  padding: 10px 16px 10px 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.chat-field input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.send-btn {
  border: none;
  background: linear-gradient(135deg, var(--accent-mid), var(--accent-end));
  color: #09210f;
  font-weight: 600;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 15px 25px rgba(13, 156, 83, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 35px rgba(13, 156, 83, 0.22);
}

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.thinking-indicator img {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  animation: pulse 1.2s ease-in-out infinite;
}

.cta-buttons button,
button.primary {
  animation: floatIn 0.6s ease forwards;
}

.site-footer {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--accent-start);
  text-decoration: none;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 18, 12, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-card {
  background: #ffffff;
  padding: 32px;
  border-radius: 28px;
  width: min(420px, 90%);
  text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  margin: 0 auto 12px;
  object-fit: cover;
}

.login-card h2 {
  margin: 0;
  color: var(--text);
}

.login-lead {
  margin: 0;
  color: var(--muted);
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

#login-form input {
  border: 1px solid rgba(13, 156, 83, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 1rem;
}

#login-form button {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-mid));
  color: #f5fffa;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 20px 35px rgba(13, 156, 83, 0.2);
}

.login-error {
  min-height: 1.2em;
  color: #c62828;
  font-size: 0.9rem;
  margin: 0;
}

@keyframes pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(0.9);
    opacity: 0.8;
  }
}

@keyframes floatIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    gap: 16px;
  }
  .cta-buttons {
    flex-direction: column;
  }
  .chat-panel {
    padding: 16px;
  }
  .input-wrapper {
    flex-direction: column;
    border-radius: 18px;
  }
  .input-wrapper input {
    width: 100%;
  }
}
.about-card {
  margin-top: 48px;
  padding: 28px 32px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(13, 156, 83, 0.08), rgba(183, 241, 113, 0.1));
  border: 1px solid rgba(13, 156, 83, 0.18);
  box-shadow: var(--shadow);
}

.about-card h2 {
  margin: 0 0 12px;
  font-size: 1.4rem;
  color: var(--text);
}

.about-card p {
  margin: 0 0 12px;
  color: var(--text);
  line-height: 1.6;
}
