/**
 * AI Business Consultant Chat Widget
 * Zero Qubit 2025 Design System - Claude.ai/ChatGPT Inspired
 * Apple-inspired light-first design with sophisticated minimalism
 */

/* Zero Qubit 2025 Design System Variables - Apple-Inspired Light Theme */
:root {
  /* PRIMARY BRAND - Quantum Cyan optimized for light backgrounds */
  --abc-primary: var(--primary, #007acc);
  --abc-primary-light: var(--primary-light, #0099ff);
  --abc-primary-dark: var(--primary-dark, #005c99);
  --abc-primary-hover: var(--primary-hover, #0088e6);
  --abc-primary-subtle: var(--primary-subtle, rgba(0, 122, 204, 0.06));
  --abc-primary-light-bg: var(--primary-light-bg, rgba(0, 122, 204, 0.04));
  --abc-primary-medium-bg: var(--primary-medium-bg, rgba(0, 122, 204, 0.08));
  --abc-primary-strong-bg: var(--primary-strong-bg, rgba(0, 122, 204, 0.12));
  
  /* BACKGROUND SYSTEM - Apple-inspired whites and grays */
  --abc-bg-primary: var(--bg-primary, #ffffff);
  --abc-bg-secondary: var(--bg-secondary, #f5f5f7);
  --abc-bg-tertiary: var(--bg-tertiary, #f2f2f7);
  --abc-bg-elevated: var(--bg-elevated, #fafafa);
  --abc-bg-section: var(--bg-section, #fbfbfd);
  --abc-bg-accent: var(--bg-accent, #f8f9ff);
  
  /* NEUTRAL SCALE - Teenage Engineering precision */
  --abc-neutral-50: var(--neutral-50, #fafafa);
  --abc-neutral-100: var(--neutral-100, #f4f4f5);
  --abc-neutral-200: var(--neutral-200, #e4e4e7);
  --abc-neutral-300: var(--neutral-300, #d4d4d8);
  --abc-neutral-400: var(--neutral-400, #a1a1aa);
  --abc-neutral-500: var(--neutral-500, #71717a);
  --abc-neutral-600: var(--neutral-600, #52525b);
  --abc-neutral-800: var(--neutral-800, #27272a);
  --abc-neutral-900: var(--neutral-900, #18181b);
  
  /* TEXT COLORS - High contrast for accessibility */
  --abc-text-primary: var(--text-primary, #1d1d1f);
  --abc-text-secondary: var(--text-secondary, #86868b);
  --abc-text-tertiary: var(--text-tertiary, #a1a1a6);
  --abc-text-inverse: var(--text-inverse, #ffffff);
  --abc-text-accent: var(--text-accent, var(--abc-primary));
  
  /* BORDER SYSTEM */
  --abc-border-light: var(--border-light, #e5e5e7);
  --abc-border-medium: var(--border-medium, #d2d2d7);
  --abc-border-focus: var(--border-focus, rgba(0, 122, 204, 0.5));
  
  /* GLASS EFFECTS - Apple-inspired refined glassmorphism */
  --abc-glass-bg: var(--glass-bg, rgba(255, 255, 255, 0.85));
  --abc-glass-border: var(--glass-border, rgba(0, 122, 204, 0.08));
  --abc-glass-border-hover: var(--glass-border-hover, rgba(0, 122, 204, 0.16));
  --abc-glass-shadow-light: var(--glass-shadow-light, rgba(0, 0, 0, 0.04));
  --abc-glass-shadow-medium: var(--glass-shadow-medium, rgba(0, 0, 0, 0.08));
  --abc-glass-shadow-strong: var(--glass-shadow-strong, rgba(0, 0, 0, 0.12));
  
  /* INTERACTIVE STATES */
  --abc-hover-bg: var(--hover-bg, rgba(0, 122, 204, 0.04));
  --abc-active-bg: var(--active-bg, rgba(0, 122, 204, 0.08));
  --abc-focus-bg: var(--focus-bg, rgba(0, 122, 204, 0.06));
  
  /* Chat-specific design tokens */
  --abc-chat-max-width: 800px;
  --abc-chat-border-radius: 16px;
  --abc-message-border-radius: 12px;
  --abc-input-border-radius: 24px;
  --abc-button-border-radius: 12px;
  --abc-shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --abc-shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.06);
  --abc-shadow-large: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.05);
  
  /* Widget-specific dimensions and effects */
  --abc-chat-bubble-size: 60px;
  --abc-chat-window-width: 380px;
  --abc-chat-shadow: var(--abc-shadow-large);
  --abc-chat-shadow-hover: 0 12px 20px rgba(0, 0, 0, 0.12), 0 6px 8px rgba(0, 0, 0, 0.08);
  --abc-chat-animation-duration: var(--abc-duration-normal);
  --abc-chat-animation-easing: var(--abc-ease-out);
  
  /* Typography - Apple system fonts following Zero Qubit 2025 guidelines */
  --abc-font-primary: var(--font-primary, -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif);
  --abc-font-body: var(--font-body, -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif);
  --abc-font-family: var(--abc-font-body);
  --abc-font-family-mono: var(--font-mono, 'SF Mono', Monaco, 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'Roboto Mono', Consolas, monospace);
  --abc-font-weight-regular: 400;
  --abc-font-weight-medium: 500;
  --abc-font-weight-semibold: 600;
  --abc-font-weight-bold: 700;
  
  /* Animation system */
  --abc-duration-fast: 0.15s;
  --abc-duration-normal: 0.25s;
  --abc-duration-slow: 0.4s;
  --abc-ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --abc-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --abc-ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Chat widget container */
.abc-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: var(--abc-font-family);
}

/* Chat bubble */
.abc-chat-bubble {
  width: var(--abc-chat-bubble-size);
  height: var(--abc-chat-bubble-size);
  background: var(--abc-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--abc-chat-shadow);
  transition: all var(--abc-chat-animation-duration) var(--abc-chat-animation-easing);
}

.abc-chat-bubble:hover {
  transform: scale(1.05);
  box-shadow: var(--abc-chat-shadow-hover);
}

.abc-chat-bubble.active {
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
}

/* Chat window - Apple-inspired glassmorphism */
.abc-chat-window {
  position: absolute;
  bottom: calc(var(--abc-chat-bubble-size) + 10px);
  right: 0;
  width: var(--abc-chat-window-width);
  height: var(--abc-chat-window-height);
  background: var(--abc-glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--abc-border-light);
  border-radius: var(--abc-chat-border-radius);
  box-shadow: var(--abc-shadow-large);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all var(--abc-duration-normal) var(--abc-ease-out);
  overflow: hidden;
}

.abc-chat-window.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.abc-chat-window::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--abc-glass-border), transparent);
  opacity: 0.6;
}

/* Chat header - Refined Apple-style */
.abc-chat-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--abc-border-light);
  background: var(--abc-bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  border-radius: var(--abc-chat-border-radius) var(--abc-chat-border-radius) 0 0;
}

.abc-chat-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.abc-chat-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--abc-primary), var(--abc-primary-light));
  color: var(--abc-text-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--abc-font-primary);
  font-weight: var(--abc-font-weight-semibold);
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 122, 204, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.abc-chat-title {
  font-family: var(--abc-font-primary);
  font-weight: var(--abc-font-weight-semibold);
  color: var(--abc-text-primary);
  font-size: 16px;
  letter-spacing: -0.01em;
}

.abc-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--abc-text-secondary);
  font-family: var(--abc-font-body);
  font-size: 13px;
  font-weight: 400;
}

.abc-status-indicator {
  width: 8px;
  height: 8px;
  background: var(--abc-success, #34c759);
  border-radius: 50%;
  animation: pulse 2s infinite ease-in-out;
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.4);
}

@keyframes pulse {
  0% { 
    opacity: 1; 
    transform: scale(1);
  }
  50% { 
    opacity: 0.6; 
    transform: scale(0.9);
  }
  100% { 
    opacity: 1; 
    transform: scale(1);
  }
}

.abc-chat-close {
  background: var(--abc-hover-bg);
  border: none;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: var(--abc-text-secondary);
  transition: all 0.2s var(--abc-ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.abc-chat-close:hover {
  color: var(--abc-text-primary);
  background: var(--abc-active-bg);
  transform: scale(1.05);
}

.abc-chat-close:active {
  transform: scale(0.95);
}

/* Progress indicator - Apple-inspired */
.abc-conversation-progress {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--abc-neutral-100);
  overflow: hidden;
}

.abc-progress-bar {
  position: relative;
  height: 100%;
  background: var(--abc-neutral-100);
  overflow: hidden;
}

.abc-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--abc-primary), var(--abc-primary-light));
  transition: width 0.4s var(--abc-ease-out);
  border-radius: 1px;
}

.abc-progress-text {
  position: absolute;
  right: 20px;
  bottom: 10px;
  font-size: 11px;
  font-family: var(--abc-font-body);
  font-weight: 500;
  color: var(--abc-text-secondary);
  letter-spacing: 0.01em;
}

/* Stage indicator - Enhanced */
.abc-stage-indicator {
  font-size: 11px;
  font-family: var(--abc-font-body);
  font-weight: 500;
  color: var(--abc-primary);
  margin-top: 3px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Qualification badge - Apple-inspired */
.abc-qualification-badge {
  position: absolute;
  top: 10px;
  right: 52px;
  background: linear-gradient(135deg, var(--abc-primary), var(--abc-primary-light));
  color: var(--abc-text-inverse);
  padding: 6px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-family: var(--abc-font-body);
  font-weight: var(--abc-font-weight-medium);
  letter-spacing: 0.01em;
  box-shadow: 0 2px 6px rgba(0, 122, 204, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Chat messages area - ChatGPT/Claude.ai inspired */
.abc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--abc-bg-primary);
  scroll-behavior: smooth;
}

/* Message styles - Modern chat bubbles */
.abc-message {
  max-width: 75%;
  word-wrap: break-word;
  animation: messageSlide 0.3s var(--abc-ease-out);
  position: relative;
  margin-bottom: 4px;
}

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

.abc-message.user {
  align-self: flex-end;
  background: var(--abc-primary);
  color: var(--abc-text-inverse);
  padding: 12px 16px;
  border-radius: 20px 20px 6px 20px;
  font-family: var(--abc-font-body);
  font-size: 15px;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0, 122, 204, 0.15);
}

.abc-message.assistant {
  align-self: flex-start;
  background: var(--abc-bg-elevated);
  color: var(--abc-text-primary);
  padding: 12px 16px;
  border-radius: 20px 20px 20px 6px;
  font-family: var(--abc-font-body);
  font-size: 15px;
  line-height: 1.4;
  border: 1px solid var(--abc-border-light);
  box-shadow: 0 1px 3px var(--abc-glass-shadow-light);
}

.abc-message.error {
  background: var(--abc-error-bg, rgba(220, 53, 69, 0.08));
  color: var(--abc-error, #dc3545);
  border: 1px solid rgba(220, 53, 69, 0.2);
}

/* Message timestamps */
.abc-message-time {
  font-size: 11px;
  color: var(--abc-text-tertiary);
  margin-top: 4px;
  text-align: right;
  font-family: var(--abc-font-body);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.abc-message:hover .abc-message-time {
  opacity: 1;
}

/* Message Content Formatting */
.abc-message-bubble p {
  margin: 0 0 8px 0;
  line-height: 1.4;
}

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

.abc-message-bubble strong {
  font-weight: 600;
  color: inherit;
}

.abc-message-bubble em {
  font-style: italic;
  color: inherit;
}

.abc-message-bubble .abc-message-list {
  margin: 8px 0;
  padding-left: 20px;
  list-style-type: none;
}

.abc-message-bubble .abc-message-list li {
  margin: 4px 0;
  position: relative;
  line-height: 1.4;
}

.abc-message-bubble .abc-message-list li::before {
  content: "•";
  color: var(--abc-primary);
  font-weight: bold;
  position: absolute;
  left: -16px;
  top: 0;
}

.abc-message-bubble .abc-message-list li strong {
  font-weight: 600;
}

/* Ensure proper spacing for mixed content */
.abc-message-bubble > *:first-child {
  margin-top: 0;
}

.abc-message-bubble > *:last-child {
  margin-bottom: 0;
}

/* Typing indicator - ChatGPT style */
.abc-typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--abc-bg-elevated);
  border: 1px solid var(--abc-border-light);
  border-radius: 20px 20px 20px 6px;
  align-self: flex-start;
  max-width: 80px;
  box-shadow: 0 1px 3px var(--abc-glass-shadow-light);
}

.abc-typing-dots {
  display: flex;
  gap: 4px;
}

.abc-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--abc-text-secondary);
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out;
}

.abc-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.abc-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

.abc-typing-avatar {
  width: 20px;
  height: 20px;
  background: var(--abc-primary);
  color: var(--abc-text-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--abc-font-weight-semibold);
  flex-shrink: 0;
}

/* Suggested actions removed to prevent confusion */

/* Chat input area - ChatGPT/Claude.ai inspired */
.abc-chat-input-area {
  padding: 16px 20px 20px 20px;
  border-top: 1px solid var(--abc-border-light);
  background: var(--abc-bg-primary);
}

.abc-chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--abc-bg-elevated);
  border: 1.5px solid var(--abc-border-light);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.abc-chat-input-container:focus-within {
  border-color: var(--abc-primary);
  box-shadow: 0 0 0 3px var(--abc-border-focus), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.abc-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 12px 0;
  font-size: 15px;
  font-family: var(--abc-font-family);
  color: var(--abc-text-primary);
  resize: none;
  min-height: 20px;
  max-height: 120px;
  line-height: 1.4;
  overflow-y: auto;
}

.abc-chat-input::placeholder {
  color: var(--abc-text-tertiary);
  font-weight: 400;
}

.abc-chat-send {
  background: var(--abc-primary);
  color: var(--abc-text-inverse);
  border: none;
  border-radius: 20px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 2px;
  flex-shrink: 0;
}

.abc-chat-send:hover:not(:disabled) {
  background: var(--abc-primary-hover);
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 122, 204, 0.3);
}

.abc-chat-send:active:not(:disabled) {
  transform: scale(0.95);
}

.abc-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--abc-neutral-300);
}

.abc-chat-send:disabled:hover {
  transform: none;
  box-shadow: none;
}

.abc-send-text {
  display: none;
}

/* Lead capture form */
.abc-lead-capture-form {
  padding: 16px;
  background: var(--abc-bg-section);
  border-radius: 12px;
  margin: 8px 16px;
}

.abc-lead-capture-form h4 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: var(--abc-font-weight-semibold);
  color: var(--abc-text-primary);
}

.abc-lead-capture-form input,
.abc-lead-capture-form select {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--abc-border-light);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  font-family: var(--abc-font-family);
}

.abc-lead-capture-form button[type="submit"] {
  width: 100%;
  padding: 10px 16px;
  background: var(--abc-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: var(--abc-font-weight-medium);
  cursor: pointer;
  transition: background 0.2s;
}

.abc-lead-capture-form button[type="submit"]:hover {
  background: var(--abc-primary-hover);
}

/* Consultation prompt */
.abc-consultation-prompt {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
}

.abc-consultation-button {
  flex: 1;
  background: var(--abc-primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.abc-consultation-button:hover {
  background: var(--abc-primary-hover);
}

.abc-consultation-later {
  background: transparent;
  color: var(--abc-primary);
  border: 1px solid var(--abc-primary);
}

.abc-consultation-later:hover {
  background: var(--abc-bg-elevated);
}

/* Error messages */
.abc-error-message {
  background: #fee;
  color: #c00;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
}

/* Rate limit message */
.abc-rate-limit-message {
  background: var(--abc-bg-section);
  color: var(--abc-text-secondary);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  margin: 8px 16px;
}

/* Responsive Design - Mobile-First Approach */

/* Tablet adjustments */
@media (max-width: 768px) {
  .abc-chat-widget {
    bottom: 16px;
    right: 16px;
  }
  
  .abc-chat-window {
    width: 90vw;
    max-width: 400px;
    height: 70vh;
    max-height: 600px;
  }
  
  .abc-chat-header {
    padding: 16px 18px;
  }
  
  .abc-chat-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  
  .abc-chat-messages {
    padding: 16px;
    gap: 14px;
  }
  
  .abc-message {
    max-width: 80%;
    font-size: 14px;
    padding: 10px 14px;
  }
  
  .abc-chat-input-area {
    padding: 14px 16px 16px 16px;
  }
  
  .abc-chat-input-container {
    padding: 3px 3px 3px 14px;
  }
  
  .abc-chat-send {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }
}

/* Mobile phone adjustments */
@media (max-width: 480px) {
  .abc-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
    position: fixed;
  }
  
  .abc-chat-window {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    bottom: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
  }
  
  .abc-chat-header {
    padding: 16px;
    border-radius: 0;
    background: var(--abc-bg-primary);
    border-bottom: 1px solid var(--abc-border-medium);
  }
  
  .abc-chat-bubble {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    font-size: 14px;
  }
  
  .abc-chat-messages {
    padding: 16px;
    padding-bottom: 8px;
  }
  
  .abc-message {
    max-width: 85%;
    font-size: 16px; /* Better readability on mobile */
  }
  
  .abc-chat-input-area {
    padding: 12px 16px 16px 16px;
    background: var(--abc-bg-elevated);
    border-top: 1px solid var(--abc-border-medium);
    border-radius: 0;
  }
  
  .abc-chat-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 14px 0;
  }
  
  .abc-chat-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* Small mobile phones */
@media (max-width: 360px) {
  .abc-chat-header {
    padding: 12px 16px;
  }
  
  .abc-chat-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  
  .abc-chat-title {
    font-size: 15px;
  }
  
  .abc-chat-status {
    font-size: 12px;
  }
  
  .abc-chat-messages {
    padding: 12px;
  }
  
  .abc-message {
    padding: 10px 12px;
    font-size: 15px;
  }
}

/* ============================================
   ACCESSIBILITY & REDUCED MOTION
   ============================================ */

/* Focus styles */
.abc-chat-widget *:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--abc-border-focus);
}

.abc-chat-widget button:focus,
.abc-chat-widget input:focus,
.abc-chat-widget textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--abc-border-focus);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .abc-chat-widget {
    --abc-border-light: #000000;
    --abc-border-medium: #000000;
    --abc-text-secondary: #000000;
    --abc-text-tertiary: #333333;
    --abc-bg-elevated: #ffffff;
    --abc-glass-bg: #ffffff;
  }
  
  .abc-chat-window {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-width: 2px;
  }
  
  .abc-message.assistant {
    border-width: 2px;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .abc-chat-widget *,
  .abc-chat-widget *::before,
  .abc-chat-widget *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .abc-typing-dot {
    animation: none !important;
  }
  
  .abc-status-indicator {
    animation: none !important;
  }
}

/* Dark mode support - Force light mode as per Zero Qubit 2025 guidelines */
@media (prefers-color-scheme: dark) {
  .abc-chat-widget {
    color-scheme: light; /* Force light mode for brand consistency */
    /* All colors remain light theme as per design guidelines */
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .abc-chat-send {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  
  .abc-chat-close {
    width: 36px;
    height: 36px;
    padding: 10px;
  }
  
  .abc-message:hover .abc-message-time {
    opacity: 0; /* Disable hover effects on touch devices */
  }
  
  .abc-chat-bubble {
    width: 60px;
    height: 60px;
  }
}

/* Print styles */
@media print {
  .abc-chat-widget {
    display: none !important;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.abc-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;
}

.abc-no-scroll {
  overflow: hidden;
}

/* Loading state */
.abc-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Fade in animation for new elements */
.abc-fade-in {
  animation: fade-in var(--abc-duration-normal) var(--abc-ease-out);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================
   HIGHLIGHT ANIMATIONS
   ============================================ */

.abc-chat-bubble.pulse-highlight {
  animation: abc-pulse-highlight 2s ease-in-out 2;
}

@keyframes abc-pulse-highlight {
  0%, 100% { 
    transform: scale(1);
    box-shadow: var(--abc-shadow-large);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: var(--abc-shadow-large), 0 0 25px rgba(0, 122, 204, 0.3);
  }
}

/* Attention-grabbing pulse for important messages */
.abc-message.highlight {
  animation: message-highlight 1s ease-out;
}

@keyframes message-highlight {
  0% {
    background-color: var(--abc-primary-subtle);
  }
  100% {
    background-color: transparent;
  }
}

/* Shake animation for errors */
.abc-error-shake {
  animation: error-shake 0.5s ease-in-out;
}

@keyframes error-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ============================================
   FINAL OPTIMIZATIONS & PERFORMANCE
   ============================================ */

/* GPU acceleration for smooth animations */
.abc-chat-bubble,
.abc-chat-window,
.abc-message,
.abc-typing-indicator {
  transform: translateZ(0);
  will-change: transform, opacity;
}

/* Optimize repaints */
.abc-chat-messages {
  contain: layout style paint;
}

/* Smooth scrolling */
.abc-chat-messages {
  scroll-behavior: smooth;
}

@supports (scroll-behavior: smooth) {
  .abc-chat-messages {
    scroll-behavior: smooth;
  }
}

/* Modern browser optimizations */
@supports (backdrop-filter: blur(10px)) {
  .abc-chat-window {
    backdrop-filter: blur(10px);
    background: var(--abc-glass-bg);
  }
}

/* ============================================
   INLINE WIDGET OVERRIDES
   ============================================ */

/* Inline widget container - override floating positioning */
.abc-chat-widget.inline {
    position: static !important;
    bottom: auto !important;
    right: auto !important;
    width: 100% !important;
    max-width: 800px !important;
    margin: 0 auto 20px auto !important;
    padding: 0 20px !important;
    z-index: auto !important;
    box-sizing: border-box !important;
}

/* Inline chat window - always visible and properly sized */
.abc-chat-widget.inline .abc-chat-window {
    position: static !important;
    bottom: auto !important;
    right: auto !important;
    width: 100% !important;
    height: 550px !important;
    max-height: 550px !important;
    min-height: 550px !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: all !important;
    border-radius: var(--abc-chat-border-radius) !important;
    box-shadow: var(--abc-shadow-medium) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Hide chat bubble for inline widgets */
.abc-chat-widget.inline .abc-chat-bubble {
    display: none !important;
}

/* Ensure inline messages area is properly sized */
.abc-chat-widget.inline .abc-chat-messages {
    flex: 1 !important;
    height: auto !important;
    min-height: 380px !important;
    max-height: calc(550px - 140px) !important;
    overflow-y: auto !important;
    padding: 20px !important;
}

/* Inline chat header styling */
.abc-chat-widget.inline .abc-chat-header {
    background: var(--abc-bg-elevated);
    border-bottom: 1px solid var(--abc-border-light);
    border-radius: var(--abc-chat-border-radius) var(--abc-chat-border-radius) 0 0;
}

/* Inline input area */
.abc-chat-widget.inline .abc-chat-input-area {
    border-top: 1px solid var(--abc-border-light);
    border-radius: 0 0 var(--abc-chat-border-radius) var(--abc-chat-border-radius);
    background: var(--abc-bg-primary);
    padding: 16px 20px 20px 20px !important;
    flex-shrink: 0 !important;
    min-height: 70px !important;
}

/* Mobile responsiveness for inline widgets */
@media (max-width: 768px) {
    .abc-chat-widget.inline {
        max-width: 100% !important;
        margin: 0 auto 20px auto !important;
        padding: 0 16px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-window {
        height: 480px !important;
        min-height: 480px !important;
        border-radius: 12px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-messages {
        min-height: 320px !important;
        max-height: calc(480px - 140px) !important;
        padding: 16px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-header {
        border-radius: 12px 12px 0 0 !important;
        padding: 14px 16px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-input-area {
        border-radius: 0 0 12px 12px !important;
        padding: 14px 16px 16px 16px !important;
        min-height: 65px !important;
    }
}

@media (max-width: 480px) {
    .abc-chat-widget.inline {
        padding: 0 8px !important;
        margin: 0 auto 15px auto !important;
    }
    
    .abc-chat-widget.inline .abc-chat-window {
        height: 450px !important;
        min-height: 450px !important;
        border-radius: 8px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-messages {
        min-height: 290px !important;
        max-height: calc(450px - 140px) !important;
        padding: 12px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-header {
        border-radius: 8px 8px 0 0 !important;
        padding: 12px 16px !important;
    }
    
    .abc-chat-widget.inline .abc-chat-input-area {
        border-radius: 0 0 8px 8px !important;
        padding: 12px 14px 14px 14px !important;
        min-height: 60px !important;
    }
}

/* End of CSS - Zero Qubit 2025 Design System */