/* GBrakes AI Parts Finder - Mobile-First Styles */

/* CSS Custom Properties (Design Tokens) */
:root {
  /* GBrakes Brand Colors */
  --gbrakes-primary: #f9ce08;        /* GBrakes Yellow/Gold */
  --gbrakes-primary-dark: #d4b007;   /* Darker yellow for hover */
  --gbrakes-primary-light: #fbd943;  /* Lighter yellow for accents */
  --gbrakes-secondary: #1a1a1a;      /* Dark charcoal background */
  --gbrakes-secondary-light: #2a2a2a; /* Lighter charcoal */
  
  /* CycleGear Colors */
  --cyclegear-blue: #0066CC;         /* CycleGear Blue */
  --cyclegear-blue-light: #3385D6;   /* Lighter blue */
  
  /* Neutral Colors - Light Theme */
  --white: #FFFFFF;
  --gray-50: #F9FAFB;    /* Very light gray background */
  --gray-100: #F3F4F6;   /* Light gray background */
  --gray-200: #E5E7EB;   /* Card borders */
  --gray-300: #D1D5DB;   /* Light borders */
  --gray-400: #9CA3AF;   /* Disabled text */
  --gray-500: #6B7280;   /* Secondary text */
  --gray-600: #4B5563;   /* Dark secondary text */
  --gray-700: #374151;   /* Main text */
  --gray-800: #1F2937;   /* Dark text */
  --gray-900: #111827;   /* Pure black text */
  
  /* Status Colors */
  --success: #10B981;
  --success-light: #34D399;
  --error: #EF4444;
  --error-light: #F87171;
  --warning: #F59E0B;
  --warning-light: #FBBF24;
  --info: #3B82F6;
  --info-light: #60A5FA;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;     /* 12px */
  --font-size-sm: 0.875rem;    /* 14px */
  --font-size-base: 1rem;      /* 16px */
  --font-size-lg: 1.125rem;    /* 18px */
  --font-size-xl: 1.25rem;     /* 20px */
  --font-size-2xl: 1.5rem;     /* 24px */
  --font-size-3xl: 1.875rem;   /* 30px */
  
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Spacing */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  
  /* Border Radius */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */
  --radius-2xl: 1.5rem;   /* 24px */
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
  
  /* Z-Index Stack */
  --z-header: 100;
  --z-menu: 200;
  --z-toast: 300;
  --z-loading: 400;
  
  /* Animation */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
  
  /* Layout */
  --header-height: 64px;
  --input-height: 60px;
  --max-width: 768px;
  --chat-padding: var(--space-4);
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--gray-900);
  background: linear-gradient(135deg, 
    var(--gray-50) 0%, 
    var(--gray-100) 50%, 
    var(--gray-50) 100%);
  background-attachment: fixed;
  height: 100%;
  overflow: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--gbrakes-primary) 0%, var(--gbrakes-primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-loading);
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loading-content {
  text-align: center;
  color: var(--white);
}

.gbrakes-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-8);
}

.gbrakes-logo .logo-image {
  height: 80px;
  width: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  transition: all var(--transition-normal);
  animation: logoFloat 6s ease-in-out infinite;
}

.gbrakes-logo .logo-image:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3));
}

@keyframes logoFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Legacy logo styles for fallback */
.gbrakes-logo .logo-g {
  width: 60px;
  height: 60px;
  background: var(--white);
  color: var(--gbrakes-primary);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  box-shadow: var(--shadow-lg);
}

.gbrakes-logo .logo-text {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.1em;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--white);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-4);
}

.loading-text {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-medium);
  opacity: 0.9;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--gray-50);
  position: relative;
  overflow: auto;
}


/* Header */
.chat-header {
  background: #1a1a1a;
  color: var(--white);
  height: 80px;
  flex-shrink: 0;
  position: relative;
  z-index: var(--z-header);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}


.header-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: var(--space-4);
  gap: var(--space-2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-content: flex-start;
}

