/* ============================================
   Martimart Brand Site – Native App Design System
   Based on Apple HIG 2024 & Internal Design Tokens
   ============================================ */

:root {
  /* Colors - Core Palette */
  --color-primary: #3C3C43; /* Marti Gray */
  --color-primary-dark: #5A5A5E;
  --color-accent: #5AC8FA; /* Teal */
  --color-accent-dark: #64D2FF;
  
  /* Backgrounds */
  --bg-system: #FFFFFF;
  --bg-system-grouped: #F2F2F7;
  --bg-card: #FFFFFF;
  
  /* Text */
  --text-primary: #000000;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary: rgba(60, 60, 67, 0.3);
  
  /* Bubbles */
  --bubble-bot-bg: #F2F2F7;
  --bubble-bot-text: #000000;
  --bubble-user-bg: #3C3C43;
  --bubble-user-text: #FFFFFF;
  
  /* Shadows (Apple-level) */
  --shadow-bot: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  --shadow-user: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-header: 0 0 0 1px rgba(0, 0, 0, 0.05);
  
  /* Dimensions */
  --radius-bubble: 18px;
  --radius-card: 16px;
  --radius-button: 12px;
  --header-height: 60px;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-system: #000000;
    --bg-system-grouped: #000000;
    --bg-card: #1C1C1E;
    
    --text-primary: #FFFFFF;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --text-tertiary: rgba(235, 235, 245, 0.3);
    
    --bubble-bot-bg: #1C1C1E; /* Secondary System Background */
    --bubble-bot-text: #FFFFFF;
    --bubble-user-bg: #5A5A5E; /* Marti Gray Dark */
    
    --shadow-bot: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-user: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-header: 0 0 0 1px rgba(255, 255, 255, 0.1);
  }
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-system);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ============================================
   Layout & Container
   ============================================ */
.app-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-system);
  position: relative;
  /* Removed max-width and box-shadow for full-width design */
}

