/**
 * Chat Widget Styles
 * Modern, floating chat widget with smooth animations
 *
 * @package CR_AI_Chat
 */

/* ========================================
   CSS Custom Properties (Variables)
   ======================================== */
:root {
  /* Primary Colors */
  --cr-chat-primary: #667eea;
  --cr-chat-primary-dark: #5568d3;
  --cr-chat-primary-light: #818cf8;
  --cr-chat-primary-rgb: 102, 126, 234;

  /* Secondary Colors */
  --cr-chat-secondary: #764ba2;
  --cr-chat-accent: #4ade80;

  /* Background Colors */
  --cr-chat-bg-widget: #ffffff;
  --cr-chat-bg-messages: #f8fafc;
  --cr-chat-bg-header: linear-gradient(135deg, var(--cr-chat-primary) 0%, var(--cr-chat-secondary) 100%);
  --cr-chat-bg-input: #ffffff;

  /* Text Colors */
  --cr-chat-text-primary: #1e293b;
  --cr-chat-text-secondary: #64748b;
  --cr-chat-text-muted: #94a3b8;
  --cr-chat-text-inverse: #ffffff;

  /* Border Colors */
  --cr-chat-border: #e2e8f0;
  --cr-chat-border-hover: #cbd5e1;
  --cr-chat-border-focus: var(--cr-chat-primary);

  /* Message Bubble Colors */
  --cr-chat-bubble-user-bg: linear-gradient(135deg, var(--cr-chat-primary) 0%, var(--cr-chat-secondary) 100%);
  --cr-chat-bubble-user-text: #ffffff;
  --cr-chat-bubble-assistant-bg: #ffffff;
  --cr-chat-bubble-assistant-text: #1e293b;
  --cr-chat-bubble-assistant-border: #e2e8f0;

  /* Typography */
  --cr-chat-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --cr-chat-font-size-base: 14px;
  --cr-chat-font-size-title: 18px;
  --cr-chat-font-size-small: 13px;
  --cr-chat-font-size-tiny: 11px;
  --cr-chat-font-weight-normal: 400;
  --cr-chat-font-weight-medium: 500;
  --cr-chat-font-weight-semibold: 600;

  /* Spacing */
  --cr-chat-spacing-xs: 4px;
  --cr-chat-spacing-sm: 8px;
  --cr-chat-spacing-md: 12px;
  --cr-chat-spacing-lg: 16px;
  --cr-chat-spacing-xl: 20px;
  --cr-chat-spacing-2xl: 24px;

  /* Border Radius */
  --cr-chat-radius-sm: 8px;
  --cr-chat-radius-md: 12px;
  --cr-chat-radius-lg: 16px;
  --cr-chat-radius-bubble: 16px;
  --cr-chat-radius-full: 50%;

  /* Shadows */
  --cr-chat-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --cr-chat-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --cr-chat-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.15);
  --cr-chat-shadow-button: 0 4px 12px rgba(var(--cr-chat-primary-rgb), 0.4);
  --cr-chat-shadow-button-hover: 0 6px 20px rgba(var(--cr-chat-primary-rgb), 0.6);

  /* Avatar/Logo Sizes */
  --cr-chat-avatar-size: 32px;
  --cr-chat-logo-height: 40px;
  --cr-chat-button-size: 60px;

  /* Widget Dimensions */
  --cr-chat-widget-width: 400px;
  --cr-chat-widget-height: 600px;

  /* Transitions */
  --cr-chat-transition-fast: 0.2s;
  --cr-chat-transition-normal: 0.3s;
  --cr-chat-transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Chat Button (Toggle)
   ======================================== */
.cr-chat-button {
  position: fixed;
  bottom: var(--cr-chat-spacing-2xl, 24px);
  right: var(--cr-chat-spacing-2xl, 24px);
  z-index: 9998;
  width: var(--cr-chat-button-size, 60px);
  height: var(--cr-chat-button-size, 60px);
  min-width: var(--cr-chat-button-size, 60px);
  min-height: var(--cr-chat-button-size, 60px);
  padding: 0;
  border-radius: var(--cr-chat-radius-full, 50%);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border: none;
  cursor: pointer;
  box-shadow: var(--cr-chat-shadow-button, 0 4px 12px rgba(102, 126, 234, 0.4));
  transition: all var(--cr-chat-transition-normal, 0.3s) var(--cr-chat-transition-ease, cubic-bezier(0.4, 0, 0.2, 1));
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: var(--cr-chat-text-inverse, white);
  flex-shrink: 0;
  font-family: var(--cr-chat-font-family);
  opacity: 1 !important;
  visibility: visible !important;
}

.cr-chat-button:hover {
  transform: scale(1.1);
  box-shadow: var(--cr-chat-shadow-button-hover, 0 6px 20px rgba(102, 126, 234, 0.6));
}

.cr-chat-button:active {
  transform: scale(0.95);
}

.cr-chat-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  color: white;
}

/* Bottom-left positioning */
.cr-chat-button.cr-chat-button--bottom-left {
  right: auto;
  left: var(--cr-chat-spacing-2xl, 24px);
}

/* Button with custom image */
.cr-chat-button--image .cr-chat-button__image {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 50%;
}

/* Button with text label */
.cr-chat-button--text {
  width: auto;
  min-width: var(--cr-chat-button-size, 60px);
  padding: 0 20px;
  border-radius: 30px;
}

