/**
 * AI Appraisal Comment Styles
 * Ensures proper styling for AI-generated appraisal comments
 * Supports BOTH old format (no wrapper divs) and new format (with wrapper divs)
 */

/* Main container */
.ai-appraisal-comment {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}

/* ============================================
   OLD FORMAT SUPPORT (no wrapper divs)
   Comments without .ai-header, .social-proof-counter, etc.
   ============================================ */

/* Old format: First paragraph is the AI header */
.ai-appraisal-comment > p:first-child {
  font-size: 18px !important;
  margin-bottom: 8px !important;
  padding-bottom: 12px !important;
  border-bottom: 2px solid #1a365d !important;
}

.ai-appraisal-comment > p:first-child strong {
  color: #1a365d !important;
}

/* Old format: Second paragraph is Confidence Level */
.ai-appraisal-comment > p:nth-child(2) {
  background: #edf2f7 !important;
  padding: 8px 14px !important;
  border-radius: 6px !important;
  display: inline-block !important;
  margin-bottom: 15px !important;
  font-size: 14px !important;
}

/* ============================================
   NEW FORMAT SUPPORT (with wrapper divs)
   ============================================ */

/* New format: Header section wrapper */
.ai-appraisal-comment .ai-header {
  border-bottom: 2px solid #1a365d !important;
  padding-bottom: 12px !important;
  margin-bottom: 15px !important;
}

.ai-appraisal-comment .ai-header p {
  margin: 0 !important;
}

