/* Chatbot Widget Styles - V2 Design System */
:root {
  --chatbot-primary: var(--accent-primary, #00d4aa);
  --chatbot-primary-dark: var(--accent-primary-hover, #00b894);
  --chatbot-secondary: var(--accent-secondary, #00a8ff);
  --chatbot-accent: #a855f7;
  --chatbot-dark-bg: var(--bg-primary, #0a0e1a);
  --chatbot-darker-bg: #050810;
  --chatbot-card-bg: var(--bg-card, rgba(15, 20, 40, 0.85));
  --chatbot-text-primary: var(--text-primary, #ffffff);
  --chatbot-text-secondary: var(--text-secondary, #94a3b8);
  --chatbot-text-muted: var(--text-muted, #64748b);
  --chatbot-border: var(--border-color, rgba(255, 255, 255, 0.08));
  --chatbot-gradient-primary: linear-gradient(135deg, var(--accent-primary, #00d4aa) 0%, var(--accent-secondary, #00a8ff) 100%);
  --chatbot-gradient-card: linear-gradient(145deg, rgba(26, 31, 58, 0.9) 0%, rgba(45, 55, 72, 0.8) 100%);
  --chatbot-shadow-soft: var(--shadow-soft, 0 10px 40px rgba(0, 0, 0, 0.4));
  --chatbot-shadow-hover: var(--shadow-hover, 0 20px 50px rgba(0, 212, 170, 0.15));
  --chatbot-shadow-glow: var(--shadow-glow, 0 0 30px rgba(0, 212, 170, 0.25));
  --chatbot-error-color: var(--color-warning, #ffa726);
}

/* Light mode overrides */
[data-theme="light"] {
  --chatbot-darker-bg: var(--bg-secondary, #eceae5);
  --chatbot-gradient-card: linear-gradient(145deg, var(--bg-card, #ffffff) 0%, var(--bg-card-hover, #f8f8f5) 100%);
}

.chatbot-widget-container {
  position: fixed;
  bottom: 50px;
  right: 50px;
  z-index: 10003 !important; /* Always above back button (9999) */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.chatbot-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chatbot-gradient-primary);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow-soft), var(--chatbot-shadow-glow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-sizing: border-box;
  padding: 0;
  line-height: 1;
}

.chatbot-toggle-btn:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: var(--chatbot-shadow-hover), var(--chatbot-shadow-glow);
}

.chatbot-toggle-btn.active {
  background: var(--chatbot-gradient-primary);
  box-shadow: var(--chatbot-shadow-hover), var(--chatbot-shadow-glow);
}

.chatbot-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--color-danger, #ff6b6b);
  color: white;
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: bold;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(var(--color-danger, 239, 68, 68), 0.4);
}

.chatbot-badge.badge-locked {
  background: var(--color-warning, #ffa726);
  color: var(--text-inverse, #0a0e27);
  padding: 4px 6px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.chatbot-badge.hidden,
.requests-badge.hidden {
  display: none !important;
}

/* Chat Window */
.chatbot-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 480px;
  height: 700px;
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  border-radius: 16px;
  box-shadow: var(--chatbot-shadow-soft), 0 0 0 1px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10003 !important; /* Always above back button (9999) */
}

.chatbot-window.hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  visibility: hidden;
}

.chatbot-window.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* Window Header */
.chatbot-window-header {
  background: var(--chatbot-gradient-primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chatbot-window-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  pointer-events: none;
}

.chatbot-window-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  position: relative;
  z-index: 1;
}

.chatbot-window-title .badge {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-weight: 600;
}

.chatbot-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md, 8px);
  transition: all 0.2s ease;
  position: relative;
  z-index: 1;
}

.chatbot-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* Messages Container */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--chatbot-darker-bg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: rgba(128, 128, 128, 0.1);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-primary);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-secondary);
}

.welcome-message {
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  padding: 20px;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--chatbot-shadow-soft);
  margin-bottom: 8px;
  color: var(--chatbot-text-primary);
  font-size: 13px;
  line-height: 1.6;
}

.welcome-message p {
  color: var(--chatbot-text-primary);
  margin-bottom: 12px;
  font-size: 13px;
}

.welcome-message ul {
  margin: 10px 0;
  padding-left: 20px;
  color: var(--chatbot-text-secondary);
}

.welcome-message li {
  margin: 6px 0;
  line-height: 1.6;
  font-size: 13px;
}

.subscription-required-message {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.upgrade-notice {
  text-align: center;
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  padding: 24px 20px;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--chatbot-shadow-soft);
  max-width: 100%;
}

.upgrade-notice i {
  font-size: 24px;
  color: var(--chatbot-primary);
  margin-bottom: 12px;
  display: block;
}

.upgrade-notice p {
  font-size: 14px;
  color: var(--chatbot-text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}

.upgrade-notice .upgrade-btn {
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-md, 8px);
  background: var(--chatbot-gradient-primary);
  border: none;
  color: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.3);
  text-decoration: none;
  display: inline-block;
}

.upgrade-notice .upgrade-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.4);
  color: white;
  text-decoration: none;
}

.chatbot-input-wrapper.disabled {
  pointer-events: auto;
}

.upgrade-prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  border-radius: var(--radius-lg, 12px);
  color: var(--chatbot-text-secondary);
  font-size: 14px;
  flex-wrap: wrap;
}

.upgrade-prompt i {
  color: var(--chatbot-primary);
  font-size: 18px;
}

.upgrade-prompt span {
  flex: 1;
  min-width: 200px;
}

.upgrade-prompt .upgrade-link {
  padding: 8px 16px;
  font-weight: 600;
  border-radius: var(--radius-md, 8px);
  background: var(--chatbot-gradient-primary);
  border: none;
  color: white;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.3);
  white-space: nowrap;
}

