/* EditorJS Styles */

/* Editor Container */
[data-full-editor], [data-controller="editorjs"], [data-enhanced-editor], [data-direct-editor] {
  padding: 15px !important;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  min-height: 300px;
  margin-bottom: 1.5rem;
  background-color: white;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

[data-full-editor]:focus-within, [data-controller="editorjs"]:focus-within,
[data-enhanced-editor]:focus-within, [data-direct-editor]:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Editor structure */
.codex-editor {
  width: 100% !important;
  position: relative;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  margin: 0 !important;
  z-index: 1;
}

.codex-editor__redactor {
  padding-bottom: 150px !important;
  position: relative;
  box-sizing: border-box;
  margin: 0 !important;
  width: 100% !important;
}

.ce-block__content, .ce-toolbar__content {
  max-width: 850px !important;
  margin: 0 auto !important;
  position: relative;
}

/* Block styling */
.cdx-block {
  max-width: 100% !important;
}

/* Make sure code blocks have proper background */
.ce-code {
  background-color: #f8f9fa;
  font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 4px;
  border: 1px solid #e8e8eb;
  color: #41314e;
}

/* Paragraph styling */
.ce-paragraph {
  line-height: 1.6;
  outline: none;
  padding: 0.5em 0;
}

/* Header styling */
.ce-header {
  margin: 1em 0 0.5em;
  padding: 0;
  line-height: 1.4;
  outline: none;
  font-weight: 700;
}

h1.ce-header {
  font-size: 2em;
}

h2.ce-header {
  font-size: 1.5em;
}

h3.ce-header {
  font-size: 1.3em;
}

/* List styling */
.cdx-list {
  margin: 0.5em 0;
  padding-left: 40px;
  outline: none;
}

.cdx-list__item {
  line-height: 1.6em;
  padding: 5px 0;
}

/* Quote styling */
.cdx-quote {
  padding: 1em 1.5em;
  border-left: 4px solid #e8e8eb;
  margin: 1em 0;
  background: #f9f9fb;
  border-radius: 0 4px 4px 0;
}

.cdx-quote__text {
  font-style: italic;
  margin-bottom: 10px;
}

.cdx-quote__caption {
  font-size: 0.9em;
  color: #707684;
}

/* Image styling */
.cdx-block.image-tool {
  margin: 1.5em 0;
}

.image-tool__image {
  border-radius: 4px;
  overflow: hidden;
}

.image-tool__image-picture {
  max-width: 100%;
  height: auto;
}

.image-tool__caption {
  margin-top: 8px;
  font-size: 0.9em;
  color: #707684;
  text-align: center;
}

/* Table styling */
.tc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.tc-table__wrap {
  overflow-x: auto;
  padding: 0;
  margin: 0;
}

.tc-table tr {
  border-bottom: 1px solid #e8e8eb;
}

.tc-table td, .tc-table th {
  border: 1px solid #e8e8eb;
  padding: 10px;
  vertical-align: top;
}

.tc-table th {
  background-color: #f9f9fb;
  font-weight: bold;
}

/* Link styling */
.link-tool__content a {
  color: #388ae5;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-tool__content a:hover {
  text-decoration: none;
}

.link-tool__content--rendered {
  border: 1px solid #e8e8eb;
  border-radius: 6px;
  padding: 15px;
  margin: 10px 0;
  display: block;
  text-decoration: none !important;
  color: inherit !important;
  background-color: #f9f9fb;
}

/* Toolbar styling */
.ce-toolbar__plus, .ce-toolbar__settings-btn {
  color: #707684;
  background: #f9f9fb;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ce-toolbar__plus:hover, .ce-toolbar__settings-btn:hover {
  background-color: #e7f2ff;
  color: #3b82f6;
}

/* Conversion Toolbar */
.ce-conversion-toolbar {
  background: white;
  border: 1px solid #e8e8eb;
  box-shadow: 0 3px 15px -3px rgba(13, 20, 33, 0.13);
  border-radius: 6px;
  padding: 6px;
}

.ce-conversion-tool {
  padding: 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  color: #707684;
}

.ce-conversion-tool:hover {
  background-color: #f1f5f9;
  color: #1a202c;
}

.ce-conversion-tool--focused {
  background-color: #e7f2ff;
  color: #3b82f6;
}

/* Placeholder styling */
.ce-paragraph[data-placeholder]:empty::before {
  color: #adb5bd;
  font-style: italic;
}

/* Editor fallback styling */
.editor-fallback {
  padding: 1rem;
  color: #6b7280;
  font-style: italic;
}

/* Fix for Editor.js toolbar positioning */
.ce-toolbar {
  position: sticky !important;
  background-color: rgba(255, 255, 255, 0.97);
  z-index: 5;
}

/* Popups */
.ce-inline-toolbar, .ce-settings {
  background-color: white;
  border: 1px solid #e8e8eb;
  box-shadow: 0 3px 15px -3px rgba(13, 20, 33, 0.13);
  border-radius: 8px;
  z-index: 6;
}

/* Animation for toolbar */
.ce-block:hover .ce-block__content {
  background-color: rgba(240, 245, 255, 0.1);
}

/* Make sure editor is visible */
[data-controller="editorjs"] .codex-editor,
[data-enhanced-editor] .codex-editor,
[data-direct-editor] .codex-editor,
[data-full-editor] .codex-editor {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* RTL support for Editor.js */
.codex-editor[dir="rtl"] {
  direction: rtl !important;
  text-align: right !important;
}

.codex-editor[dir="rtl"] .ce-toolbar__plus {
  right: -34px !important;
  left: auto !important;
}

.codex-editor[dir="rtl"] .ce-toolbar__actions {
  right: auto !important;
  left: -34px !important;
}

.codex-editor[dir="rtl"] .ce-block__content {
  text-align: right !important;
  direction: rtl !important;
}

.codex-editor[dir="rtl"] .cdx-list {
  padding-right: 40px !important;
  padding-left: 0 !important;
  text-align: right !important;
  direction: rtl !important;
}

.codex-editor[dir="rtl"] .cdx-quote {
  border-left: none !important;
  border-right: 4px solid #e8e8eb !important;
  padding-left: 1em !important;
  padding-right: 1.5em !important;
  border-radius: 4px 0 0 4px !important;
  text-align: right !important;
  direction: rtl !important;
}

.codex-editor[dir="rtl"] .ce-paragraph,
.codex-editor[dir="rtl"] .ce-header {
  text-align: right !important;
  direction: rtl !important;
}

/* Strong RTL overrides */
body[dir="rtl"] .notion-renderer,
html[dir="rtl"] .notion-renderer,
.notion-renderer[dir="rtl"] {
  direction: rtl !important;
  text-align: right !important;
}

.notion-renderer[dir="rtl"] p,
.notion-renderer[dir="rtl"] h1,
.notion-renderer[dir="rtl"] h2,
.notion-renderer[dir="rtl"] h3,
.notion-renderer[dir="rtl"] h4,
.notion-renderer[dir="rtl"] h5,
.notion-renderer[dir="rtl"] h6 {
  text-align: right !important;
  direction: rtl !important;
}

/* Force RTL for specific blocks in notion-renderer */
[dir="rtl"] .notion-renderer ul,
[dir="rtl"] .notion-renderer ol {
  padding-right: 40px !important;
  padding-left: 0 !important;
  text-align: right !important;
}

[dir="rtl"] .notion-renderer blockquote {
  border-left: none !important;
  border-right: 4px solid #e8e8eb !important;
  padding-left: 1em !important;
  padding-right: 1.5em !important;
  text-align: right !important;
}

/* Smooth transition styles */
.codex-editor,
.ce-paragraph,
.ce-header,
.cdx-list,
.cdx-quote {
  transition: direction 0.3s ease-in-out, text-align 0.3s ease-in-out, padding 0.3s ease-in-out;
}

/* Mobile responsive styling */
@media (max-width: 650px) {
  .ce-block__content, .ce-toolbar__content {
    max-width: calc(100% - 40px) !important;
  }
  
  .ce-toolbar__plus {
    margin-left: 0 !important;
  }
  
  .ce-toolbar__actions {
    right: 0 !important;
  }
  
  .codex-editor[dir="rtl"] .ce-toolbar__plus {
    margin-right: 0 !important;
  }
  
  .codex-editor[dir="rtl"] .ce-toolbar__actions {
    left: 0 !important;
    right: auto !important;
  }
}