/* ========================================
   AI CARD COMPONENTS
   Modern design system for blog HTML mode
   Inspired by: ChatGPT, Notion, Apple Developer, Stripe Docs
   ======================================== */

:root {
  --ai-radius: 24px;
  --ai-radius-sm: 16px;
  --ai-radius-xs: 12px;
  --ai-shadow: 0 2px 8px rgba(11, 95, 255, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --ai-shadow-lg: 0 8px 24px rgba(11, 95, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  --ai-border: #E5E7EB;
  --ai-blue: #0B5FFF;
  --ai-blue-light: #EEF3FF;
  --ai-purple: #8B5CF6;
  --ai-purple-light: #F3F0FF;
  --ai-green: #22C55E;
  --ai-green-light: #F0FDF4;
  --ai-orange: #F97316;
  --ai-orange-light: #FFF7ED;
  --ai-red: #EF4444;
  --ai-red-light: #FEF2F2;
  --ai-gray: #6B7280;
  --ai-gray-light: #F9FAFB;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ai-border: #374151;
    --ai-blue-light: #1E3A8A;
    --ai-purple-light: #4C1D95;
    --ai-green-light: #14532D;
    --ai-orange-light: #7C2D12;
    --ai-red-light: #7F1D1D;
    --ai-gray-light: #1F2937;
  }
}

/* ========================================
   BASE CARD COMPONENT
   ======================================== */

.ai-card {
  background: #fff;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  margin: 24px 0;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-card:hover {
  box-shadow: var(--ai-shadow-lg);
  transform: translateY(-2px);
}

.ai-card-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--ai-border);
  background: var(--ai-gray-light);
}

.ai-card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1e2a3d;
}

.ai-card-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ai-gray);
}

.ai-card-body {
  padding: 28px;
  line-height: 1.75;
}

.ai-card-body > *:first-child {
  margin-top: 0;
}

.ai-card-body > *:last-child {
  margin-bottom: 0;
}

.ai-card-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--ai-border);
  background: var(--ai-gray-light);
  font-size: 14px;
  color: var(--ai-gray);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .ai-card {
    background: #1F2937;
    border-color: var(--ai-border);
  }
  .ai-card-title {
    color: #F9FAFB;
  }
  .ai-card-header,
  .ai-card-footer {
    background: #111827;
  }
}

/* ========================================
   GRID LAYOUT
   ======================================== */

.ai-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 24px 0;
}

@media (min-width: 640px) {
  .ai-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .ai-grid.ai-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ai-column {
  background: #fff;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-sm);
  padding: 24px;
  box-shadow: var(--ai-shadow);
}

@media (prefers-color-scheme: dark) {
  .ai-column {
    background: #1F2937;
  }
}

/* ========================================
   BADGES
   ======================================== */

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.ai-badge.success {
  background: var(--ai-green-light);
  color: #15803d;
  border: 1px solid #22C55E;
}

.ai-badge.warning {
  background: var(--ai-orange-light);
  color: #c2410c;
  border: 1px solid #F97316;
}

.ai-badge.danger {
  background: var(--ai-red-light);
  color: #b91c1c;
  border: 1px solid #EF4444;
}

.ai-badge.info {
  background: var(--ai-blue-light);
  color: #1e40af;
  border: 1px solid var(--ai-blue);
}

.ai-badge.note {
  background: var(--ai-purple-light);
  color: #6b21a8;
  border: 1px solid var(--ai-purple);
}

/* Dark mode badges */
@media (prefers-color-scheme: dark) {
  .ai-badge.success {
    color: #86efac;
  }
  .ai-badge.warning {
    color: #fdba74;
  }
  .ai-badge.danger {
    color: #fca5a5;
  }
  .ai-badge.info {
    color: #93c5fd;
  }
  .ai-badge.note {
    color: #d8b4fe;
  }
}

/* ========================================
   CALLOUT COMPONENT
   ======================================== */

.ai-callout {
  display: flex;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--ai-radius-sm);
  margin: 24px 0;
  border-left: 4px solid;
}

.ai-callout-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}

.ai-callout-content {
  flex: 1;
}

.ai-callout-content h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.ai-callout-content p:first-of-type {
  margin-top: 0;
}

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

/* Callout variants */
.ai-callout.info {
  background: var(--ai-blue-light);
  border-left-color: var(--ai-blue);
}

.ai-callout.warning {
  background: var(--ai-orange-light);
  border-left-color: var(--ai-orange);
}

.ai-callout.danger {
  background: var(--ai-red-light);
  border-left-color: var(--ai-red);
}

.ai-callout.success {
  background: var(--ai-green-light);
  border-left-color: var(--ai-green);
}

.ai-callout.tip {
  background: var(--ai-purple-light);
  border-left-color: var(--ai-purple);
}

/* ========================================
   COMPARE / TWO-COLUMN LAYOUT
   ======================================== */

.ai-compare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 24px 0;
}