.gbrakes-logo-small {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.gbrakes-logo-small .logo-image-small {
  height: 48px;
  width: auto;
  max-width: 180px;
  filter: none;
  transition: all var(--transition-fast);
  object-fit: contain;
}

.gbrakes-logo-small .logo-image-small:hover {
  transform: scale(1.05);
}

/* Legacy small logo styles for fallback */
.gbrakes-logo-small .logo-g {
  width: 32px;
  height: 32px;
  background: var(--white);
  color: var(--gbrakes-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

.gbrakes-logo-small .logo-text {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.05em;
}

.header-info {
  text-align: center;
}

.app-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  margin: 0;
  color: var(--white);
}

.connection-status {
  display: none;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--success);
  animation: pulse 2s infinite;
}

.status-indicator.connecting {
  background: var(--warning);
}

.status-indicator.disconnected {
  background: var(--error);
  animation: none;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.header-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.header-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

/* Content Card */
.content-card {
  background: var(--white);
  margin: var(--space-4);
  border-radius: var(--radius-2xl);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  height: auto;
}

/* Welcome Message */
.welcome-message {
  padding: var(--space-8) var(--space-6);
  text-align: center;
  background: var(--white);
  position: relative;
  flex-shrink: 0;
}


.welcome-content {
  max-width: 500px;
  margin: 0 auto;
}

.welcome-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-4);
  overflow: hidden;
  border: 3px solid var(--gray-200);
}

.welcome-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--cyclegear-blue) 0%, var(--cyclegear-blue-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--gbrakes-primary) 0%, var(--gbrakes-primary-dark) 100%);
  color: var(--white);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  box-shadow: 0 4px 12px rgba(249, 206, 8, 0.3);
}

.welcome-message h2 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--gray-900);
  margin-bottom: var(--space-3);
}

.welcome-message p {
  font-size: var(--font-size-base);
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

.quick-start-examples {
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
}

.examples-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--gray-700);
  margin-bottom: var(--space-4);
  text-align: center;
}

.example-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  color: var(--cyclegear-blue);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-normal);
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.example-btn::before {
  content: '💬';
  font-size: var(--font-size-lg);
  flex-shrink: 0;
}

.example-btn:hover {
  background: var(--gray-50);
  border-color: var(--cyclegear-blue);
  color: var(--cyclegear-blue);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
}


.example-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 4px rgba(0, 102, 204, 0.15);
}

.example-btn:focus {
  outline: 2px solid var(--cyclegear-blue);
  outline-offset: 2px;
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 300px;
  height: auto;
  background: var(--white);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  min-height: 200px;
  height: auto;
}

/* Welcome message visibility is controlled by JavaScript */

/* Message Styles */
.message {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  max-width: 100%;
  min-height: 44px;
  height: auto;
  opacity: 1 !important;
  animation: none;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  border: none;
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
  border: none;
}

.message.user .message-avatar {
  background: var(--cyclegear-blue);
  color: var(--white);
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--gbrakes-primary) 0%, var(--gbrakes-primary-dark) 100%);
  color: var(--white);
}

.message-content {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  height: auto;
}

.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  max-width: 85%;
  min-height: 20px;
  height: auto;
  word-wrap: break-word;
  position: relative;
}

.message.user .message-bubble {
  background: var(--cyclegear-blue);
  color: var(--white);
  margin-left: auto;
  border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-bubble {
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--white) 100%);
  color: var(--gray-900);
  border-bottom-left-radius: var(--radius-sm);
  border: 1px solid rgba(249, 206, 8, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.message-text {
  font-size: var(--font-size-base);
  line-height: 1.5;
  margin: 0;
  min-height: 1.5em;
  height: auto;
}

.message-text p {
  margin-bottom: var(--space-2);
}

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

.message-text strong {
  font-weight: var(--font-weight-semibold);
}

.message-text em {
  font-style: italic;
}


/* Product Cards */
.product-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: var(--space-3) 0;
  box-shadow: var(--shadow-sm);
}

.product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.product-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--gbrakes-primary);
  margin: 0;
}

.product-series {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  font-weight: var(--font-weight-bold);
}

/* Series-Specific Styling - Simple Bold Text */
.product-series-69,
.product-series-70, 
.product-series-72,
.product-series-75,
.product-series-76 {
  background: none; /* No background */
  color: inherit; /* Use parent text color */
  border-radius: 0; /* No rounded corners */
  padding: 0; /* No padding */
  margin: 0; /* No margins */
  display: inline; /* Stay inline with text */
  font-size: inherit; /* Same size as surrounding text */
  font-weight: 700; /* Bold text */
  white-space: nowrap; /* Prevent breaking */
}

