/* ============================================
   PACE Pattern Styles
   Conversational storefront with Cormorant guide
   ============================================ */

/* CSS Variables */
:root {
  /* Existing variables from main styles */
  --color-primary: #667eea;
  --color-primary-dark: #5568d3;
  --color-primary-light: #f3f4ff;
  --color-secondary: #764ba2;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-warning: #f59e0b;

  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-bg: #f8fafc;
  --color-bg-secondary: #f1f5f9;
  --color-bg-hover: #e2e8f0;
  --color-border: #e2e8f0;

  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 1rem;
  --radius-sm: 0.5rem;
  --radius-lg: 1.5rem;

  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ============================================
   Base Styles
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

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

/* Use Space Grotesk for headings and important UI */
h1, h2, h3, h4, h5, h6,
.brand-name,
.sidebar-section h3,
.legal-header h1,
.product-name,
.cormorant-avatar + .chat-header-text h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ============================================
   Icon Sidebar (ForageCast Style)
   ============================================ */

.icon-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 64px;
  background: #0a0a0a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 100;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  margin: 0 auto;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

.icon-btn.active {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-primary);
  border: 1px solid rgba(102, 126, 234, 0.3);
}

.icon-btn.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-primary);
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.8);
}

.icon-logo {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.5);
  color: var(--color-primary);
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.icon-logo:hover {
  background: rgba(102, 126, 234, 0.2);
  box-shadow: 0 0 25px rgba(102, 126, 234, 0.4);
}

/* ============================================
   Layout Grid
   ============================================ */

.app-container {
  margin-left: 64px;
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--color-bg);
}

.header {
  grid-column: 1 / -1;
  grid-row: 1;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}

/* Subtle pattern overlay */
.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

/* Header Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.brand-name {
  font-size: 1.875rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  letter-spacing: -0.02em;
  transition: all 0.2s;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.brand-name:hover {
  transform: translateY(-1px);
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.brand-separator {
  font-size: 1.5rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.5);
}

.brand-tagline {
  font-size: 0.9375rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.02em;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
  overflow-y: auto;
  border-right: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  background: white;
}

.chat-container {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem;
  overflow: hidden;
}

/* ============================================
   Sidebar Styles
   ============================================ */

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-section h3 i {
  font-size: 1rem;
}

.sidebar-product {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.sidebar-product:hover {
  background: var(--color-bg-hover);
}

.sidebar-product.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 500;
}

.product-name {
  font-size: 0.875rem;
  font-weight: 500;
  flex: 1;
}

.product-price {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.sidebar-product.active .product-price {
  color: var(--color-primary);
}

.sidebar-filters {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.sidebar-filters h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.sidebar-filters label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color 0.2s;
}

.sidebar-filters label:hover {
  color: var(--color-primary);
}

.sidebar-filters input[type="radio"] {
  cursor: pointer;
}

/* ============================================
   Chat Styles
   ============================================ */

.chat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.cormorant-avatar {
  font-size: 3rem;
  line-height: 1;
}

.chat-header-text h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.chat-header-text .subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0.25rem 0 0 0;
}

.expand-btn {
  margin-left: auto;
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--color-text-muted);
}

.expand-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-primary);
  transform: scale(1.05);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2rem 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 0;
}

.message-user,
.message-assistant {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: messageSlideIn 0.3s ease-out;
}

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

.message-user {
  align-items: flex-end;
}

.message-user .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem 1.25rem;
  border-radius: 1rem 1rem 0.25rem 1rem;
  max-width: 80%;
  line-height: 1.6;
}

.message-assistant .message-content {
  background: var(--color-bg-secondary);
  padding: 1rem 1.25rem;
  border-radius: 1rem 1rem 1rem 0.25rem;
  max-width: 90%;
  line-height: 1.6;
  color: var(--color-text);
}

.message-content p {
  margin: 0 0 0.5rem 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
}

.message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: 'Monaco', 'Courier New', monospace;
}

.message-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.5rem 0;
}

.message-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.used-products {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.used-products .label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.product-chip {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.product-chip:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.timestamp {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.message-user .timestamp {
  text-align: right;
}

/* ============================================
   Quick Prompts (Empty State)
   ============================================ */

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.prompt-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.prompt-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.prompt-card i {
  font-size: 2rem;
  color: var(--color-primary);
  flex-shrink: 0;
}

.prompt-card-text h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
}

.prompt-card-text p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ============================================
   Chat Input
   ============================================ */

.chat-input-container {
  padding: 1.5rem 0 0 0;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-input {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  transition: border-color 0.2s;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input textarea::placeholder {
  color: var(--color-text-muted);
}

.chat-input button {
  align-self: flex-end;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-input button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-input button i {
  font-size: 1.25rem;
}

/* Context Indicator */
.context-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.context-indicator i {
  font-size: 0.875rem;
}

/* ============================================
   Typing Indicator
   ============================================ */

.typing-indicator {
  display: flex;
  gap: 0.375rem;
  padding: 1rem 1.25rem;
  background: var(--color-bg-secondary);
  border-radius: 1rem 1rem 1rem 0.25rem;
  width: fit-content;
}

.typing-indicator span {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--color-text-muted);
  border-radius: 50%;
  animation: typing 1.4s 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.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* ============================================
   Message Actions
   ============================================ */

.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.action-btn.github {
  border-color: #24292e;
  color: #24292e;
}

.action-btn.github:hover {
  background: #24292e;
  color: white;
}

.action-btn.stripe {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

.action-btn.stripe:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 64px;
    left: -240px;
    bottom: 0;
    width: 240px;
    background: white;
    z-index: 100;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
  }

  .sidebar.open ~ .sidebar-overlay {
    display: block;
  }

  .chat-container {
    padding: 1rem;
  }

  .chat-header {
    padding-bottom: 1rem;
  }

  .cormorant-avatar {
    font-size: 2rem;
  }

  .chat-header-text h2 {
    font-size: 1.25rem;
  }

  .messages {
    padding: 1rem 0;
  }

  .message-user .message-content,
  .message-assistant .message-content {
    max-width: 100%;
  }

  .quick-prompts {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .prompt-card {
    padding: 1rem;
  }

  .prompt-card i {
    font-size: 1.5rem;
  }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

.messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================
   Legal View
   ============================================ */

.legal-view {
  margin-left: 64px;
  height: 100vh;
  overflow: hidden;
  background: var(--color-bg);
}

.legal-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.legal-header {
  margin-bottom: 2rem;
}

.legal-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  color: var(--color-text);
}

.legal-header .subtitle {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  margin: 0;
}

.legal-content {
  flex: 1;
  display: flex;
  gap: 2rem;
  overflow: hidden;
}

.legal-nav {
  flex-shrink: 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legal-tab {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.legal-tab:hover {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.legal-tab.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.legal-tab i {
  font-size: 1.125rem;
}

.legal-document {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  padding: 2.5rem;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.prose {
  max-width: none;
  line-height: 1.7;
}

.prose h2 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 1.5rem 0;
  color: var(--color-text);
}

.prose h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 1rem 0;
  color: var(--color-text);
}

.prose p {
  margin: 0 0 1rem 0;
  color: var(--color-text);
}

.prose ul, .prose ol {
  margin: 0 0 1rem 0;
  padding-left: 1.5rem;
  color: var(--color-text);
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose strong {
  font-weight: 600;
  color: var(--color-text);
}

.prose a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}

.prose a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

.inline-link {
  background: none;
  border: none;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
}

.inline-link:hover {
  color: var(--color-primary-dark);
}
