/**
 * Editor.js Content Rendering Styles
 * Sistema de Design Moderno - Compatível com template_post.html
 * Estilos para renderização do conteúdo JSON do Editor.js em HTML
 */

/* =============================================
   Container Principal
   ============================================= */
.editorjs-content {
  max-width: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: hsl(var(--foreground));
}

.editorjs-content > *:first-child {
  margin-top: 0;
}

.editorjs-content > *:last-child {
  margin-bottom: 0;
}

/* =============================================
   Paragraph
   ============================================= */
.ejs-paragraph {
  margin: 1.5rem 0;
  line-height: 1.6;
  color: hsl(var(--foreground));
}

.ejs-paragraph:empty {
  display: none;
}

/* =============================================
   Headers
   ============================================= */
.ejs-header {
  font-weight: 600;
  color: hsl(var(--foreground));
  margin: 2rem 0 1rem;
  line-height: 1.3;
}

.ejs-header-1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-top: 0;
}

.ejs-header-2 {
  font-size: 1.875rem;
  font-weight: 700;
}

.ejs-header-3 {
  font-size: 1.5rem;
  font-weight: 600;
}

.ejs-header-4 {
  font-size: 1.25rem;
  font-weight: 600;
}

.ejs-header-5 {
  font-size: 1.125rem;
  font-weight: 600;
}

.ejs-header-6 {
  font-size: 1rem;
  font-weight: 600;
}

/* =============================================
   Lists
   ============================================= */
.ejs-list {
  margin: 1.5rem 0;
  padding-left: 1.5rem;
}

.ejs-list li {
  margin: 0.5rem 0;
  line-height: 1.6;
  color: hsl(var(--foreground));
}

.ejs-list li::marker {
  color: hsl(var(--brand));
  font-weight: 600;
}

.ejs-list-ordered {
  list-style-type: decimal;
}

.ejs-list-unordered {
  list-style-type: disc;
}

/* Nested lists */
.ejs-list li ul,
.ejs-list li ol {
  margin: 0.5rem 0;
}

/* =============================================
   Checklist
   ============================================= */
.ejs-checklist {
  margin: 1.5rem 0;
}

.ejs-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.75rem 0;
  line-height: 1.6;
}

.ejs-checklist-item input[type="checkbox"] {
  margin-top: 0.3rem;
  width: 18px;
  height: 18px;
  cursor: default;
  accent-color: hsl(var(--brand));
  border-radius: 4px;
}

.ejs-checklist-item input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  opacity: 0.6;
  color: hsl(var(--muted-foreground));
}

/* =============================================
   Quote
   ============================================= */
.ejs-quote {
  margin: 2rem 0;
  padding: 1.5rem;
  border-left: 4px solid hsl(var(--brand));
  background: hsl(var(--secondary));
  border-radius: 0 var(--radius) var(--radius) 0;
}

.ejs-quote p {
  margin: 0;
  font-size: 1.125rem;
  font-style: italic;
  line-height: 1.6;
  color: hsl(var(--foreground));
}

.ejs-quote cite {
  display: block;
  margin-top: 1rem;
  font-size: 0.875rem;
  font-style: normal;
  color: hsl(var(--muted-foreground));
}

.ejs-quote cite::before {
  content: '— ';
}

.ejs-quote-center {
  text-align: center;
  border-left: none;
  border-top: 4px solid hsl(var(--brand));
  border-radius: var(--radius);
}

.ejs-quote-right {
  text-align: right;
  border-left: none;
  border-right: 4px solid hsl(var(--brand));
  border-radius: var(--radius) 0 0 var(--radius);
}

/* =============================================
   Warning
   ============================================= */
.ejs-warning {
  margin: 2rem 0;
  padding: 1.5rem;
  background: hsl(var(--warning) / 0.1);
  border: 1px solid hsl(var(--warning) / 0.3);
  border-left: 4px solid hsl(var(--warning));
  border-radius: var(--radius);
  color: hsl(var(--warning-foreground));
}

.ejs-warning-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: hsl(var(--foreground));
}

.ejs-warning-title::before {
  content: '⚠️';
  font-size: 1.2em;
}

.ejs-warning-message {
  line-height: 1.6;
  color: hsl(var(--foreground));
}

/* Dark mode */
.dark .ejs-warning {
  background: hsl(var(--warning) / 0.15);
  border-color: hsl(var(--warning) / 0.3);
}

/* =============================================
   Delimiter
   ============================================= */
.ejs-delimiter {
  margin: 3rem 0;
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  color: hsl(var(--muted-foreground));
}

/* =============================================
   Table
   ============================================= */
.ejs-table-wrapper {
  margin: 2rem 0;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}

.ejs-table {
  width: 100%;
  border-collapse: collapse;
  background: hsl(var(--card));
}

.ejs-table th,
.ejs-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--card-foreground));
}

.ejs-table th {
  background: hsl(var(--secondary));
  font-weight: 600;
  color: hsl(var(--foreground));
  font-size: 0.875rem;
}

.ejs-table tr:hover {
  background: hsl(var(--secondary) / 0.5);
}

/* =============================================
   Code
   ============================================= */
.ejs-code {
  margin: 2rem 0;
  padding: 1.5rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}

.ejs-code code {
  color: hsl(var(--foreground));
}

/* Dark mode */
.dark .ejs-code {
  background: hsl(var(--muted));
}

/* =============================================
   Raw HTML
   ============================================= */
.ejs-raw {
  margin: 2rem 0;
}

/* =============================================
   Image
   ============================================= */
.ejs-image {
  margin: 2.5rem 0;
  text-align: center;
}