/* Brand Name Styling - Bold for emphasis */
.brand-name {
  font-weight: 700 !important; /* Bold text with priority */
  color: inherit; /* Use parent text color */
  display: inline;
  -webkit-font-smoothing: antialiased; /* iOS font rendering */
}

/* Part Number Styling - Bold for clarity */
.part-number {
  font-weight: 700 !important; /* Bold text with priority */
  color: inherit; /* Use parent text color */
  display: inline;
  white-space: nowrap; /* Keep part numbers together */
  -webkit-font-smoothing: antialiased; /* iOS font rendering */
}

/* Product Compound Styling */
.product-compound {
  font-weight: 600; /* Semi-bold for compounds */
  color: inherit;
  display: inline;
}

/* Product Application Type Styling */
.product-application-type {
  font-weight: 700 !important; /* Bold for Front/Rear/Both */
  color: inherit;
  display: inline;
  -webkit-font-smoothing: antialiased;
}

/* Ensure strong tags are always bold */
strong {
  font-weight: 700 !important;
  -webkit-text-stroke: 0.4px currentColor; /* Enhance bold on iOS */
}

/* iOS-specific optimizations for viewport stability */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific styles */
  .app-container {
    -webkit-transform: translateZ(0); /* Hardware acceleration */
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling */
  }
  
  .chat-messages {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
  }
  
  /* Prevent viewport jumping on iOS keyboard */
  body.keyboard-visible {
    /* Removed position: fixed as it causes viewport issues */
    width: 100%;
    overflow: hidden; /* Prevent scrolling when keyboard is visible */
  }
  
  /* Ensure proper reset when keyboard hides */
  body.keyboard-transitioning {
    transition: none !important;
  }
  
  /* Force bold rendering on iOS */
  .brand-name,
  .part-number,
  .product-application-type,
  .product-series-69,
  .product-series-70,
  .product-series-72,
  .product-series-75,
  .product-series-76,
  strong {
    -webkit-text-stroke: 0.5px currentColor !important; /* Stronger bold on iOS */
    letter-spacing: 0.01em; /* Slight spacing for clarity */
    font-weight: 900 !important; /* Maximum weight */
    text-rendering: optimizeLegibility;
  }
}

/* Enhanced Product Information Styling */
.product-application {
  /* Disabled - using strategic bold instead of distracting badge */
  background: none !important;
  color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  font-weight: var(--font-weight-bold) !important;
  display: inline !important;
  border: none !important;
}

.product-cross-ref {
  background: var(--gray-200);
  color: var(--gray-700);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--gray-300);
  display: inline-block;
  margin: 0 var(--space-1);
}

.product-technology {
  /* Disabled - too distracting. Using simple bold text instead */
  background: none !important;
  color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  font-weight: var(--font-weight-semibold) !important;
  display: inline !important;
  border: none !important;
}

.product-part-number {
  background: var(--gray-800);
  color: var(--white);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  font-family: 'Courier New', monospace;
  display: inline-block;
  margin: 0 var(--space-1);
}

.product-ymm {
  /* Disabled - too distracting. Using strategic bold instead */
  background: none !important;
  color: inherit !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  font-weight: var(--font-weight-semibold) !important;
  display: inline !important;
  border: none !important;
}

.product-details {
  margin-bottom: var(--space-3);
}

.product-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: var(--font-size-sm);
}

.product-detail:last-child {
  border-bottom: none;
}

.product-detail-label {
  color: var(--gray-600);
  font-weight: var(--font-weight-medium);
}

.product-detail-value {
  color: var(--gray-900);
  font-weight: var(--font-weight-medium);
  text-align: right;
}

.cross-references {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--gray-200);
}

.cross-references h4 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.cross-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.cross-reference {
  background: var(--gray-100);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  color: var(--gray-700);
}

.brake-pads {
  font-weight: 700;
  -webkit-text-stroke: 0.3px currentColor;
}

/* AI Markup Styles - Simple and clean */
.ai-bold {
  font-weight: 700;
  -webkit-text-stroke: 0.3px currentColor;
}

