/* Render nội dung rich text (mô tả form, câu trả lời "Văn bản dài").
   Quill lưu canh lề và thụt đầu dòng bằng class ql-*, nên nơi nào render lại HTML
   đó cũng phải có các quy tắc này, không chỉ trong khung editor. */

.rich-text-content { font-size: 0.9rem; line-height: 1.6; color: #1e293b; word-break: break-word; }
.rich-text-content > *:first-child { margin-top: 0; }
.rich-text-content > *:last-child { margin-bottom: 0; }
.rich-text-content p { margin: 0 0 0.5em; }
.rich-text-content h1 { font-size: 1.3rem; }
.rich-text-content h2 { font-size: 1.15rem; }
.rich-text-content h3 { font-size: 1.02rem; }
.rich-text-content h1,
.rich-text-content h2,
.rich-text-content h3,
.rich-text-content h4,
.rich-text-content h5,
.rich-text-content h6 { margin: 0.6em 0 0.4em; font-weight: 600; line-height: 1.3; }
.rich-text-content ul,
.rich-text-content ol { margin: 0 0 0.5em; padding-left: 1.5em; }
.rich-text-content li { margin-bottom: 0.2em; }
.rich-text-content blockquote {
  margin: 0 0 0.5em; padding: 4px 0 4px 12px;
  border-left: 3px solid #cbd5e1; color: #475569;
}
.rich-text-content pre {
  margin: 0 0 0.5em; padding: 8px 10px; border-radius: 6px;
  background: #f1f5f9; font-size: 0.82rem; white-space: pre-wrap;
}
.rich-text-content code { background: #f1f5f9; padding: 1px 4px; border-radius: 4px; font-size: 0.85em; }
.rich-text-content a { color: #4f46e5; text-decoration: underline; }
.rich-text-content img { max-width: 100%; height: auto; }

/* Canh lề của Quill */
.rich-text-content .ql-align-center { text-align: center; }
.rich-text-content .ql-align-right { text-align: right; }
.rich-text-content .ql-align-justify { text-align: justify; }

/* Thụt đầu dòng: Quill cho tối đa 8 cấp, mỗi cấp 3em */
.rich-text-content .ql-indent-1 { padding-left: 3em; }
.rich-text-content .ql-indent-2 { padding-left: 6em; }
.rich-text-content .ql-indent-3 { padding-left: 9em; }
.rich-text-content .ql-indent-4 { padding-left: 12em; }
.rich-text-content .ql-indent-5 { padding-left: 15em; }
.rich-text-content .ql-indent-6 { padding-left: 18em; }
.rich-text-content .ql-indent-7 { padding-left: 21em; }
.rich-text-content .ql-indent-8 { padding-left: 24em; }

/* Khung editor khi người dùng đang trả lời câu hỏi văn bản dài */
.rich-text-field { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; background: #fff; }
.rich-text-field:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.08); }
.rich-text-field .ql-toolbar.ql-snow { border: none; border-bottom: 1px solid #e5e7eb; background: #f8fafc; padding: 5px 8px; }
.rich-text-field .ql-container.ql-snow { border: none; font-family: inherit; }
/* --rich-h là chiều cao TỐI THIỂU, không phải cố định: nội dung dài vẫn tự giãn
   thêm nên không bao giờ có thanh cuộn lồng trong ô trả lời. Tay kéo chỉ để mở
   sẵn vùng viết cho rộng, khỏi phải gõ trong một khe hẹp. */
.rich-text-field .ql-editor { min-height: var(--rich-h, 140px); font-size: 0.9rem; line-height: 1.6; }

.rich-text-resize {
  display: flex; align-items: center; justify-content: center;
  height: 14px; border-top: 1px solid #f1f5f9; background: #fbfcfe;
  cursor: ns-resize; user-select: none; touch-action: none;
}
.rich-text-resize:hover,
.rich-text-resize.is-dragging { background: #eef2ff; }
.rich-text-resize:focus-visible { outline: 2px solid #6366f1; outline-offset: -2px; }
.rich-text-grip { width: 34px; height: 3px; border-radius: 999px; background: #cbd5e1; }
.rich-text-resize:hover .rich-text-grip,
.rich-text-resize.is-dragging .rich-text-grip { background: #6366f1; }
.rich-text-field .ql-editor.ql-blank::before { font-style: normal; color: #9ca3af; left: 15px; right: 15px; }
.rich-text-counter { margin-top: 4px; font-size: 0.72rem; color: #9ca3af; text-align: right; }
.rich-text-counter.is-over { color: #dc2626; font-weight: 600; }

/* Chế độ chỉ xem: bỏ thanh công cụ, làm nền xám như input bị khoá */
.rich-text-field.is-readonly { background: #f8fafc; }
.rich-text-field.is-readonly .ql-toolbar.ql-snow { display: none; }
.rich-text-field.is-readonly .ql-editor { min-height: 0; }
.rich-text-field.is-readonly .rich-text-resize { display: none; }
