/**
 * Custom Styling untuk CKEditor 5
 * Menggantikan TinyMCE dengan tampilan yang konsisten
 */

/* Container CKEditor */
.ck-editor {
  margin-bottom: 1rem;
}

.ck-editor .ck-editor__main {
  min-height: 600px !important;
}

.ck-editor .ck-editor__main .ck-content {
  min-height: 600px !important;
}

/* Toolbar styling */
.ck.ck-toolbar {
  background-color: #f8f9fa !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 0.375rem 0.375rem 0 0 !important;
  padding: 0.5rem !important;
}

/* Editor content area */
.ck.ck-editor__main > .ck-editor__editable {
  min-height: 600px !important;
  max-height: none !important;
  height: auto !important;
  border: 1px solid #dee2e6 !important;
  border-top: none !important;
  border-radius: 0 0 0.375rem 0.375rem !important;
  padding: 1rem !important;
  background-color: #ffffff !important;
}

/* Force height untuk desktop */
@media (min-width: 768px) {
  .ck.ck-editor__main > .ck-editor__editable {
    min-height: calc(100vh - 350px) !important;
  }
}

/* Fokus state */
.ck.ck-editor__main > .ck-editor__editable:focus {
  border-color: #86b7fe !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Konten dalam editor */
.ck-content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.2;
  color: #212529;
}

/* Heading styles dalam editor */
.ck-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.ck-content h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.ck-content h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.ck-content h4 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

/* Paragraph spacing */
.ck-content p {
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

/* List styling */
.ck-content ul,
.ck-content ol {
  margin-left: 1.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.ck-content li {
  margin-bottom: 0.1rem;
  line-height: 1.2;
}

/* Table styling */
.ck-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
}

.ck-content table td,
.ck-content table th {
  border: 1px solid #dee2e6;
  padding: 0.5rem;
}

.ck-content table th {
  background-color: #f8f9fa;
  font-weight: 600;
}

/* Image styling */
.ck-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  margin: 0.5rem 0;
}

/* Blockquote styling */
.ck-content blockquote {
  border-left: 4px solid #0d6efd;
  padding-left: 1rem;
  margin-left: 0;
  margin-right: 0;
  font-style: italic;
  color: #6c757d;
}

/* Code block styling */
.ck-content pre {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
}

.ck-content code {
  background-color: #f8f9fa;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  color: #d63384;
}

/* Link styling */
.ck-content a {
  color: #0d6efd;
  text-decoration: underline;
}

.ck-content a:hover {
  color: #0a58ca;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ck.ck-toolbar {
    flex-wrap: wrap;
  }
  
  .ck.ck-editor__main > .ck-editor__editable {
    min-height: calc(100vh - 400px);
  }
}

/* Loading state */
.ck-editor-loading {
  position: relative;
  min-height: 400px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ck-editor-loading::after {
  content: "Memuat editor...";
  color: #6c757d;
  font-size: 1rem;
}

/* Upload progress indicator */
.ck-upload-placeholder {
  background-color: #f8f9fa !important;
  border: 2px dashed #dee2e6 !important;
  padding: 1rem !important;
  text-align: center !important;
}

/* Dropdown menu styling */
.ck.ck-dropdown__panel {
  max-height: 400px;
  overflow-y: auto;
}

/* Balloon toolbar (untuk inline editing) */
.ck.ck-balloon-panel {
  z-index: 1050 !important;
}


/* Spacing yang lebih rapat untuk soal CBT */
.ck-content * {
  line-height: 1.2 !important;
}

.ck-content p + p {
  margin-top: 0.1rem;
}

.ck-content br {
  line-height: 1.2;
}

/* Opsi jawaban dengan spacing rapat */
.ck-content p:has(> strong:first-child) {
  margin-bottom: 0.1rem;
  line-height: 1.2;
}

/* Untuk konten yang di-paste dari Word */
.ck-content [style*="line-height"] {
  line-height: 1.2 !important;
}

/* Override default spacing */
.ck.ck-editor__editable .ck-content {
  line-height: 1.2 !important;
}

.ck.ck-editor__editable .ck-content p {
  margin-top: 0;
  margin-bottom: 0.25rem;
  line-height: 1.2 !important;
}

.ck.ck-editor__editable .ck-content div {
  line-height: 1.2 !important;
}


/* Force minimum height - Priority tinggi */
.ck.ck-reset.ck-editor {
  min-height: 600px !important;
}

.ck.ck-reset.ck-editor .ck-editor__main {
  min-height: 600px !important;
}

.ck.ck-reset.ck-editor .ck-editor__main > .ck-editor__editable {
  min-height: 600px !important;
  height: auto !important;
}

/* Untuk layar besar */
@media (min-width: 1200px) {
  .ck.ck-reset.ck-editor .ck-editor__main > .ck-editor__editable {
    min-height: 700px !important;
  }
}

/* Override semua style yang mungkin konflik */
.ck-editor__editable_inline {
  min-height: 600px !important;
}

div[role="textbox"] {
  min-height: 600px !important;
}