.ai-emphasis {
  font-style: normal;
  font-weight: 600;
  color: var(--gray-800);
}

.ai-product {
  /* No styling - rely on bold tags only */
}

.ai-application {
  /* No styling - rely on bold tags only */
}

/* Typing Indicator */
.typing-indicator {
  padding: 0 var(--space-4) var(--space-4);
  opacity: 1;
  animation: fadeInUp 0.3s ease-out;
}

.typing-content {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.typing-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gbrakes-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--gbrakes-primary) 0%, var(--gbrakes-primary-dark) 100%);
  color: var(--white);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
}

.typing-bubble {
  background: var(--gray-100);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: var(--radius-sm);
  position: relative;
}

.typing-dots {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--gray-500);
  border-radius: var(--radius-full);
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0ms; }
.typing-dots span:nth-child(2) { animation-delay: 200ms; }
.typing-dots span:nth-child(3) { animation-delay: 400ms; }

.typing-text {
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  margin: 0;
}

/* Typing indicator when shown as a chat message */
.typing-bubble-content {
  background: var(--gray-100);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: var(--radius-sm);
}

@keyframes typing {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Chat Input */
.chat-input-container {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  padding: var(--space-4);
  flex-shrink: 0;
  position: relative;
}


.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  background: var(--gray-50);
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  border: 1px solid var(--gray-200);
  transition: all var(--transition-normal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}


.chat-input-wrapper:focus-within {
  border-color: var(--cyclegear-blue);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1),
              0 1px 3px rgba(0, 0, 0, 0.1);
}


.message-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--gray-900);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 0;
}

.message-input::placeholder {
  color: var(--gray-500);
}

.send-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--cyclegear-blue);
  color: var(--white);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 3px rgba(0, 102, 204, 0.3);
}


.send-btn:hover:not(:disabled) {
  background: var(--cyclegear-blue-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
}


.send-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.95);
  box-shadow: 0 1px 3px rgba(0, 102, 204, 0.3);
}

.send-btn:disabled {
  background: var(--gray-300);
  color: var(--gray-500);
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}


.input-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  text-align: center;
}

.character-count {
  color: var(--gray-500);
}

.character-count.warning {
  color: var(--warning);
}

.character-count.error {
  color: var(--error);
}

.powered-by {
  color: var(--gray-500);
}

.powered-by strong {
  color: var(--gray-700);
}

.powered-by a {
  color: var(--gray-800);
  text-decoration: none;
  transition: var(--transition-fast);
}

.powered-by a:hover {
  color: var(--gray-900);
  text-decoration: underline;
}

.powered-by a strong {
  color: inherit;
}

/* Footer Notice */
.footer-notice {
  background: var(--gray-100);
  padding: var(--space-4);
  margin: 0 var(--space-4) var(--space-4);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--warning);
}

.footer-notice p {
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  line-height: 1.4;
  margin: 0;
}

.footer-notice strong {
  color: var(--gray-800);
  font-weight: var(--font-weight-semibold);
}

/* Menu Overlay */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-menu);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.menu-overlay.show {
  opacity: 1;
  visibility: visible;
}

.menu-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--white);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.menu-overlay.show .menu-content {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.menu-header h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--gray-900);
}

.close-menu-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--gray-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.close-menu-btn:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.menu-items {
  flex: 1;
  padding: var(--space-4);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  border: none;
  background: transparent;
  color: var(--gray-700);
  font-size: var(--font-size-base);
  text-align: left;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-2);
}

.menu-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.menu-item:active {
  background: var(--gray-200);
  transform: scale(0.98);
}

.menu-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.app-info {
  text-align: center;
  color: var(--gray-600);
  font-size: var(--font-size-sm);
}

.app-info p {
  margin-bottom: var(--space-1);
}

.version {
  color: var(--gray-500);
  font-size: var(--font-size-xs);
}

.copyright {
  color: var(--gray-500);
  font-size: var(--font-size-xs);
}