.ejs-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 0 auto;
}

.ejs-image figcaption {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.ejs-image-border img {
  border: 1px solid hsl(var(--border));
  padding: 0.5rem;
}

.ejs-image-background {
  background: hsl(var(--secondary));
  padding: 1rem;
  border-radius: var(--radius);
}

.ejs-image-stretched img {
  width: 100%;
  max-width: 100%;
}

/* =============================================
   Embed
   ============================================= */
.ejs-embed {
  margin: 2.5rem 0;
}

.ejs-embed-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 ratio */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
}

.ejs-embed-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
}

.ejs-embed-caption {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* =============================================
   Link Tool (Card Preview)
   ============================================= */
.ejs-link {
  display: flex;
  margin: 2rem 0;
  text-decoration: none;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s;
  background: hsl(var(--card));
}

.ejs-link:hover {
  border-color: hsl(var(--brand));
  box-shadow: 0 4px 12px hsl(var(--brand) / 0.15);
  transform: translateY(-2px);
}

.ejs-link-image {
  flex-shrink: 0;
  width: 200px;
  height: 150px;
  overflow: hidden;
  background: hsl(var(--secondary));
}

.ejs-link-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ejs-link-content {
  flex: 1;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ejs-link-title {
  font-weight: 600;
  font-size: 1.1rem;
  color: hsl(var(--foreground));
  line-height: 1.4;
}

.ejs-link-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ejs-link-url {
  font-size: 0.75rem;
  color: hsl(var(--brand));
  margin-top: auto;
}

/* =============================================
   Inline Elements
   ============================================= */
.editorjs-content a {
  color: hsl(var(--brand));
  text-decoration: underline;
  text-decoration-color: hsl(var(--brand) / 0.3);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  transition: all 0.2s;
}

.editorjs-content a:hover {
  text-decoration-color: hsl(var(--brand));
}

.editorjs-content strong,
.editorjs-content b {
  font-weight: 700;
  color: hsl(var(--foreground));
}

.editorjs-content em,
.editorjs-content i {
  font-style: italic;
}

.editorjs-content code {
  padding: 0.2em 0.4em;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.875em;
  color: hsl(var(--brand));
}

.editorjs-content mark {
  background: hsl(var(--warning) / 0.2);
  padding: 0 0.2em;
  border-radius: 2px;
}

/* =============================================
   Botões CTA (Call-to-Action) do Editor.js
   ============================================= */
.ejs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: background-color 0.2s, transform 0.1s;
  cursor: pointer;
  gap: 0.5rem;
  border: none;
  text-decoration: none;
  margin: 1rem 0;
}

.ejs-button-primary {
  background-color: hsl(var(--brand));
  color: hsl(var(--brand-foreground));
}

.ejs-button-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.ejs-button-outline {
  background-color: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

.ejs-button-outline:hover {
  background-color: hsl(var(--secondary));
}

/* =============================================
   Alert/Info Box
   ============================================= */
.ejs-alert {
  margin: 2rem 0;
  padding: 1.5rem;
  border-radius: var(--radius);
  border-left: 4px solid;
}

.ejs-alert-info {
  background: hsl(var(--info) / 0.1);
  border-color: hsl(var(--info));
  color: hsl(var(--foreground));
}

.ejs-alert-success {
  background: hsl(var(--success) / 0.1);
  border-color: hsl(var(--success));
  color: hsl(var(--foreground));
}

.ejs-alert-warning {
  background: hsl(var(--warning) / 0.1);
  border-color: hsl(var(--warning));
  color: hsl(var(--foreground));
}

.ejs-alert-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* =============================================
   Responsividade
   ============================================= */
@media (max-width: 1024px) {
  .ejs-header-1 {
    font-size: 1.875rem;
  }
  
  .ejs-header-2 {
    font-size: 1.5rem;
  }
  
  .ejs-header-3 {
    font-size: 1.25rem;
  }
}

@media (max-width: 768px) {
  .editorjs-content {
    font-size: 1rem;
  }
  
  .ejs-header-1 {
    font-size: 1.75rem;
  }
  
  .ejs-header-2 {
    font-size: 1.5rem;
  }
  
  .ejs-header-3 {
    font-size: 1.25rem;
  }
  
  .ejs-quote {
    padding: 1rem 1.25rem;
  }
  
  .ejs-list {
    padding-left: 1.25rem;
  }
  
  .ejs-table-wrapper {
    margin-left: -1rem;
    margin-right: -1rem;
    border-radius: 0;
  }
  
  .ejs-link {
    flex-direction: column;
  }
  
  .ejs-link-image {
    width: 100%;
    height: 180px;
  }
  
  .ejs-code {
    padding: 1rem;
    font-size: 0.8rem;
  }
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
  .editorjs-content {
    max-width: 100%;
    padding: 0;
    color: #000;
  }
  
  .ejs-image,
  .ejs-embed,
  .ejs-link {
    page-break-inside: avoid;
  }
  
  .ejs-link {
    border: 1px solid #ddd;
  }
  
  .ejs-link:hover {
    transform: none;
    box-shadow: none;
  }
  
  .ejs-button {
    border: 1px solid #000;
  }
}

/* =============================================
   Dark Mode Specific Adjustments
   ============================================= */
.dark .editorjs-content a {
  color: hsl(var(--brand));
}

.dark .ejs-table tr:hover {
  background: hsl(var(--muted) / 0.5);
}

.dark .ejs-image-background {
  background: hsl(var(--muted));
}

.dark .ejs-embed-wrapper {
  background: hsl(var(--muted));
}
