/* ============================================================================
   Message Actions Component Styles
   ============================================================================

   Styles for the context menu and inline results system in conversation messages.
   Features:
   - Context menu (3 dots) with dropdown
   - Inline results display (loading, success, error)
   - Animations and transitions
   - Mobile responsive (bottom sheet on mobile)
   - Dark mode support via CSS variables
*/

/* ============================================================================
   CONTEXT MENU
   ============================================================================ */

/* Menu trigger button */
.context-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  color: var(--text-secondary);
}

/* Show trigger on hover (desktop) or always (mobile) */
@media (min-width: 640px) {
  .context-menu-trigger {
    opacity: 0;
  }

  .message-bubble-simple:hover .context-menu-trigger,
  .context-menu-trigger:focus {
    opacity: 1;
  }
}

@media (max-width: 639px) {
  .context-menu-trigger {
    opacity: 1 !important;
  }
}

/* Context menu dropdown */
.message-context-menu {
  position: relative;
  z-index: 50;
}

.context-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 0.25rem;
  animation: slideDown 0.2s ease-out;
}

/* Context menu items */
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
  text-align: left;
  min-height: 44px; /* Touch-friendly */
}

.context-menu-item:hover {
  background: var(--bg-surface-hover);
}

.context-menu-item svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.context-menu-item:hover svg {
  color: var(--accent);
}

/* Flow cost badge */
.flow-cost {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--accent-10);
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
}

/* Divider */
.context-menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 0.25rem 0;
}

/* Mobile: Bottom sheet instead of dropdown */
@media (max-width: 639px) {
  .context-menu-dropdown {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    margin: 0;
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
  }
}

/* ============================================================================
   INLINE RESULTS CONTAINER
   ============================================================================ */

.inline-results-container {
  margin-top: 0.75rem;
  animation: slideDown 0.3s ease-out;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.loading-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 0.75rem;
  padding: 1rem;
}

/* Progress bar */
.progress-bar {
  position: relative;
  overflow: hidden;
  background: var(--bg-surface-hover);
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--accent-20) 0%,
    var(--accent) 50%,
    var(--accent-20) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ============================================================================
   SUCCESS STATE - SUGGESTION/IMPROVEMENT CARDS
   ============================================================================ */

.suggestion-card,
.improvement-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 0.75rem;
  padding: 1rem;
  transition: all 0.2s ease;
  animation: fadeInScale 0.3s ease-out;
}

.suggestion-card:hover,
.improvement-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Stagger animation for multiple suggestions */
.suggestion-card:nth-child(2) {
  animation-delay: 0.1s;
}

.suggestion-card:nth-child(3) {
  animation-delay: 0.2s;
}

/* ============================================================================
   ERROR STATE
   ============================================================================ */

.error-card {
  animation: fadeInScale 0.3s ease-out;
}

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

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

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

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Shimmer effect class (for loading states) */
.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-surface) 0%,
    var(--bg-surface-hover) 50%,
    var(--bg-surface) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus visible for keyboard navigation */
.context-menu-trigger:focus-visible,
.context-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .context-menu-dropdown,
  .inline-results-container,
  .suggestion-card,
  .improvement-card,
  .error-card {
    animation: none;
  }

  .progress-fill,
  .loading-shimmer {
    animation: none;
  }

  .context-menu-trigger,
  .context-menu-item,
  .suggestion-card,
  .improvement-card {
    transition: none;
  }
}

/* ============================================================================
   HIGH CONTRAST MODE
   ============================================================================ */

@media (prefers-contrast: high) {
  .context-menu-dropdown {
    border-width: 2px;
  }

  .context-menu-item:hover {
    outline: 2px solid var(--text-primary);
    outline-offset: -2px;
  }
}