/* Toast Notifications */
.toast {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  left: var(--space-4);
  right: var(--space-4);
  max-width: calc(var(--max-width) - var(--space-8));
  margin: 0 auto;
  z-index: var(--z-toast);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  transition: all var(--transition-normal);
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

.toast-error .toast-content {
  background: var(--error);
  color: var(--white);
}

.toast-success .toast-content {
  background: var(--success);
  color: var(--white);
}

.toast-icon {
  flex-shrink: 0;
}


/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .loading-spinner {
    animation: none;
  }
  
  .typing-dots span {
    animation: none;
  }
  
  .status-indicator {
    animation: none;
  }
  
  /* Ensure messages are visible when animations are disabled */
  .message,
  .typing-indicator {
    opacity: 1 !important;
  }
}

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

*:focus {
  outline: 2px solid var(--gbrakes-primary);
  outline-offset: 2px;
}

button:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--cyclegear-blue);
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --gray-100: #F0F0F0;
    --gray-200: #E0E0E0;
    --gray-300: #C0C0C0;
    --gray-500: #808080;
    --gray-600: #606060;
    --gray-700: #404040;
    --gray-800: #202020;
    --gray-900: #000000;
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  :root {
    --chat-padding: var(--space-3);
  }
  
  /* Fix mobile viewport and scrolling */
  .app-container {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  
  .content-card {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: var(--space-2);
    min-height: 0; /* Important for flex children */
  }
  
  .chat-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Important for flex children */
  }
  
  .chat-messages {
    padding: var(--space-3);
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
  }
  
  /* Fix example buttons visibility */
  .quick-start-examples {
    max-width: 100%;
    padding: 0 var(--space-2);
    overflow-y: auto;
    max-height: 200px; /* Limit height and allow scrolling if needed */
    -webkit-overflow-scrolling: touch;
  }
  
  .example-btn {
    font-size: var(--font-size-sm);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    white-space: normal; /* Allow text wrapping */
    text-align: left;
    min-height: auto;
  }
  
  .header-content {
    padding: var(--space-3);
    gap: var(--space-2);
  }
  
  .app-title {
    font-size: var(--font-size-base);
  }
  
  .chat-input-container {
    padding: var(--space-3);
    flex-shrink: 0; /* Prevent input from shrinking */
  }
  
  .welcome-message {
    padding: var(--space-6) var(--space-3);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .welcome-message h2 {
    font-size: var(--font-size-xl);
  }
  
  .message-bubble {
    max-width: 90%;
  }
  
  /* Mobile-specific product highlighting adjustments */
  .product-part-number,
  .product-series,
  .product-application,
  .product-cross-ref,
  .product-technology,
  .product-ymm {
    margin: var(--space-1) var(--space-1);
    font-size: var(--font-size-xs);
    padding: var(--space-1) var(--space-2);
    display: inline-block;
    word-break: break-all; /* Handle long part numbers on small screens */
  }
  
  .product-part-number {
    font-size: var(--font-size-xs); /* Smaller on mobile */
  }
  
  .menu-content {
    width: 100%;
  }
  
  .toast {
    left: var(--space-3);
    right: var(--space-3);
  }
  
  
  /* Additional mobile fixes for footer and input */
  .footer-notice {
    display: none; /* Hide footer notice on mobile to save space */
  }
  
  .typing-indicator {
    position: relative;
    flex-shrink: 0;
  }
  
  /* Ensure input area stays at bottom */
  .chat-input-container {
    position: sticky;
    bottom: 0;
    background: var(--white);
    z-index: 10;
  }
}

@media (max-width: 375px) {
  .gbrakes-logo-small .logo-text {
    display: none;
  }
  
  .header-info {
    margin-left: var(--space-2);
  }
  
  .logo-image-small {
    max-width: 120px;
    height: auto;
  }
  
  .header-content {
    padding: var(--space-2);
  }
  
  .header-btn {
    width: 36px;
    height: 36px;
  }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .welcome-message {
    padding: var(--space-4) var(--space-3);
  }
  
  .welcome-message h2 {
    font-size: var(--font-size-lg);
  }
  
  .welcome-icon {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-4);
  }
}

/* Tablet Portrait */
@media (min-width: 481px) and (max-width: 768px) {
  .message-bubble {
    max-width: 75%;
  }
  
  .menu-content {
    width: 320px;
  }
}