@media (min-width: 768px) {
  .ai-compare {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ai-compare .ai-column {
  position: relative;
}

.ai-compare .ai-column h3 {
  margin-top: 0;
  font-size: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ai-border);
}

/* ========================================
   TIMELINE / STEPS
   ======================================== */

.ai-timeline {
  margin: 32px 0;
  padding-left: 0;
  list-style: none;
}

.ai-step {
  position: relative;
  padding-left: 56px;
  padding-bottom: 32px;
}

.ai-step:last-child {
  padding-bottom: 0;
}

.ai-step::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 40px;
  bottom: -8px;
  width: 2px;
  background: var(--ai-border);
}

.ai-step:last-child::before {
  display: none;
}

.ai-step-number {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ai-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(11, 95, 255, 0.3);
}

.ai-step-content h4 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.ai-step-content p {
  margin: 0;
  color: var(--ai-gray);
  line-height: 1.6;
}

/* ========================================
   FAQ COMPONENT
   ======================================== */

.ai-faq {
  margin: 24px 0;
}

.ai-faq-item {
  background: #fff;
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-sm);
  padding: 20px 24px;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.ai-faq-item:hover {
  box-shadow: var(--ai-shadow);
  transform: translateY(-2px);
}

.ai-faq-question {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ai-blue);
}

.ai-faq-answer {
  color: #1e2a3d;
  line-height: 1.6;
}

.ai-faq-answer p:first-child {
  margin-top: 0;
}

.ai-faq-answer p:last-child {
  margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
  .ai-faq-item {
    background: #1F2937;
  }
  .ai-faq-answer {
    color: #E5E7EB;
  }
}

/* ========================================
   TABLE COMPONENT
   ======================================== */

.ai-table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
  border-radius: var(--ai-radius-sm);
  border: 1px solid var(--ai-border);
  box-shadow: var(--ai-shadow);
}

.ai-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 15px;
}

.ai-table thead {
  background: var(--ai-gray-light);
  border-bottom: 2px solid var(--ai-border);
}

.ai-table th {
  padding: 16px 20px;
  text-align: left;
  font-weight: 700;
  font-size: 14px;
  color: #1e2a3d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-table td {
  padding: 16px 20px;
  border-top: 1px solid var(--ai-border);
}

.ai-table tbody tr {
  transition: background 0.15s;
}

.ai-table tbody tr:hover {
  background: var(--ai-gray-light);
}

@media (prefers-color-scheme: dark) {
  .ai-table {
    background: #1F2937;
  }
  .ai-table th {
    color: #F9FAFB;
  }
  .ai-table thead {
    background: #111827;
  }
}

/* ========================================
   CODE BLOCK
   ======================================== */

.ai-code {
  margin: 24px 0;
  border-radius: var(--ai-radius-sm);
  overflow: hidden;
  border: 1px solid var(--ai-border);
  box-shadow: var(--ai-shadow);
}

.ai-code-header {
  background: #1F2937;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-code-lang {
  font-size: 13px;
  font-weight: 600;
  color: #9CA3AF;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-code pre {
  margin: 0;
  padding: 20px;
  background: #111827;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
}

.ai-code code {
  color: #E5E7EB;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

/* ========================================
   IMAGE COMPONENT
   ======================================== */

.ai-image {
  margin: 32px 0;
}

.ai-image img {
  width: 100%;
  height: auto;
  border-radius: var(--ai-radius-sm);
  box-shadow: var(--ai-shadow);
  border: 1px solid var(--ai-border);
}

.ai-image-caption {
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  color: var(--ai-gray);
  font-style: italic;
}

/* ========================================
   HIGHLIGHT BOX
   ======================================== */

.ai-highlight {
  background: linear-gradient(135deg, var(--ai-blue-light) 0%, var(--ai-purple-light) 100%);
  border: 2px solid var(--ai-blue);
  border-radius: var(--ai-radius);
  padding: 28px 32px;
  margin: 32px 0;
  box-shadow: var(--ai-shadow-lg);
}

.ai-highlight h3 {
  margin-top: 0;
  color: var(--ai-blue);
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

@media (max-width: 640px) {
  .ai-card-body,
  .ai-card-header,
  .ai-card-footer {
    padding-left: 20px;
    padding-right: 20px;
  }
  
  .ai-callout {
    padding: 16px 20px;
  }
  
  .ai-column {
    padding: 20px;
  }
  
  .ai-step {
    padding-left: 48px;
  }
  
  .ai-step-number {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* ========================================
   TYPOGRAPHY ENHANCEMENTS
   ======================================== */

.ai-card h1,
.ai-card h2,
.ai-card h3,
.ai-card h4 {
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.ai-card p {
  margin: 16px 0;
  line-height: 1.75;
}

.ai-card ul,
.ai-card ol {
  margin: 16px 0;
  padding-left: 28px;
}

.ai-card li {
  margin: 8px 0;
  line-height: 1.6;
}

.ai-card a {
  color: var(--ai-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: opacity 0.15s;
}

.ai-card a:hover {
  opacity: 0.7;
}

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

.ai-card:focus-within {
  outline: 2px solid var(--ai-blue);
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .ai-card,
  .ai-faq-item,
  .ai-step-number {
    transition: none;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .ai-card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .ai-code {
    page-break-inside: avoid;
  }
}