.ai-appraisal-comment .ai-header p:first-child {
  font-size: 18px !important;
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.ai-appraisal-comment .ai-header p:last-child {
  margin-top: 5px !important;
  font-size: 13px !important;
  color: #4a5568 !important;
}

/* New format: Social proof counter */
.ai-appraisal-comment .social-proof-counter {
  display: flex !important;
  justify-content: center !important;
  gap: 1.5rem !important;
  flex-wrap: wrap !important;
  background: #f8fafc !important;
  border-radius: 10px !important;
  padding: 12px 16px !important;
  margin-bottom: 15px !important;
  text-align: center !important;
}

.ai-appraisal-comment .social-proof-counter > div {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.ai-appraisal-comment .social-proof-counter span:first-child {
  font-size: 1.25rem !important;
}

.ai-appraisal-comment .social-proof-counter span:last-child {
  font-size: 13px !important;
  color: #4a5568 !important;
}

.ai-appraisal-comment .social-proof-counter strong {
  color: #1a365d !important;
}

/* New format: Archive-informed badge */
.ai-appraisal-comment .archive-informed-badge {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  padding: 12px 16px !important;
  border-radius: 8px !important;
  margin: 12px 0 !important;
  border-left: 4px solid #1a365d !important;
}

.ai-appraisal-comment .archive-informed-badge p {
  margin: 0 !important;
  font-size: 13px !important;
  color: #4a5568 !important;
}

/* ============================================
   MAIN APPRAISAL CONTENT (both formats)
   ============================================ */

/* Main title - h1 (new format) and h2 (old format) */
.ai-appraisal-comment h1,
.ai-appraisal-comment h2 {
  border-left: 4px solid #ed8936 !important;
  padding-left: 1rem !important;
  color: #2c5282 !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  margin: 1.5rem 0 1rem 0 !important;
  background: none !important;
  -webkit-text-fill-color: #2c5282 !important;
}

/* Horizontal rule */
.ai-appraisal-comment hr {
  border: none !important;
  border-top: 1px solid #e2e8f0 !important;
  margin: 20px 0 !important;
}

/* Section headings - paragraphs containing only a strong element */
.ai-appraisal-comment > p > strong:only-child {
  display: block !important;
  color: #1a365d !important;
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  margin-top: 1rem !important;
  padding-bottom: 0.5rem !important;
  border-bottom: 2px solid #edf2f7 !important;
}

/* Regular paragraphs */
.ai-appraisal-comment > p {
  color: #4a5568 !important;
  line-height: 1.7 !important;
  margin-bottom: 1rem !important;
}

/* Paragraphs with labels like "Category:", "Condition:" */
.ai-appraisal-comment > p > strong:first-child:not(:only-child) {
  color: #1a365d !important;
}

/* Lists */
.ai-appraisal-comment ul,
.ai-appraisal-comment ol {
  margin: 0.75rem 0 1.25rem 0 !important;
  padding-left: 1.5rem !important;
  background: #f8fafc !important;
  border-radius: 8px !important;
  padding-top: 12px !important;
  padding-bottom: 12px !important;
  padding-right: 12px !important;
}

.ai-appraisal-comment li {
  color: #4a5568 !important;
  line-height: 1.6 !important;
  margin-bottom: 0.5rem !important;
}

.ai-appraisal-comment li:last-child {
  margin-bottom: 0 !important;
}

.ai-appraisal-comment li strong {
  color: #1a365d !important;
}

/* ============================================
   ESTIMATED VALUE BOX (both formats)
   Matches: paragraph after an hr containing "ESTIMATED VALUE"
   ============================================ */

/* Style paragraphs after hr that contain value info */
.ai-appraisal-comment > hr + p {
  background: linear-gradient(135deg, #f6e05e 0%, #ecc94b 100%) !important;
  padding: 16px 20px !important;
  border-radius: 10px !important;
  text-align: center !important;
  margin: 20px 0 !important;
  box-shadow: 0 4px 12px rgba(236, 201, 75, 0.3) !important;
}

.ai-appraisal-comment > hr + p strong {
  display: block !important;
  font-size: 0.9rem !important;
  color: #744210 !important;
  margin-bottom: 8px !important;
}

/* ============================================
   HOW CREATED SECTION (new format only)
   ============================================ */

.ai-appraisal-comment .how-created-section {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
  padding: 16px !important;
  border-radius: 8px !important;
  margin-top: 15px !important;
  border: 1px solid #dee2e6 !important;
}

.ai-appraisal-comment .how-created-section p {
  margin: 0 !important;
}

.ai-appraisal-comment .how-created-section p:first-child {
  margin-bottom: 8px !important;
  font-size: 14px !important;
}

.ai-appraisal-comment .how-created-section p:nth-child(2) {
  font-size: 13px !important;
  color: #495057 !important;
  line-height: 1.5 !important;
}

.ai-appraisal-comment .how-created-section p:last-child {
  margin-top: 10px !important;
  font-size: 12px !important;
}

.ai-appraisal-comment .how-created-section a {
  color: #1a365d !important;
  text-decoration: none !important;
}

/* ============================================
   DISCLAIMER SECTION (new format only)
   ============================================ */

.ai-appraisal-comment .disclaimer {
  margin-top: 15px !important;
  padding: 12px !important;
  background: #fff3cd !important;
  border-radius: 6px !important;
  border-left: 4px solid #ffc107 !important;
}

.ai-appraisal-comment .disclaimer p {
  margin: 0 !important;
  font-size: 12px !important;
  color: #856404 !important;
}

/* ============================================
   UPGRADE PROMPTS (new format only)
   ============================================ */

.ai-appraisal-comment .upgrade-prompts {
  margin-top: 20px !important;
  border-top: 2px solid #e2e8f0 !important;
  padding-top: 20px !important;
}

.ai-appraisal-comment .upgrade-prompt {
  padding: 16px 18px !important;
  border-radius: 10px !important;
  margin-bottom: 15px !important;
}

.ai-appraisal-comment .upgrade-prompt.expert-review {
  background: #f7fafc !important;
  border: 2px solid #e2e8f0 !important;
}

.ai-appraisal-comment .upgrade-prompt.free-user {
  background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%) !important;
  border: 1px solid #9ae6b4 !important;
}

.ai-appraisal-comment .upgrade-prompt p:first-child {
  margin: 0 0 8px 0 !important;
  font-size: 15px !important;
}

.ai-appraisal-comment .upgrade-prompt p:nth-child(2) {
  margin: 0 0 10px 0 !important;
  font-size: 13px !important;
}

.ai-appraisal-comment .upgrade-prompt a {
  display: inline-block !important;
  padding: 8px 16px !important;
  border-radius: 50px !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  font-size: 13px !important;
}

.ai-appraisal-comment .upgrade-prompt.expert-review a {
  background: #d4af37 !important;
  color: white !important;
}

.ai-appraisal-comment .upgrade-prompt.free-user a {
  background: #38a169 !important;
  color: white !important;
}

.ai-appraisal-comment .next-action {
  text-align: center !important;
  padding-top: 10px !important;
}

.ai-appraisal-comment .next-action p {
  margin: 0 0 12px 0 !important;
  font-size: 14px !important;
  color: #718096 !important;
}

.ai-appraisal-comment .next-action > a {
  display: inline-block !important;
  background: linear-gradient(135deg, #d4af37 0%, #b8931f 100%) !important;
  color: white !important;
  padding: 12px 28px !important;
  border-radius: 50px !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3) !important;
}

/* ============================================
   SIMILAR ITEMS SECTION (new format only)
   ============================================ */

.ai-appraisal-comment .similar-items-section {
  background: #f7fafc !important;
  padding: 15px !important;
  border-radius: 8px !important;
  margin-top: 15px !important;
}

.ai-appraisal-comment .similar-items-section p:first-child {
  margin: 0 0 10px 0 !important;
  font-weight: 600 !important;
}

.ai-appraisal-comment .similar-items-section ul {
  margin: 0 !important;
  padding-left: 20px !important;
  background: transparent !important;
}

/* ============================================
   LINKS
   ============================================ */

.ai-appraisal-comment a {
  color: #2c5282 !important;
  text-decoration: none !important;
}

.ai-appraisal-comment a:hover {
  color: #1a365d !important;
  text-decoration: underline !important;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

@media (max-width: 600px) {
  .ai-appraisal-comment .social-proof-counter {
    flex-direction: column !important;
    gap: 0.75rem !important;
    padding: 10px 12px !important;
  }

  .ai-appraisal-comment .social-proof-counter > div {
    justify-content: center !important;
  }

  .ai-appraisal-comment h1,
  .ai-appraisal-comment h2 {
    font-size: 1.25rem !important;
  }

  .ai-appraisal-comment .upgrade-prompt {
    padding: 14px !important;
  }

  .ai-appraisal-comment > hr + p {
    padding: 14px 16px !important;
  }
}
