/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #404040;
  --bg-overlay: rgba(0, 0, 0, 0.7);
  
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --text-muted: #808080;
  --text-inverse: #000000;
  
  --msg-user-bg: #1877f2;
  --msg-user-text: #ffffff;
  --msg-bot-bg: #404040;
  --msg-bot-text: #ffffff;
  
  --border-color: #404040;
  --primary-light: #1a237e;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Dark theme specific adjustments */
[data-theme="dark"] .theme-toggle .light-icon {
  opacity: 0;
}

[data-theme="dark"] .theme-toggle .dark-icon {
  opacity: 1;
}

[data-theme="dark"] .welcome-screen {
  background: linear-gradient(135deg, var(--primary-light), var(--bg-secondary));
}

[data-theme="dark"] .spinner {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: var(--primary-color);
}

/* Business-specific color schemes */
.business-theme-blue {
  --primary-color: #1877f2;
  --primary-hover: #166fe5;
  --primary-light: #e3f2fd;
}

.business-theme-green {
  --primary-color: #00c853;
  --primary-hover: #00b248;
  --primary-light: #e8f5e8;
}

.business-theme-purple {
  --primary-color: #6c5ce7;
  --primary-hover: #5f3dc4;
  --primary-light: #f1f0ff;
}

.business-theme-orange {
  --primary-color: #ff9800;
  --primary-hover: #f57c00;
  --primary-light: #fff3e0;
}

.business-theme-red {
  --primary-color: #f44336;
  --primary-hover: #d32f2f;
  --primary-light: #ffebee;
}

.business-theme-teal {
  --primary-color: #009688;
  --primary-hover: #00796b;
  --primary-light: #e0f2f1;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.8);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.8);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.8);
  }
  
  [data-theme="dark"] {
    --border-color: #ffffff;
    --text-muted: #cccccc;
  }
  
  .message-bubble {
    border: 2px solid var(--border-color);
  }
}

/* Color scheme preference detection */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #404040;
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #808080;
    --text-inverse: #000000;
    
    --msg-bot-bg: #404040;
    --msg-bot-text: #ffffff;
    
    --border-color: #404040;
    --primary-light: #1a237e;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
  
  .spinner {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary-color);
  }
}

/* Override system dark mode when light theme is explicitly selected */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --text-inverse: #ffffff;
  
  --msg-bot-bg: #e9ecef;
  --msg-bot-text: #212529;
  
  --border-color: #dee2e6;
  --primary-light: #e3f2fd;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .theme-toggle .light-icon {
  opacity: 1;
}

[data-theme="light"] .theme-toggle .dark-icon {
  opacity: 0;
}

[data-theme="light"] .spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary-color);
}