/* ============================================
   Header (Glassmorphism)
   ============================================ */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  transition: background-color 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  .chat-header {
    background-color: rgba(28, 28, 30, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
}

.header-brand {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.header-btn:hover {
  opacity: 1;
}

/* ============================================
   Chat Stream
   ============================================ */
.chat-stream {
  flex: 1;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 8px; /* Tighter gap for consecutive messages */
  max-width: 1200px; /* Readable max-width for content on very large screens */
  width: 100%;
  margin: 0 auto;
}

.timestamp {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   Message Bubbles
   ============================================ */
.msg {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: var(--radius-bubble);
  font-size: 16px; /* SF Pro Base */
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
  animation: msgAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Limit bubble width on desktop for readability */
@media (min-width: 768px) {
  .msg {
    max-width: 600px;
  }
}

/* Bot Message */
.msg.bot {
  align-self: flex-start;
  background-color: var(--bubble-bot-bg);
  color: var(--bubble-bot-text);
  border-bottom-left-radius: 4px; /* Tail effect */
  box-shadow: var(--shadow-bot);
}

/* User Message */
.msg.user {
  align-self: flex-end;
  background-color: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 4px; /* Tail effect */
  box-shadow: var(--shadow-user);
}

/* Consecutive Messages */
.msg.bot + .msg.bot {
  border-top-left-radius: 4px;
  border-bottom-left-radius: var(--radius-bubble);
  margin-top: -4px; /* Stack closer */
}
.msg.bot:last-of-type {
  border-bottom-left-radius: 4px;
}

.msg.user + .msg.user {
  border-top-right-radius: 4px;
  border-bottom-right-radius: var(--radius-bubble);
  margin-top: -4px;
}
.msg.user:last-of-type {
  border-bottom-right-radius: 4px;
}

/* Rich Content in Bubbles */
.msg strong {
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.msg ul {
  padding-left: 20px;
  margin: 8px 0;
}
.msg li { margin-bottom: 4px; }

/* ============================================
   Rich Components: Product Carousel
   ============================================ */
.carousel-container {
  width: 100%;
  margin-left: 0;
  padding: 10px 0;
  overflow-x: auto;
  display: flex;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
  scroll-padding: 0 16px;
  margin-bottom: 12px;
}

.carousel-container::-webkit-scrollbar { display: none; }

.product-card {
  flex: 0 0 180px;
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
  border: 1px solid rgba(0,0,0,0.04);
}

.product-card:active { transform: scale(0.98); }

.product-image {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background-color: #FFFFFF;
  padding: 16px;
}

.product-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-brand {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 2px;
}

.product-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: auto;
}

.product-btn {
  margin-top: 10px;
  background-color: var(--bg-system-grouped);
  color: var(--color-primary);
  border: none;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* ============================================
   Rich Components: Feature Cards (Horizontal Scroll)
   ============================================ */
.feature-carousel {
  width: 100%;
  overflow-x: auto;
  display: flex;
  gap: 12px;
  padding-bottom: 8px; /* Space for scrollbar/shadow */
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
}

.feature-carousel::-webkit-scrollbar { display: none; }

.feature-card {
  flex: 0 0 200px; /* Fixed width for feature cards */
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.feature-icon {
  width: 40px;
  height: 40px;
  background-color: var(--bg-system-grouped);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.feature-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.feature-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.feature-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ============================================
   Rich Components: Quick Replies
   ============================================ */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end; /* Align right like user options */
}

.reply-pill {
  background-color: var(--bg-system-grouped);
  color: var(--color-primary);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  border: 1px solid rgba(0,0,0,0.05);
}

.reply-pill:hover {
  background-color: rgba(60, 60, 67, 0.1);
}

/* ============================================
   Hero Banner (Typewriter Effect)
   ============================================ */
.hero-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 60px 0 40px;
  min-height: 120px; /* Prevent layout shift */
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.hero-prompt {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 600px;
  margin: 0;
  min-height: 1.2em; /* Reserve space for text */
}

.cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background-color: #007AFF; /* Apple Blue */
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

.cursor.hidden {
  display: none;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.hero-cta {
  background-color: var(--color-primary);
  color: #FFFFFF;
  border: none;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hero-cta:hover {
  opacity: 0.9;
}

.hero-cta:active {
  transform: scale(0.96);
}

/* ============================================
   Input Area (Active)
   ============================================ */
.input-area {
  position: sticky;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 16px 24px 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 1200px; /* Match max-width of chat stream */
  margin: 0 auto;
}

@media (prefers-color-scheme: dark) {
  .input-area {
    background-color: rgba(28, 28, 30, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.input-field {
  flex: 1;
  height: 44px;
  background-color: rgba(118, 118, 128, 0.12);
  border-radius: 22px;
  padding: 0 20px;
  font-size: 16px;
  color: var(--text-primary);
  border: none;
  outline: none;
  font-family: inherit;
}

.input-field::placeholder {
  color: var(--text-tertiary);
}

.input-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.input-btn:active {
  transform: scale(0.95);
}

/* ============================================
   Typing Indicator
   ============================================ */
.typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background-color: var(--bubble-bot-bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  margin-bottom: 8px;
}

.dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-tertiary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

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

/* ============================================
   Footer
   ============================================ */
.footer-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px 0;
  font-size: 11px;
  color: var(--text-tertiary);
}

.footer-links a:hover { color: var(--text-primary); }

/* ============================================
   Legal Page Specifics
   ============================================ */
.legal-content {
  padding: 32px 24px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.legal-content h1 { font-size: 28px; margin-bottom: 8px; }
.legal-content h2 { font-size: 20px; margin: 28px 0 10px; }
.legal-content p { margin-bottom: 16px; color: var(--text-secondary); font-size: 16px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  color: var(--color-accent);
  margin-bottom: 24px;
  font-weight: 500;
  font-size: 16px;
}