.upgrade-prompt .upgrade-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.4);
  color: white;
  text-decoration: none;
}

.message {
  animation: fadeIn 0.3s ease-in;
  max-width: 80%;
}

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

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

.message.assistant {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.6;
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
}

.message-content p {
  margin: 0 0 8px 0;
}

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

.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

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

.message-content code {
  background: rgba(128, 128, 128, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.message.user .message-content {
  background: var(--chatbot-gradient-primary);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.3);
}

.message.assistant .message-content {
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  color: var(--chatbot-text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--chatbot-shadow-soft);
}

.message.error .message-content {
  background: rgba(var(--color-warning, 245, 158, 11), 0.2);
  border: 1px solid rgba(var(--color-warning, 245, 158, 11), 0.4);
  color: var(--chatbot-error-color);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Retry button for errors */
.retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 0 !important;
  margin-left: auto;
  margin-top: 8px;
  background: rgba(255, 167, 38, 0.3);
  border: 1px solid rgba(255, 167, 38, 0.5);
  border-radius: 50% !important;
  color: var(--chatbot-error-color);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0 !important;
  flex-grow: 0 !important;
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
}

.retry-btn:hover {
  background: rgba(255, 167, 38, 0.5);
  border-color: var(--chatbot-error-color);
  transform: scale(1.1);
}

.retry-btn:active {
  transform: scale(0.95);
}

.retry-btn i {
  font-size: 12px;
}

.message-time {
  font-size: 0.75rem;
  color: var(--chatbot-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

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

/* Loading Indicator */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--chatbot-shadow-soft);
  align-self: flex-start;
  max-width: 85%;
  animation: fadeIn 0.3s ease-in;
}

.loading-animation {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(var(--accent-primary-rgb, 0, 212, 170), 0.2);
  border-top-color: var(--chatbot-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--chatbot-primary);
  border-radius: 50%;
  animation: loadingDots 1.4s infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

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

.loading-text {
  color: var(--chatbot-text-primary);
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.3s ease;
  flex: 1;
}

/* Legacy Typing Indicator (for backward compatibility) */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--chatbot-shadow-soft);
  align-self: flex-start;
  max-width: 80px;
}

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

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--chatbot-primary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

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

.typing-text {
  color: var(--chatbot-text-secondary);
  font-size: 0.85rem;
}

