/**
 * AI Assistant Panel Styles - v2026-01-24b
 * Slide-over chat panel (70% width, brand purple colors)
 */

/* Panel Container */
.ai-assistant-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ai-assistant-panel.open {
  pointer-events: auto;
  opacity: 1;
}

/* Overlay */
.ai-assistant-panel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

/* Panel Content */
.ai-assistant-panel-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 70%;
  max-width: 900px;
  min-width: 400px;
  background: var(--ai-surface, #fff);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}

.ai-assistant-panel.open .ai-assistant-panel-content {
  transform: translateX(0);
}

/* Header */
.ai-assistant-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ai-border, #E5E7EB);
  background: var(--ai-surface, #fff);
  flex-shrink: 0;
}

.ai-assistant-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ai-text-primary, #111827);
}

.ai-assistant-panel-title svg {
  color: #7C3AED;
}

.ai-assistant-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-assistant-panel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ai-text-secondary, #6B7280);
  transition: background 0.15s, color 0.15s;
}

.ai-assistant-panel-btn:hover {
  background: var(--ai-bg-hover, #F3F4F6);
  color: var(--ai-text-primary, #111827);
}

/* Messages Area */
.ai-assistant-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message */
.ai-panel-message {
  display: flex;
  gap: 10px;
  max-width: 100%;
}

.ai-panel-message.user {
  flex-direction: row-reverse;
}

.ai-panel-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
}

.ai-panel-message.assistant .ai-panel-message-avatar {
  background: #7C3AED;
  color: white;
}

.ai-panel-message.user .ai-panel-message-avatar {
  background: #7C3AED;
  color: white;
}

.ai-panel-message-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  max-width: calc(100% - 50px);
  word-wrap: break-word;
}

.ai-panel-message.assistant .ai-panel-message-content {
  background: var(--ai-bg-secondary, #F3F4F6);
  color: var(--ai-text-primary, #111827);
  border-bottom-left-radius: 4px;
}

.ai-panel-message.user .ai-panel-message-content {
  background: #7C3AED;
  color: white;
  border-bottom-right-radius: 4px;
}

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

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

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

/* Quick Actions */
.ai-assistant-panel-quick-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--ai-border, #E5E7EB);
  overflow-x: auto;
  flex-shrink: 0;
}

.ai-quick-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--ai-border, #E5E7EB);
  background: var(--ai-surface, #fff);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ai-text-secondary, #6B7280);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.ai-quick-action:hover {
  border-color: #7C3AED;
  color: #7C3AED;
  background: rgba(152, 16, 250, 0.05);
}

.ai-quick-action svg {
  flex-shrink: 0;
}

/* Input Area */
.ai-assistant-panel-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--ai-border, #E5E7EB);
  background: var(--ai-surface, #fff);
  flex-shrink: 0;
}

.ai-assistant-panel-input textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--ai-border, #E5E7EB);
  border-radius: 24px;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 120px;
  transition: border-color 0.15s;
}

.ai-assistant-panel-input textarea:focus {
  border-color: #7C3AED;
}

.ai-panel-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: #7C3AED;
  color: white;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

.ai-panel-send-btn:hover:not(:disabled) {
  background: #6D28D9;
  transform: scale(1.05);
}

.ai-panel-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading */
.ai-panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

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

.ai-loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--ai-text-muted, #9CA3AF);
  border-radius: 50%;
  animation: aiPanelBounce 1.4s infinite ease-in-out both;
}

.ai-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes aiPanelBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Error */
.ai-panel-error {
  padding: 20px;
  text-align: center;
  color: var(--ai-text-secondary, #6B7280);
}

/* History Panel */
.ai-assistant-history-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ai-surface, #fff);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.ai-assistant-history-panel.visible {
  transform: translateX(0);
}

.ai-history-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ai-border, #E5E7EB);
  font-weight: 600;
  color: var(--ai-text-primary, #111827);
}

.ai-history-back {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ai-text-secondary, #6B7280);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}

.ai-history-back:hover {
  background: var(--ai-bg-hover, #F3F4F6);
}

.ai-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.ai-history-item {
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}

.ai-history-item:hover {
  background: var(--ai-bg-hover, #F3F4F6);
}

.ai-history-item.active {
  background: rgba(152, 16, 250, 0.08);
  border: 1px solid rgba(152, 16, 250, 0.2);
}

.ai-history-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ai-text-primary, #111827);
  margin-bottom: 4px;
}

.ai-history-item-preview {
  font-size: 13px;
  color: var(--ai-text-secondary, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-history-loading,
.ai-history-empty,
.ai-history-error {
  padding: 40px 20px;
  text-align: center;
  color: var(--ai-text-secondary, #6B7280);
}

/* AI Button in Header */
.ai-assistant-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  background: #7C3AED;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-width: fit-content;
  transition: background 0.15s;
}

.ai-assistant-btn:hover {
  background: #6D28D9;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .ai-assistant-btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .ai-assistant-panel-content {
    width: 100%;
    min-width: unset;
    max-width: 100%;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .ai-assistant-panel-content {
    background: #1F2937;
  }

  .ai-assistant-panel-header {
    background: #1F2937;
    border-color: #374151;
  }

  .ai-assistant-panel-title {
    color: #F9FAFB;
  }

  .ai-panel-message.assistant .ai-panel-message-content {
    background: #374151;
    color: #F9FAFB;
  }

  .ai-assistant-panel-quick-actions {
    border-color: #374151;
  }

  .ai-quick-action {
    border-color: #374151;
    background: #1F2937;
    color: #9CA3AF;
  }

  .ai-assistant-panel-input {
    background: #1F2937;
    border-color: #374151;
  }

  .ai-assistant-panel-input textarea {
    background: #374151;
    border-color: #4B5563;
    color: #F9FAFB;
  }

  .ai-assistant-history-panel {
    background: #1F2937;
  }

  .ai-history-header {
    border-color: #374151;
    color: #F9FAFB;
  }

  .ai-history-item-title {
    color: #F9FAFB;
  }
}
