/* ============================================
   AI WRITING HELPER STYLES
   Created: October 7, 2025
   AI-powered description writing assistant for marketplace listings
   ============================================ */

/* ============================================
   1. DESCRIPTION HEADER WITH AI BUTTON
   ============================================ */

.description-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.description-header h3 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
}

.ai-helper-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  transition: all var(--transition-base);
}

.ai-helper-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-helper-btn svg {
  flex-shrink: 0;
}

/* ============================================
   2. AI HELPER CONTAINER
   ============================================ */

.ai-helper-container {
  position: relative;
  width: 100%;
}

.ai-helper-panel {
  position: absolute;
  top: 0;
  right: calc(100% + 16px);
  width: 400px;
  background: var(--color-bg-elevated);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  max-height: 600px;
  overflow-y: auto;
  transition: all var(--transition-base);
}

.ai-helper-panel.hidden {
  display: none;
}

/* Responsive positioning */
@media (max-width: 1200px) {
  .ai-helper-panel {
    position: relative;
    right: auto;
    width: 100%;
    margin-bottom: var(--space-lg);
    order: -1;
  }
}

/* ============================================
   3. AI HELPER HEADER
   ============================================ */

.ai-helper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ai-helper-header h4 {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.ai-helper-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-helper-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* ============================================
   4. AI HELPER CONTENT
   ============================================ */

.ai-helper-content {
  padding: var(--space-lg);
}

.ai-helper-intro {
  margin: 0 0 var(--space-lg);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
}

/* ============================================
   5. AI HELPER INPUTS
   ============================================ */

.ai-helper-inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.form-group-sm {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-group-sm label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.input-sm {
  padding: var(--space-sm);
  font-size: var(--font-size-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.input-sm:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ============================================
   6. AI HELPER ACTIONS
   ============================================ */

.ai-helper-actions {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.ai-helper-actions .btn {
  flex: 1;
  min-width: -webkit-fill-available;
  min-width: fit-content;
}

.ai-helper-actions .btn svg {
  vertical-align: middle;
}

/* ============================================
   7. GENERATED PREVIEW
   ============================================ */

.ai-generated-preview {
  background: var(--color-bg-secondary);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-top: var(--space-lg);
  animation: slideIn 0.3s ease;
}

.ai-generated-preview.hidden {
  display: none;
}

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

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.preview-header strong {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.preview-length {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.preview-content {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-relaxed);
  color: var(--color-text);
  white-space: pre-wrap;
  margin-bottom: var(--space-md);
  max-height: 300px;
  overflow-y: auto;
  padding: var(--space-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.preview-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.preview-actions .btn {
  flex: 1;
  min-width: -webkit-fill-available;
  min-width: fit-content;
}

/* ============================================
   8. AI LOADING STATE
   ============================================ */

.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  gap: var(--space-md);
}

.ai-loading.hidden {
  display: none;
}

.ai-loading p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================================
   9. RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .description-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-helper-btn {
    width: 100%;
    justify-content: center;
  }

  .ai-helper-panel {
    width: 100%;
    max-height: none;
  }

  .ai-helper-actions,
  .preview-actions {
    flex-direction: column;
  }

  .ai-helper-actions .btn,
  .preview-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .ai-helper-header {
    padding: var(--space-md);
  }

  .ai-helper-content {
    padding: var(--space-md);
  }

  .ai-helper-header h4 {
    font-size: var(--font-size-base);
  }
}

/* ============================================
   10. ACCESSIBILITY
   ============================================ */

.ai-helper-btn:focus-visible,
.ai-helper-close:focus-visible,
.input-sm:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

/* ============================================
   11. DARK MODE ADJUSTMENTS
   ============================================ */

[data-theme="dark"] .ai-helper-panel {
  border-color: var(--color-border);
}

[data-theme="dark"] .preview-content {
  background: var(--color-bg-secondary);
}

[data-theme="dark"] .loading-spinner {
  border-color: var(--color-border);
  border-top-color: #8b9aff;
}

/* ============================================
   12. PRINT STYLES
   ============================================ */

@media print {
  .ai-helper-btn,
  .ai-helper-panel {
    display: none !important;
  }
}

/* ============================================
   13. ANIMATION UTILITIES
   ============================================ */

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* ============================================
   14. SUCCESS/ERROR STATES
   ============================================ */

.ai-message {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  margin-top: var(--space-md);
}

.ai-message-success {
  background: rgba(0, 204, 0, 0.1);
  border: 1px solid var(--color-success);
  color: var(--color-success);
}

.ai-message-error {
  background: rgba(204, 0, 0, 0.1);
  border: 1px solid var(--color-error);
  color: var(--color-error);
}

/* ============================================
   15. BUTTON VARIANTS
   ============================================ */

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn-outline:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-text);
}

