/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --secondary: #059669;
  --secondary-dark: #047857;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-icon {
  background: var(--primary);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav a:hover { color: var(--primary); }

/* ===== Hero ===== */
.hero {
  padding: 80px 0 60px;
  text-align: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
}

.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.hero .accent { color: var(--primary); }

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero-search {
  display: flex;
  max-width: 580px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.hero-search:focus-within {
  border-color: var(--primary-light);
}

.hero-search input {
  flex: 1;
  padding: 16px 20px;
  border: none;
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  background: transparent;
}

.hero-search button {
  padding: 16px 28px;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s;
  white-space: nowrap;
}

.hero-search button:hover { background: var(--primary-dark); }

/* ===== Stats Bar ===== */
.stats-bar {
  padding: 32px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.stats-grid {
  display: flex;
  justify-content: center;
  gap: 60px;
}

.stat { text-align: center; }

.stat-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Featured Products ===== */
.featured { padding: 60px 0; }

.featured h2,
.how-it-works h2 {
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 36px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, transform 0.2s;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.product-card h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.product-card .product-category {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.product-card .product-action {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 600;
}

/* ===== How It Works ===== */
.how-it-works {
  padding: 60px 0;
  background: var(--surface);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.step {
  text-align: center;
  padding: 24px;
}

.step-number {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.step h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.step p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
  padding: 40px 0;
  background: #0f172a;
  color: #94a3b8;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.footer-brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
}

.footer-brand .logo-icon {
  background: var(--primary-light);
}

.footer-brand p {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 4px;
  font-weight: 400;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.footer-links a:hover { color: white; }

.footer-bottom {
  border-top: 1px solid #1e293b;
  padding-top: 24px;
}

.disclaimer {
  font-size: 0.8rem;
  line-height: 1.7;
  color: #64748b;
}

.disclaimer strong { color: #94a3b8; }

.footer-bottom > p:last-child {
  margin-top: 12px;
  font-size: 0.8rem;
}

.footer-compact { padding: 16px 0; }

.footer-compact .disclaimer { text-align: center; }

/* ===== Chat Page Layout ===== */
.chat-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Chat Messages ===== */
.message {
  max-width: 90%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.65;
  animation: fadeIn 0.2s ease;
  word-wrap: break-word;
}

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

.system-message {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--primary-dark);
  align-self: center;
  text-align: center;
  max-width: 100%;
  font-size: 0.9rem;
}

.user-message {
  background: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.assistant-message {
  background: var(--surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* ===== Thinking Section ===== */
.thinking-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.thinking-header::before {
  content: '\25b6';
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.thinking-section.expanded .thinking-header::before,
.thinking-section.streaming .thinking-header::before {
  transform: rotate(90deg);
}

.thinking-content {
  display: none;
  padding: 0 14px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

.thinking-section.expanded .thinking-content,
.thinking-section.streaming .thinking-content {
  display: block;
}

/* ===== Answer Content (Markdown) ===== */
.answer-content h1,
.answer-content h2,
.answer-content h3 {
  margin: 16px 0 8px;
  font-weight: 700;
}

.answer-content h2 { font-size: 1.15rem; }
.answer-content h3 { font-size: 1.05rem; }
.answer-content p { margin: 8px 0; }

.answer-content ul,
.answer-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.answer-content li { margin: 4px 0; }
.answer-content strong { font-weight: 600; }

.answer-content code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.answer-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 0.9rem;
}

.answer-content th,
.answer-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.answer-content th {
  background: #f8fafc;
  font-weight: 600;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typing 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== CTA Card ===== */
.cta-card {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #86efac;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin: 8px 0;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.cta-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.cta-button {
  display: inline-block;
  padding: 12px 28px;
  background: var(--secondary);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.cta-button:hover { background: var(--secondary-dark); }

.cta-disclaimer {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 8px;
}

/* ===== Chat Input Area ===== */
.chat-input-area {
  padding: 12px 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-form {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  transition: border-color 0.2s;
}

.chat-form:focus-within {
  border-color: var(--primary-light);
}

.chat-form input {
  flex: 1;
  padding: 12px 14px;
  border: none;
  outline: none;
  font-size: 0.95rem;
  font-family: var(--font);
  background: transparent;
}

.chat-form button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s;
}

.chat-form button:hover { background: var(--primary-dark); }

.chat-form button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* ===== Rate Limit & PII Warning ===== */
.rate-limit-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 0;
}

.pii-warning {
  background: #fef3cd;
  border: 1px solid #fbbf24;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: #92400e;
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .hero-search { flex-direction: column; }
  .hero-search button { padding: 14px; }
  .stats-grid { gap: 24px; }
  .steps-grid { grid-template-columns: 1fr; gap: 16px; }
  .footer-content { flex-direction: column; gap: 24px; }
  .message { max-width: 95%; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.65rem; }
  .hero { padding: 48px 0 40px; }
  .stats-grid { flex-direction: column; gap: 16px; }
}