.cr-chat-button__text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Unread message badge */
.cr-chat-button__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: badgePop 0.3s ease;
}

@keyframes badgePop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ========================================
   Chat Widget Container
   ======================================== */
.cr-chat-widget {
  position: fixed;
  bottom: 96px;
  right: var(--cr-chat-spacing-2xl, 24px);
  z-index: 9999;
  width: var(--cr-chat-widget-width, 400px);
  max-width: calc(100vw - 48px);
  height: var(--cr-chat-widget-height, 600px);
  max-height: calc(100vh - 130px);
  background: var(--cr-chat-bg-widget, white);
  border-radius: var(--cr-chat-radius-lg, 16px);
  box-shadow: var(--cr-chat-shadow-lg, 0 12px 48px rgba(0, 0, 0, 0.15));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp var(--cr-chat-transition-normal, 0.3s) var(--cr-chat-transition-ease, cubic-bezier(0.4, 0, 0.2, 1));
  font-family: var(--cr-chat-font-family);
}

/* Bottom-left positioning */
.cr-chat-widget.cr-chat-widget--bottom-left {
  right: auto;
  left: var(--cr-chat-spacing-2xl, 24px);
}

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

.cr-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

/* ========================================
   Chat Header
   ======================================== */
.cr-chat-header {
  background: var(--cr-chat-bg-header, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
  color: var(--cr-chat-text-inverse, white);
  padding: var(--cr-chat-spacing-xl, 20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cr-chat-header__content {
  flex: 1;
}

.cr-chat-header__title {
  margin: 0;
  font-size: var(--cr-chat-font-size-title, 18px);
  font-weight: var(--cr-chat-font-weight-semibold, 600);
  line-height: 1.3;
}

.cr-chat-header__status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--cr-chat-spacing-xs, 4px);
  font-size: var(--cr-chat-font-size-small, 13px);
  opacity: 0.95;
}

.cr-chat-header__status-dot {
  width: var(--cr-chat-spacing-sm, 8px);
  height: var(--cr-chat-spacing-sm, 8px);
  background: var(--cr-chat-accent, #4ade80);
  border-radius: var(--cr-chat-radius-full, 50%);
  animation: pulse 2s infinite;
}

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

.cr-chat-header__actions {
  display: flex;
  gap: 8px;
}

.cr-chat-header__action {
  background: transparent;
  border: none;
  color: var(--cr-chat-text-inverse, white);
  cursor: pointer;
  padding: var(--cr-chat-spacing-sm, 8px);
  border-radius: var(--cr-chat-radius-sm, 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--cr-chat-transition-fast, 0.2s);
}

.cr-chat-header__action:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Avatar variants */
.cr-chat-header__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cr-chat-header__avatar-initials {
  font-size: 14px;
  font-weight: 600;
  color: currentColor;
}

/* Logo in header */
.cr-chat-header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: var(--cr-chat-logo-height, 40px);
}

.cr-chat-header__logo-img {
  max-height: var(--cr-chat-logo-height, 40px);
  max-width: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.cr-chat-header__action svg {
  width: 20px;
  height: 20px;
}

/* Header Confirmation Dialog */
.cr-chat-header__confirm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--cr-chat-radius-sm, 8px);
  animation: fadeIn 0.2s ease;
}

.cr-chat-header__confirm-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--cr-chat-text-inverse, white);
  white-space: nowrap;
}

.cr-chat-header__confirm-btn {
  background: transparent;
  border: none;
  color: var(--cr-chat-text-inverse, white);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--cr-chat-transition-fast, 0.2s);
}

.cr-chat-header__confirm-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.cr-chat-header__confirm-btn--yes:hover {
  background: rgba(74, 222, 128, 0.3);
}

.cr-chat-header__confirm-btn--no:hover {
  background: rgba(248, 113, 113, 0.3);
}

/* ========================================
   Chat Messages
   ======================================== */
.cr-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--cr-chat-spacing-xl, 20px);
  background: var(--cr-chat-bg-messages, #f8fafc);
  scroll-behavior: smooth;
}

/* Welcome Message */
.cr-chat-welcome {
  text-align: center;
  padding: 20px var(--cr-chat-spacing-lg, 16px);
  width: 100%;
  box-sizing: border-box;
}

/* Topics grid needs full width of welcome container */
.cr-chat-welcome .cr-chat-topics {
  text-align: left;
}

.cr-chat-welcome__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--cr-chat-spacing-md, 12px);
  background: var(--cr-chat-bg-header, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
  border-radius: var(--cr-chat-radius-full, 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cr-chat-text-inverse, white);
}

.cr-chat-welcome__icon svg {
  width: 32px;
  height: 32px;
}

.cr-chat-welcome__title {
  margin: 0 0 var(--cr-chat-spacing-xs, 4px);
  font-size: 18px;
  font-weight: var(--cr-chat-font-weight-semibold, 600);
  color: var(--cr-chat-text-primary, #1e293b);
}

.cr-chat-welcome__description {
  margin: 0 0 var(--cr-chat-spacing-md, 12px);
  font-size: var(--cr-chat-font-size-base, 14px);
  color: var(--cr-chat-text-secondary, #64748b);
  line-height: 1.4;
}

.cr-chat-welcome__suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--cr-chat-spacing-sm, 8px);
  max-width: 300px;
  margin: 0 auto;
}