/* Desktop */
@media (min-width: 769px) {
  .app-container {
    border-radius: var(--radius-xl);
    margin: var(--space-4) auto;
    height: calc(100vh - var(--space-8));
    overflow: hidden;
  }
  
  .chat-header {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  
  .message-bubble {
    max-width: 70%;
  }
  
  .menu-content {
    width: 320px;
  }
  
  /* Hover effects for desktop */
  .example-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  
}

/* Print Styles */
@media print {
  .chat-header,
  .chat-input-container,
  .menu-overlay,
  .toast,
  .loading-screen {
    display: none !important;
  }
  
  .app-container {
    height: auto;
    max-width: none;
    margin: 0;
    box-shadow: none;
  }
  
  .chat-messages {
    padding: 0;
  }
  
  .message {
    page-break-inside: avoid;
  }
}

/* Dark Mode Support (for future implementation) */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here in the future */
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    margin: 50px auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

.modal-body {
    padding: 24px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* About Modal Specific Styles */
.about-content {
    color: #333;
    line-height: 1.6;
}

.about-logo {
    max-width: 200px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
}

.about-content h4 {
    color: #1a1a1a;
    font-size: 18px;
    margin: 24px 0 16px;
    font-weight: 600;
}

.about-content h5 {
    color: #b8960a;
    font-size: 16px;
    margin: 20px 0 12px;
    font-weight: 600;
}

.about-content p {
    margin-bottom: 16px;
    color: #555;
}

.about-content ul {
    margin: 12px 0 16px;
    padding-left: 24px;
}

.about-content li {
    margin-bottom: 8px;
    color: #555;
}

.about-content strong {
    color: #333;
    font-weight: 600;
}

.about-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Help Modal Specific Styles */
.help-content {
    color: #333;
    line-height: 1.6;
}

.help-content h4 {
    color: #1a1a1a;
    font-size: 18px;
    margin: 0 0 20px;
    font-weight: 600;
}

.help-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.help-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.help-section h5 {
    color: #b8960a;
    font-size: 16px;
    margin: 0 0 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-content ol,
.help-content ul {
    margin: 12px 0;
    padding-left: 24px;
}

.help-content li {
    margin-bottom: 8px;
    color: #555;
}

.help-content strong {
    color: #333;
    font-weight: 600;
}

.help-content p {
    margin: 12px 0;
    color: #555;
}

/* Modal Responsive */
@media (max-width: 640px) {
    .modal-content {
        margin: 20px auto;
        max-width: calc(100% - 32px);
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .about-logo {
        max-width: 150px;
    }
}
/* iOS-Specific Keyboard Viewport Fixes for iPhone 16 Chrome */
@supports (-webkit-touch-callout: none) {
  /* iOS-only styles */
  
  /* Keyboard transitioning state */
  body.keyboard-transitioning {
    transition: height 0.3s ease-out !important;
  }
  
  /* Keyboard visible state */
  body.keyboard-visible {
    /* Force stable viewport during keyboard show */
    height: 100vh !important;
    overflow: hidden !important;
  }
  
  /* Enhanced viewport stability for iOS Chrome */
  body.keyboard-transitioning #app {
    transform: translateZ(0) !important; /* Force hardware acceleration */
    will-change: transform !important;
  }
  
  /* Chat messages container iOS fixes */
  body.keyboard-visible #chat-messages {
    /* Ensure messages stay scrollable during keyboard transitions */
    transform: translateZ(0) !important;
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
  }
  
  /* Input area iOS fixes */
  body.keyboard-visible .input-area {
    /* Prevent input area from moving during keyboard animation */
    position: fixed !important;
    bottom: 0 !important;
    transform: translateZ(0) !important;
  }
  
  /* Force layout stability during transitions */
  body.keyboard-transitioning * {
    /* Prevent subpixel rendering issues */
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
  }
}

/* Additional iOS Chrome-specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 2) {
  /* High-DPI iOS devices (includes iPhone 16) */
  
  .message-bubble {
    /* Enhance text rendering during keyboard transitions */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  
  /* Ensure consistent scrolling behavior */
  #chat-messages {
    scroll-snap-type: none !important; /* Disable scroll snapping that can interfere */
    overscroll-behavior: contain !important; /* Prevent over-scroll bounce during keyboard hide */
  }
}