/* Input Wrapper */
.chatbot-input-wrapper {
  padding: 16px 20px;
  background: var(--chatbot-dark-bg);
  border-top: 1px solid var(--chatbot-border);
  flex-shrink: 0;
}

.chatbot-form .input-group {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}

.chatbot-input {
  flex: 1;
  border-radius: var(--radius-2xl, 24px);
  padding: 10px 16px;
  background: var(--chatbot-card-bg);
  border: 1px solid var(--chatbot-border);
  color: var(--chatbot-text-primary);
  font-size: 16px; /* Prevent iOS zoom - must be at least 16px */
  transition: all 0.3s ease;
  resize: none;
  overflow-y: auto;
  min-height: 40px;
  max-height: 150px;
  line-height: 1.5;
  font-family: inherit;
}

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

.chatbot-input:focus {
  border-color: var(--chatbot-primary);
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.2), var(--chatbot-shadow-glow);
  outline: none;
  background: var(--chatbot-dark-bg);
}

.chatbot-send-btn {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  padding: 0;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  background: var(--chatbot-gradient-primary);
  border: none;
  color: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.3);
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.1) translateY(-2px);
  box-shadow: var(--chatbot-shadow-hover);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Resize Handle */
.chatbot-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--chatbot-border);
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chatbot-resize-handle:hover {
  background: var(--chatbot-primary);
}

.chatbot-resize-handle i {
  color: var(--chatbot-text-muted);
  font-size: 12px;
}

.chatbot-resize-handle:hover i {
  color: var(--chatbot-primary);
}

/* ============================================
   RESPONSIVE - MOBILE & TABLET (< 768px) - FULLSCREEN CHAT
   ============================================ */