.cr-chat-welcome__suggestion {
  padding: var(--cr-chat-spacing-md, 12px) var(--cr-chat-spacing-lg, 16px);
  background: var(--cr-chat-bg-widget, white);
  border: 1px solid var(--cr-chat-border, #e2e8f0);
  border-radius: var(--cr-chat-radius-md, 12px);
  cursor: pointer;
  font-size: var(--cr-chat-font-size-base, 14px);
  color: var(--cr-chat-text-primary, #1e293b);
  font-weight: var(--cr-chat-font-weight-medium, 500);
  transition: all var(--cr-chat-transition-fast, 0.2s);
  text-align: left;
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.cr-chat-welcome__suggestion:hover {
  background: #f1f5f9;
  border-color: var(--cr-chat-border-hover, #cbd5e1);
  transform: translateY(-1px);
  box-shadow: var(--cr-chat-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

/* Message */
.cr-chat-message {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  animation: fadeIn 0.3s;
}

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

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

.cr-chat-message__avatar {
  width: var(--cr-chat-avatar-size, 32px);
  height: var(--cr-chat-avatar-size, 32px);
  border-radius: var(--cr-chat-radius-full, 50%);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--cr-chat-font-size-base, 14px);
  font-weight: var(--cr-chat-font-weight-semibold, 600);
}

.cr-chat-message--user .cr-chat-message__avatar {
  background: var(--cr-chat-bubble-user-bg, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
  color: var(--cr-chat-bubble-user-text, white);
}

/* Message avatar variants */
.cr-chat-message__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cr-chat-message__avatar-initials {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.cr-chat-message--assistant .cr-chat-message__avatar {
  background: var(--cr-chat-bubble-assistant-border, #e2e8f0);
  color: var(--cr-chat-text-secondary, #475569);
}

.cr-chat-message__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--cr-chat-spacing-xs, 4px);
}

.cr-chat-message__bubble {
  padding: var(--cr-chat-spacing-md, 12px) var(--cr-chat-spacing-lg, 16px);
  border-radius: var(--cr-chat-radius-bubble, 16px);
  font-size: var(--cr-chat-font-size-base, 14px);
  line-height: 1.5;
  word-wrap: break-word;
  max-width: 85%;
}

.cr-chat-message--user .cr-chat-message__bubble {
  background: var(--cr-chat-bubble-user-bg, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
  color: var(--cr-chat-bubble-user-text, white);
  border-bottom-right-radius: var(--cr-chat-spacing-xs, 4px);
  margin-left: auto;
}

.cr-chat-message--assistant .cr-chat-message__bubble {
  background: var(--cr-chat-bubble-assistant-bg, white);
  color: var(--cr-chat-bubble-assistant-text, #1e293b);
  border: 1px solid var(--cr-chat-bubble-assistant-border, #e2e8f0);
  border-bottom-left-radius: var(--cr-chat-spacing-xs, 4px);
}

.cr-chat-message__bubble--error {
  background: #fee2e2 !important;
  border-color: #fecaca !important;
  color: #991b1b !important;
}

.cr-chat-message__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #94a3b8;
  padding: 0 4px;
}

.cr-chat-message--user .cr-chat-message__meta {
  justify-content: flex-end;
}

/* Feedback Buttons */
.cr-chat-message__feedback {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cr-chat-message:hover .cr-chat-message__feedback {
  opacity: 1;
}

.cr-chat-message__feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.cr-chat-message__feedback-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.cr-chat-message__feedback-btn--helpful:hover:not(:disabled) {
  color: #22c55e;
}

.cr-chat-message__feedback-btn--unhelpful:hover:not(:disabled) {
  color: #ef4444;
}

.cr-chat-message__feedback-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.cr-chat-message__feedback-btn.submitting svg {
  animation: pulse 0.8s ease-in-out infinite;
}

.cr-chat-message__feedback-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.cr-chat-message__feedback-status--helpful {
  color: #22c55e;
}

.cr-chat-message__feedback-status--unhelpful {
  color: #ef4444;
}

.cr-chat-message__feedback-error {
  font-size: 11px;
  color: #ef4444;
  font-weight: 500;
}

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

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

/* Test Mode Indicator */
.cr-chat-message__test-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: #92400e;
}

.cr-chat-message__test-mode svg {
  flex-shrink: 0;
  color: #d97706;
}

.cr-chat-message--test-blocked .cr-chat-message__bubble {
  border-color: #f59e0b !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* Typing Indicator */
.cr-chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.cr-chat-typing__dot {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.cr-chat-typing__dot:nth-child(2) {
  animation-delay: 0.2s;
}

.cr-chat-typing__dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ========================================
   Chat Input
   ======================================== */
.cr-chat-input {
  flex-shrink: 0;
  border-top: 1px solid var(--cr-chat-border, #e2e8f0);
  background: var(--cr-chat-bg-input, white);
  padding: var(--cr-chat-spacing-lg, 16px);
}

.cr-chat-input__form {
  display: flex;
  flex-direction: column;
  gap: var(--cr-chat-spacing-md, 12px);
}

.cr-chat-input__wrapper {
  display: block;
  width: 100%;
}

.cr-chat-input__textarea {
  flex: 1 1 0%;
  width: 100%;
  min-width: 0;
  padding: var(--cr-chat-spacing-md, 12px) var(--cr-chat-spacing-lg, 16px);
  border: 1px solid var(--cr-chat-border, #e2e8f0);
  border-radius: var(--cr-chat-radius-md, 12px);
  font-size: var(--cr-chat-font-size-base, 14px);
  font-family: var(--cr-chat-font-family, inherit);
  color: var(--cr-chat-text-primary, #1e293b);
  background: var(--cr-chat-bg-widget, #ffffff);
  resize: none;
  outline: none;
  transition: all var(--cr-chat-transition-fast, 0.2s);
  max-height: 120px;
  min-height: 44px;
  line-height: 1.5;
  overflow-y: auto;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}

.cr-chat-input__textarea::-webkit-scrollbar {
  width: 4px;
}

.cr-chat-input__textarea::-webkit-scrollbar-track {
  background: transparent;
}

.cr-chat-input__textarea::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 2px;
}

.cr-chat-input__textarea::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}

.cr-chat-input__textarea:focus {
  border-color: var(--cr-chat-border-focus, var(--cr-chat-primary, #667eea));
  box-shadow: 0 0 0 3px rgba(var(--cr-chat-primary-rgb, 102, 126, 234), 0.1);
}

.cr-chat-input__textarea:disabled {
  background: var(--cr-chat-bg-messages, #f8fafc);
  cursor: not-allowed;
}

.cr-chat-input__actions {
  display: flex;
  gap: var(--cr-chat-spacing-sm, 8px);
}

.cr-chat-input__action {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--cr-chat-border, #e2e8f0);
  border-radius: 10px;
  color: var(--cr-chat-text-secondary, #64748b);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--cr-chat-transition-fast, 0.2s);
  flex-shrink: 0;
}

.cr-chat-input__action:hover:not(:disabled) {
  background: var(--cr-chat-bg-messages, #f8fafc);
  border-color: var(--cr-chat-border-hover, #cbd5e1);
  color: var(--cr-chat-text-secondary, #475569);
}

.cr-chat-input__action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cr-chat-input__action--recording {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: white !important;
  animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

.cr-chat-input__submit {
  width: 40px;
  height: 40px;
  background: var(--cr-chat-bg-header, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
  border: none;
  border-radius: 10px;
  color: var(--cr-chat-text-inverse, white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--cr-chat-transition-fast, 0.2s);
  flex-shrink: 0;
}

.cr-chat-input__submit:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(var(--cr-chat-primary-rgb, 102, 126, 234), 0.3);
}

.cr-chat-input__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cr-chat-input__submit svg,
.cr-chat-input__action svg {
  width: 20px;
  height: 20px;
}

.cr-chat-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.cr-chat-input__recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #ef4444;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 8px;
}

.cr-chat-input__recording-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

.cr-chat-input__error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: #b91c1c;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin-top: 8px;
}

.cr-chat-input__error-dismiss {
  background: transparent;
  border: none;
  color: #b91c1c;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.7;
}

.cr-chat-input__error-dismiss:hover {
  opacity: 1;
}

/* ========================================
   Chat Footer (Branding)
   ======================================== */
.cr-chat-footer {
  flex-shrink: 0;
  padding: var(--cr-chat-spacing-sm, 8px) var(--cr-chat-spacing-lg, 16px);
  background: var(--cr-chat-bg-widget, #ffffff);
  border-top: 1px solid var(--cr-chat-border, #e2e8f0);
  text-align: center;
}

.cr-chat-footer__link {
  font-size: var(--cr-chat-font-size-tiny, 11px);
  color: var(--cr-chat-text-muted, #94a3b8);
  text-decoration: none;
  transition: color var(--cr-chat-transition-fast, 0.2s);
}

.cr-chat-footer__link:hover {
  color: var(--cr-chat-text-secondary, #64748b);
}

/* ========================================
   Scrollbar
   ======================================== */
.cr-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.cr-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.cr-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.cr-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========================================
   Utilities
   ======================================== */
.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;
}

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 640px) {
  .cr-chat-button {
    bottom: 16px;
    right: 16px;
    left: auto;
    width: 52px;
    height: 52px;
  }

  /* Bottom-left positioning on mobile */
  .cr-chat-button.cr-chat-button--bottom-left {
    right: auto;
    left: 16px;
  }

  .cr-chat-widget {
    bottom: 84px;
    right: 16px;
    left: auto;
    width: calc(100vw - 32px);
    max-width: none;
    height: calc(100vh - 110px);
    max-height: none;
  }

  /* Bottom-left positioning on mobile */
  .cr-chat-widget.cr-chat-widget--bottom-left {
    right: auto;
    left: 16px;
  }

  .cr-chat-message__bubble {
    max-width: 90%;
  }

  .cr-chat-input__textarea {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* ========================================
   Dark Mode Support
   ======================================== */

/* Dark mode styles - reusable mixin-like selector */
.cr-chat-widget[data-color-scheme="dark"],
.cr-chat-button[data-color-scheme="dark"] {
  --cr-chat-dark-bg: #1e293b;
  --cr-chat-dark-bg-secondary: #0f172a;
  --cr-chat-dark-border: #334155;
  --cr-chat-dark-text: #f1f5f9;
  --cr-chat-dark-text-muted: #94a3b8;
  --cr-chat-dark-text-secondary: #cbd5e1;
}

/* Forced dark mode via data attribute */
.cr-chat-widget[data-color-scheme="dark"] {
  background: var(--cr-chat-dark-bg);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-messages {
  background: var(--cr-chat-dark-bg-secondary);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-message--assistant .cr-chat-message__bubble {
  background: var(--cr-chat-dark-bg);
  border-color: var(--cr-chat-dark-border);
  color: var(--cr-chat-dark-text);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-message--assistant .cr-chat-message__avatar {
  background: var(--cr-chat-dark-border);
  color: var(--cr-chat-dark-text-secondary);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-input {
  background: var(--cr-chat-dark-bg);
  border-color: var(--cr-chat-dark-border);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-input__textarea {
  background: var(--cr-chat-dark-bg-secondary);
  border-color: var(--cr-chat-dark-border);
  color: var(--cr-chat-dark-text);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-input__textarea:focus {
  border-color: var(--cr-chat-primary, #667eea);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-input__action {
  background: var(--cr-chat-dark-bg-secondary);
  border-color: var(--cr-chat-dark-border);
  color: var(--cr-chat-dark-text-muted);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-input__action:hover:not(:disabled) {
  background: var(--cr-chat-dark-bg);
  border-color: #475569;
  color: var(--cr-chat-dark-text-secondary);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-welcome__title {
  color: var(--cr-chat-dark-text);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-welcome__description {
  color: var(--cr-chat-dark-text-muted);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-welcome__suggestion {
  background: var(--cr-chat-dark-bg);
  border-color: var(--cr-chat-dark-border);
  color: var(--cr-chat-dark-text-secondary);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-welcome__suggestion:hover {
  background: var(--cr-chat-dark-border);
  border-color: #475569;
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-typing {
  background: var(--cr-chat-dark-bg);
  border-color: var(--cr-chat-dark-border);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-footer {
  background: var(--cr-chat-dark-bg);
  border-color: var(--cr-chat-dark-border);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-footer__link {
  color: var(--cr-chat-dark-text-muted);
}

/* Auto dark mode - follows system preference */
@media (prefers-color-scheme: dark) {
  .cr-chat-widget:not([data-color-scheme="light"]) {
    background: #1e293b;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-messages {
    background: #0f172a;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-message--assistant .cr-chat-message__bubble {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-message--assistant .cr-chat-message__avatar {
    background: #334155;
    color: #cbd5e1;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-input {
    background: #1e293b;
    border-color: #334155;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-input__textarea {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-input__textarea:focus {
    border-color: #667eea;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-input__action {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-input__action:hover:not(:disabled) {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-welcome__title {
    color: #f1f5f9;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-welcome__description {
    color: #94a3b8;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-welcome__suggestion {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-welcome__suggestion:hover {
    background: #334155;
    border-color: #475569;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-typing {
    background: #1e293b;
    border-color: #334155;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-footer {
    background: #1e293b;
    border-color: #334155;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-footer__link {
    color: #94a3b8;
  }
}

/* ========================================
   Override Elementor and Theme Styles
   High specificity to override Elementor's background-image: none !important
   Uses CSS variables so admin settings are applied
   ======================================== */

/* Chat Button */
html body button.cr-chat-button.cr-chat-button.cr-chat-button,
html body button.cr-chat-button.cr-chat-button.cr-chat-button:hover,
html body button.cr-chat-button.cr-chat-button.cr-chat-button:active,
html body button.cr-chat-button.cr-chat-button.cr-chat-button:focus {
  background: var(--cr-chat-button-bg, var(--cr-chat-bg-header, linear-gradient(135deg, var(--cr-chat-primary, #667eea) 0%, var(--cr-chat-secondary, #764ba2) 100%))) !important;
  background-color: var(--cr-chat-primary, #667eea) !important;
  color: var(--cr-chat-text-inverse, #ffffff) !important;
}

/* Chat Widget Container */
html body .cr-chat-widget.cr-chat-widget.cr-chat-widget {
  background: var(--cr-chat-bg-widget, white) !important;
  background-image: none !important;
}

/* Chat Header */
html body .cr-chat-header.cr-chat-header.cr-chat-header {
  background: var(--cr-chat-bg-header, linear-gradient(135deg, var(--cr-chat-primary, #667eea) 0%, var(--cr-chat-secondary, #764ba2) 100%)) !important;
}

html body .cr-chat-header__content.cr-chat-header__content.cr-chat-header__content {
  display: flex !important;
  gap: 12px !important;
}

html body .cr-chat-header__title.cr-chat-header__title.cr-chat-header__title {
  color: var(--cr-chat-text-inverse, white) !important;
}

html body .cr-chat-header__status-text.cr-chat-header__status-text.cr-chat-header__status-text {
  color: var(--cr-chat-text-inverse, white) !important;
  opacity: 0.9 !important;
}

html body .cr-chat-header__action.cr-chat-header__action:hover {
  background: rgba(255, 255, 255, 0.2) !important;
  background-image: none !important;
}

/* Messages Area */
html body .cr-chat-messages.cr-chat-messages.cr-chat-messages {
  background: var(--cr-chat-bg-messages, #f8fafc) !important;
  background-image: none !important;
}

/* Welcome Section */
html body .cr-chat-welcome__icon.cr-chat-welcome__icon.cr-chat-welcome__icon {
  background: var(--cr-chat-bg-header, linear-gradient(135deg, var(--cr-chat-primary, #667eea) 0%, var(--cr-chat-secondary, #764ba2) 100%)) !important;
}

html body .cr-chat-welcome__suggestion.cr-chat-welcome__suggestion.cr-chat-welcome__suggestion {
  background: var(--cr-chat-bg-widget, white) !important;
  background-image: none !important;
}

html body .cr-chat-welcome__suggestion.cr-chat-welcome__suggestion:hover {
  background: #f1f5f9 !important;
  background-image: none !important;
}

/* Message Bubbles */
html body .cr-chat-message--user .cr-chat-message__avatar.cr-chat-message__avatar {
  background: var(--cr-chat-bubble-user-bg, linear-gradient(135deg, var(--cr-chat-primary, #667eea) 0%, var(--cr-chat-secondary, #764ba2) 100%)) !important;
}

html body .cr-chat-message--assistant .cr-chat-message__avatar.cr-chat-message__avatar {
  background: var(--cr-chat-bubble-assistant-border, #e2e8f0) !important;
  background-image: none !important;
}

html body .cr-chat-message--user .cr-chat-message__bubble.cr-chat-message__bubble {
  background: var(--cr-chat-bubble-user-bg, linear-gradient(135deg, var(--cr-chat-primary, #667eea) 0%, var(--cr-chat-secondary, #764ba2) 100%)) !important;
}

html body .cr-chat-message--assistant .cr-chat-message__bubble.cr-chat-message__bubble {
  background: var(--cr-chat-bubble-assistant-bg, white) !important;
  background-image: none !important;
}

html body .cr-chat-message__bubble--error.cr-chat-message__bubble--error {
  background: #fee2e2 !important;
  background-image: none !important;
}

/* Typing Indicator */
html body .cr-chat-typing.cr-chat-typing.cr-chat-typing {
  background: white !important;
  background-image: none !important;
}

html body .cr-chat-typing__dot.cr-chat-typing__dot {
  background: #94a3b8 !important;
  background-image: none !important;
}

/* Input Area */
html body .cr-chat-input.cr-chat-input.cr-chat-input {
  background: var(--cr-chat-bg-input, white) !important;
  background-image: none !important;
}

html body .cr-chat-input__textarea.cr-chat-input__textarea.cr-chat-input__textarea {
  background: var(--cr-chat-bg-widget, #ffffff) !important;
  background-image: none !important;
}

html body .cr-chat-input__textarea.cr-chat-input__textarea:disabled {
  background: var(--cr-chat-bg-messages, #f8fafc) !important;
  background-image: none !important;
}

html body .cr-chat-input__action.cr-chat-input__action:hover:not(:disabled) {
  background: var(--cr-chat-bg-messages, #f8fafc) !important;
  background-image: none !important;
}

html body .cr-chat-input__action--recording.cr-chat-input__action--recording {
  background: #ef4444 !important;
  background-image: none !important;
}

html body .cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit {
  background: var(--cr-chat-bg-header, linear-gradient(135deg, var(--cr-chat-primary, #667eea) 0%, var(--cr-chat-secondary, #764ba2) 100%)) !important;
}

html body .cr-chat-input__recording-indicator.cr-chat-input__recording-indicator {
  background: #fef2f2 !important;
  background-image: none !important;
}

html body .cr-chat-input__recording-dot.cr-chat-input__recording-dot {
  background: #ef4444 !important;
  background-image: none !important;
}

/* Scrollbar */
html body .cr-chat-messages.cr-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1 !important;
  background-image: none !important;
}

html body .cr-chat-messages.cr-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8 !important;
  background-image: none !important;
}

/* SVG Colors - Chat Button */
html body button.cr-chat-button.cr-chat-button.cr-chat-button {
  color: #ffffff !important;
}

html body button.cr-chat-button.cr-chat-button.cr-chat-button svg,
html body button.cr-chat-button.cr-chat-button.cr-chat-button:hover svg,
html body button.cr-chat-button.cr-chat-button.cr-chat-button svg path,
html body button.cr-chat-button.cr-chat-button.cr-chat-button svg rect,
html body button.cr-chat-button.cr-chat-button.cr-chat-button:hover svg path,
html body button.cr-chat-button.cr-chat-button.cr-chat-button:hover svg rect {
  stroke: #ffffff !important;
  fill: none !important;
  color: #ffffff !important;
  display: block !important;
  width: 24px !important;
  height: 24px !important;
}

html body button.cr-chat-button.cr-chat-button.cr-chat-button svg rect[fill] {
  fill: #ffffff !important;
}

/* SVG Colors - Header Actions */
html body .cr-chat-header__action.cr-chat-header__action.cr-chat-header__action,
html body .cr-chat-header__action.cr-chat-header__action.cr-chat-header__action:hover {
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

html body button.cr-chat-header__action.cr-chat-header__action.cr-chat-header__action svg,
html body button.cr-chat-header__action.cr-chat-header__action.cr-chat-header__action svg path,
html body button.cr-chat-header__action.cr-chat-header__action.cr-chat-header__action:hover svg,
html body button.cr-chat-header__action.cr-chat-header__action.cr-chat-header__action:hover svg path {
  stroke: #ffffff !important;
  fill: none !important;
  color: #ffffff !important;
  display: block !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
}

/* Input Actions Container */
html body .cr-chat-input__actions.cr-chat-input__actions {
  display: flex !important;
  gap: var(--cr-chat-spacing-sm, 8px) !important;
}

/* SVG Colors - Input Actions */
html body .cr-chat-input__action.cr-chat-input__action.cr-chat-input__action,
html body .cr-chat-input__action.cr-chat-input__action.cr-chat-input__action:hover {
  color: var(--cr-chat-text-secondary, #64748b) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

html body button.cr-chat-input__action.cr-chat-input__action.cr-chat-input__action svg,
html body button.cr-chat-input__action.cr-chat-input__action.cr-chat-input__action svg path,
html body button.cr-chat-input__action.cr-chat-input__action.cr-chat-input__action svg rect,
html body button.cr-chat-input__action.cr-chat-input__action.cr-chat-input__action:hover svg,
html body button.cr-chat-input__action.cr-chat-input__action.cr-chat-input__action:hover svg path,
html body button.cr-chat-input__action.cr-chat-input__action.cr-chat-input__action:hover svg rect {
  stroke: currentColor !important;
  fill: none !important;
  color: inherit !important;
  display: block !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
}

html body .cr-chat-input__action.cr-chat-input__action.cr-chat-input__action svg rect[fill] {
  fill: currentColor !important;
}

html body .cr-chat-input__action--recording.cr-chat-input__action--recording.cr-chat-input__action--recording,
html body .cr-chat-input__action--recording.cr-chat-input__action--recording.cr-chat-input__action--recording:hover {
  color: #ffffff !important;
}

html body .cr-chat-input__action--recording.cr-chat-input__action--recording.cr-chat-input__action--recording svg,
html body .cr-chat-input__action--recording.cr-chat-input__action--recording.cr-chat-input__action--recording svg path,
html body .cr-chat-input__action--recording.cr-chat-input__action--recording.cr-chat-input__action--recording svg rect {
  stroke: #ffffff !important;
  fill: #ffffff !important;
  color: #ffffff !important;
  display: block !important;
  width: 20px !important;
  height: 20px !important;
}

/* SVG Colors - Submit Button */
html body .cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit,
html body .cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit:hover {
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

html body button.cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit svg,
html body button.cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit svg path,
html body button.cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit svg circle,
html body button.cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit:hover svg,
html body button.cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit:hover svg path,
html body button.cr-chat-input__submit.cr-chat-input__submit.cr-chat-input__submit:hover svg circle {
  stroke: #ffffff !important;
  fill: none !important;
  color: #ffffff !important;
  display: block !important;
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
}

/* Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
  html body .cr-chat-widget.cr-chat-widget.cr-chat-widget {
    background: #1e293b !important;
  }

  html body .cr-chat-messages.cr-chat-messages.cr-chat-messages {
    background: #0f172a !important;
  }

  html body .cr-chat-message--assistant .cr-chat-message__bubble.cr-chat-message__bubble {
    background: #1e293b !important;
  }

  html body .cr-chat-message--assistant .cr-chat-message__avatar.cr-chat-message__avatar {
    background: #334155 !important;
  }

  html body .cr-chat-input.cr-chat-input.cr-chat-input {
    background: #1e293b !important;
  }

  html body .cr-chat-input__textarea.cr-chat-input__textarea.cr-chat-input__textarea {
    background: #0f172a !important;
  }

  html body .cr-chat-input__action.cr-chat-input__action.cr-chat-input__action {
    background: #0f172a !important;
  }

  html body .cr-chat-input__action.cr-chat-input__action:hover:not(:disabled) {
    background: #1e293b !important;
  }

  html body .cr-chat-welcome__suggestion.cr-chat-welcome__suggestion.cr-chat-welcome__suggestion {
    background: #1e293b !important;
  }

  html body .cr-chat-welcome__suggestion.cr-chat-welcome__suggestion:hover {
    background: #334155 !important;
  }

  html body .cr-chat-typing.cr-chat-typing.cr-chat-typing {
    background: #1e293b !important;
  }
}

/* ========================================
   Expanded Mode
   Full viewport height when expanded
   ======================================== */
.cr-chat-widget--expanded {
  height: 100vh !important;
  max-height: 100vh !important;
  top: 0 !important;
  bottom: 0 !important;
  right: 0 !important;
  width: var(--cr-chat-widget-width, 400px) !important;
  border-radius: 0 !important;
  transition: all var(--cr-chat-transition-normal, 0.3s) var(--cr-chat-transition-ease, cubic-bezier(0.4, 0, 0.2, 1));
}

.cr-chat-widget--expanded.cr-chat-widget--bottom-left {
  right: auto !important;
  left: 0 !important;
}

/* ========================================
   Resize Handle
   Left edge drag handle for resizing width
   ======================================== */
.cr-chat-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background var(--cr-chat-transition-fast, 0.2s);
}

.cr-chat-resize-handle:hover,
.cr-chat-resize-handle:focus {
  background: rgba(var(--cr-chat-primary-rgb, 102, 126, 234), 0.1);
}

.cr-chat-resize-handle:focus {
  outline: 2px solid var(--cr-chat-primary, #667eea);
  outline-offset: -2px;
}

.cr-chat-resize-handle__grip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 2px;
  opacity: 0;
  transition: opacity var(--cr-chat-transition-fast, 0.2s);
}

.cr-chat-resize-handle:hover .cr-chat-resize-handle__grip,
.cr-chat-resize-handle:focus .cr-chat-resize-handle__grip {
  opacity: 1;
}

.cr-chat-resize-handle__grip span {
  width: 4px;
  height: 4px;
  background: var(--cr-chat-primary, #667eea);
  border-radius: 50%;
}

/* Hide resize handle on mobile */
@media (max-width: 640px) {
  .cr-chat-resize-handle {
    display: none !important;
  }
}

/* ========================================
   Topic Cards
   Grid of suggestion cards with icons
   ======================================== */
.cr-chat-topics {
  display: grid;
  /* Auto-fit: 2 columns when space allows (min 140px per card), otherwise 1 column */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--cr-chat-spacing-sm, 8px);
  padding: 0;
  margin-top: var(--cr-chat-spacing-md, 12px);
  width: 100%;
  max-width: 100%;
}

.cr-chat-topic-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--cr-chat-spacing-xs, 4px);
  padding: var(--cr-chat-spacing-sm, 8px) var(--cr-chat-spacing-md, 12px);
  background: var(--cr-chat-bg-widget, white);
  border: 1px solid var(--cr-chat-border, #e2e8f0);
  border-radius: var(--cr-chat-radius-md, 12px);
  cursor: pointer;
  transition: all var(--cr-chat-transition-fast, 0.2s);
  text-align: left;
  box-sizing: border-box;
  min-width: 0; /* Allow flex/grid shrinking */
  overflow: hidden; /* Prevent content overflow */
}

.cr-chat-topic-card:hover {
  background: #f1f5f9;
  border-color: var(--cr-chat-border-hover, #cbd5e1);
  transform: translateY(-2px);
  box-shadow: var(--cr-chat-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.cr-chat-topic-card:focus {
  outline: 2px solid var(--cr-chat-primary, #667eea);
  outline-offset: 2px;
}

.cr-chat-topic-card__icon {
  font-size: 24px;
  line-height: 1;
}

.cr-chat-topic-card__content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0; /* Allow text truncation */
  overflow: hidden;
}

.cr-chat-topic-card__title {
  font-size: var(--cr-chat-font-size-base, 14px);
  font-weight: var(--cr-chat-font-weight-semibold, 600);
  color: var(--cr-chat-text-primary, #1e293b);
  margin: 0;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cr-chat-topic-card__description {
  font-size: var(--cr-chat-font-size-small, 13px);
  color: var(--cr-chat-text-secondary, #64748b);
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-height: 2.8em;
}

/* Topic cards loading skeleton */
.cr-chat-topic-card--loading {
  pointer-events: none;
}

.cr-chat-topic-card--loading .cr-chat-topic-card__icon,
.cr-chat-topic-card--loading .cr-chat-topic-card__title,
.cr-chat-topic-card--loading .cr-chat-topic-card__description {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  color: transparent !important;
}

.cr-chat-topic-card--loading .cr-chat-topic-card__icon {
  width: 24px;
  height: 24px;
}

.cr-chat-topic-card--loading .cr-chat-topic-card__title {
  width: 80%;
  height: 16px;
}

.cr-chat-topic-card--loading .cr-chat-topic-card__description {
  width: 100%;
  height: 14px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Grid auto-adapts via auto-fit, no media query needed */

/* Dark mode support for topic cards */
.cr-chat-widget[data-color-scheme="dark"] .cr-chat-topic-card {
  background: var(--cr-chat-dark-bg, #1e293b);
  border-color: var(--cr-chat-dark-border, #334155);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-topic-card:hover {
  background: var(--cr-chat-dark-border, #334155);
  border-color: #475569;
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-topic-card__title {
  color: var(--cr-chat-dark-text, #f1f5f9);
}

.cr-chat-widget[data-color-scheme="dark"] .cr-chat-topic-card__description {
  color: var(--cr-chat-dark-text-muted, #94a3b8);
}

@media (prefers-color-scheme: dark) {
  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-topic-card {
    background: #1e293b;
    border-color: #334155;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-topic-card:hover {
    background: #334155;
    border-color: #475569;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-topic-card__title {
    color: #f1f5f9;
  }

  .cr-chat-widget:not([data-color-scheme="light"]) .cr-chat-topic-card__description {
    color: #94a3b8;
  }
}

/* High specificity overrides for topic cards */
html body .cr-chat-topic-card.cr-chat-topic-card.cr-chat-topic-card {
  background: var(--cr-chat-bg-widget, white) !important;
  background-image: none !important;
}

html body .cr-chat-topic-card.cr-chat-topic-card:hover {
  background: #f1f5f9 !important;
  background-image: none !important;
}

/* ========================================
   Reduced Motion Support
   Accessibility for users who prefer reduced motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  /* Disable all animations */
  .cr-chat-button,
  .cr-chat-widget,
  .cr-chat-message,
  .cr-chat-message__bubble,
  .cr-chat-input__textarea,
  .cr-chat-input__action,
  .cr-chat-input__submit,
  .cr-chat-header__action,
  .cr-chat-welcome__suggestion,
  .cr-chat-typing__dot,
  .cr-chat-message__feedback-btn,
  .cr-chat-input__recording-indicator,
  .cr-chat-input__recording-dot,
  * {
    animation: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }

  /* Widget still appears but without slide animation */
  .cr-chat-widget {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  /* Button hover still works but instantly */
  .cr-chat-button {
    transition: none !important;
  }

  /* Disable typing animation - show static dots */
  .cr-chat-typing__dot {
    animation: none !important;
    opacity: 0.6 !important;
  }

  /* Disable pulse animations */
  .cr-chat-header__status-indicator,
  .cr-chat-input__recording-dot {
    animation: none !important;
  }

  /* Message feedback - instant hover states */
  .cr-chat-message__feedback-btn {
    transition: none !important;
  }

  /* Scroll behavior - instant jump instead of smooth */
  .cr-chat-messages {
    scroll-behavior: auto !important;
  }
}