@media (max-width: 767px) {
  .chatbot-widget-container {
    bottom: 16px;
    bottom: env(safe-area-inset-bottom, 16px);
    right: 16px;
    left: auto;
  }

  /* Fullscreen chat window on mobile/tablet */
  .chatbot-window {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 10003 !important; /* Always above back button (9999) */
  }

  /* Hide toggle button when chat is open */
  .chatbot-toggle-btn.active {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .chatbot-toggle-btn {
    width: 52px;
    height: 52px;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 10003 !important; /* Always above back button (9999) */
  }

  .chatbot-window-header {
    padding: 14px 16px;
    padding-top: env(safe-area-inset-top, 14px);
    border-radius: 0 !important;
  }

  .chatbot-messages {
    padding: 14px 10px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chatbot-input-wrapper {
    padding: 10px 14px;
    padding-bottom: 14px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .chatbot-form .input-group {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .chatbot-input {
    flex: 1;
    font-size: 16px !important; /* Prevent iOS zoom - must be at least 16px */
    min-height: 44px;
    padding: 10px 14px;
    width: auto !important;
  }

  /* Ensure chatbot input scrolls into view when keyboard appears */
  .chatbot-input:focus {
    /* Scroll will be handled by JavaScript, but ensure it's visible */
    outline: none;
  }

  .chatbot-send-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    max-width: 44px !important;
    max-height: 44px !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
  }

  .message-content {
    font-size: 13px;
    padding: 10px 12px;
    max-width: 90%;
  }

  .welcome-message {
    padding: 14px;
    font-size: 12px;
    margin: 10px;
  }

  /* Disable resize on mobile */
  .chatbot-resize-handle {
    display: none;
  }
}

/* TABLET PORTRAIT (576px - 767px) - Now included in fullscreen mode above */

/* ============================================
   RESPONSIVE - TABLET LANDSCAPE / MOBILE LARGE (768px - 1023px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1279px) {
  .chatbot-widget-container {
    bottom: 24px;
    right: 24px;
  }

  .chatbot-window {
    width: 480px;
    height: 650px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 120px);
    bottom: 100px;
    right: 24px;
    left: auto;
    border-radius: 16px;
  }

  .chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }

  .chatbot-window-header {
    padding: 18px 20px;
  }

  .chatbot-messages {
    padding: 20px 16px;
  }

  .chatbot-input-wrapper {
    padding: 16px 20px;
  }

  .chatbot-input {
    font-size: 15px;
    min-height: 44px;
    padding: 12px 16px;
  }

  .chatbot-send-btn {
    width: 44px;
    height: 44px;
  }

  .message-content {
    font-size: 14px;
    padding: 12px 16px;
    max-width: 80%;
  }

  .welcome-message {
    padding: 20px;
    font-size: 13px;
  }

  .chatbot-resize-handle {
    display: block;
    height: 10px;
  }
}

/* ============================================
   RESPONSIVE - DESKTOP (>= 1024px)
   ============================================ */
@media (min-width: 1280px) {
  .chatbot-widget-container {
    bottom: 50px;
    right: 50px;
  }

  .chatbot-window {
    width: 480px;
    height: 700px;
    bottom: 90px;
    right: 20px;
    border-radius: 16px;
  }

  .chatbot-toggle-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }

  .chatbot-resize-handle {
    display: block;
    height: 10px;
  }
}


/* ============================================
   SYSTEM ACTION MESSAGES
   ============================================ */
.message.system-action {
  margin-bottom: 16px;
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

/* Center system action button on tablet and desktop */
@media (min-width: 768px) {
  .message.system-action {
    align-self: center;
  }

  .message.system-action .message-content {
    margin: 0 auto;
  }
}

.message.system-action .message-content {
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.message.system-action .message-time {
  text-align: left;
  margin-top: 4px;
}

.system-action-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow: hidden;
}

/* On mobile, align to start */
@media (max-width: 767px) {
  .system-action-content {
    align-items: flex-start;
  }
}

.system-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  min-width: 200px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-md, 8px);
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.system-action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.system-action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.system-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Tutorial variant — teal/emerald gradient, distinct from the default purple */
.system-action-btn--tutorial {
  background: linear-gradient(135deg, #0f9d8c 0%, #16c79a 100%);
  box-shadow: 0 4px 12px rgba(15, 157, 140, 0.35);
}

.system-action-btn--tutorial:hover:not(:disabled) {
  background: linear-gradient(135deg, #16c79a 0%, #0f9d8c 100%);
  box-shadow: 0 6px 16px rgba(15, 157, 140, 0.5);
}

.system-action-btn.loading {
  position: relative;
  pointer-events: none;
}

.system-action-btn.loading .action-title,
.system-action-btn.loading .action-subtitle,
.system-action-btn.loading i {
  opacity: 0.3;
}

.system-action-btn.loading::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  top: 50%;
  left: 50%;
  margin-left: -12px;
  margin-top: -12px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 10;
}

.system-action-btn .action-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.system-action-btn .action-subtitle {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.9;
  margin-top: 2px;
  text-align: center;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.system-action-btn i {
  font-size: 18px;
  margin-bottom: 2px;
}

/* Mobile adjustments for system actions */
@media (max-width: 767px) {
  .system-action-btn {
    min-width: auto;
    width: 100%;
    max-width: 100%;
    padding: 12px 16px;
    box-sizing: border-box;
  }

  .system-action-btn .action-title {
    font-size: 14px;
    max-width: 100%;
  }

  .system-action-btn .action-subtitle {
    font-size: 11px;
    max-width: 100%;
  }

  .message.system-action {
    max-width: 90%;
  }
}

/* System action started/completed state */
.system-action-started {
  color: var(--chatbot-text-primary);
  font-size: 14px;
  padding: 12px 16px;
  background: var(--chatbot-gradient-card);
  border: 1px solid var(--chatbot-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--chatbot-shadow-soft);
  text-align: center;
}

.system-action-error {
  color: var(--chatbot-error-color);
  font-size: 14px;
  padding: 12px 16px;
  background: rgba(255, 167, 38, 0.2);
  border: 1px solid rgba(255, 167, 38, 0.4);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--chatbot-shadow-soft);
  text-align: center;
}

.system-action-error .btn {
  margin-top: 8px;
  background: var(--chatbot-gradient-primary);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-md, 8px);
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
}

.system-action-error .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-primary-rgb, 0, 212, 170), 0.4);
  color: white;
  text-decoration: none;
}

.message.system-action-completed {
  align-self: flex-start;
}

@media (min-width: 768px) {
  .message.system-action-completed {
    align-self: center;
  }
}
