/* Rich Text Editor Styles */

/* Контейнер для описания в модальном окне */
.rich-text-description-container {
  position: relative;
  margin: 0;
  min-height: 100px;
  width: 100%;
  pointer-events: auto !important; /* Явно разрешаем клики */
  z-index: 1; /* Убеждаемся, что контейнер выше других элементов */
}

.task-description {
  margin: 0;
  padding: 8px;
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  word-break: break-word;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 24px;
}

.task-description:hover {
  background: rgba(0, 0, 0, 0.02);
}

.task-description:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-tertiary);
  font-style: italic;
}

.rich-text-view {
  padding: 8px;
  border-radius: var(--radius-sm);
  min-height: 24px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.rich-text-view:hover {
  background: rgba(0, 0, 0, 0.02);
}

.rich-text-placeholder {
  color: var(--color-text-tertiary);
  font-style: italic;
}

.rich-text-edit-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.task-description-container:hover .rich-text-edit-btn {
  opacity: 1;
}

.rich-text-edit-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Режим редактирования */
.rich-text-editing .rich-text-view,
.rich-text-editing .rich-text-edit-btn {
  display: none;
}

.rich-text-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--color-bg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: none;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--color-text);
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

.toolbar-btn:active {
  background: rgba(0, 0, 0, 0.1);
}

.toolbar-btn strong {
  font-weight: bold;
}

.toolbar-btn em {
  font-style: italic;
}

.toolbar-btn u {
  text-decoration: underline;
}

.toolbar-btn-save {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  margin-left: auto;
}

.toolbar-btn-save:hover {
  background: #005a8f;
  border-color: #005a8f;
}

.toolbar-btn-cancel {
  background: transparent;
  color: var(--color-text-secondary);
}

.toolbar-btn-cancel:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text);
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 4px;
}

.toolbar-select {
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  font-size: 12px;
  background: white;
  cursor: pointer;
  height: 28px;
  min-width: 60px;
}

.toolbar-select:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

.toolbar-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(0, 121, 191, 0.1);
}

.rich-text-editor {
  min-height: 100px;
  /* max-height убран для авто-растягивания */
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  pointer-events: auto !important; /* Явно разрешаем клики */
  cursor: text !important; /* Явно указываем курсор текста */
  border-top: none;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text);
  background: white;
  overflow-y: auto; /* Показываем scrollbar только если нужно */
  outline: none;
  word-break: break-word;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  resize: none; /* Отключаем ручное изменение размера, используем авто-растягивание */
}

.rich-text-editor:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 121, 191, 0.1);
}

.rich-text-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-tertiary);
  font-style: italic;
}

/* Стили для отформатированного текста */
.rich-text-editor strong,
.rich-text-view strong {
  font-weight: bold;
}

.rich-text-editor em,
.rich-text-view em {
  font-style: italic;
}

.rich-text-editor u,
.rich-text-view u {
  text-decoration: underline;
}

.rich-text-editor ul,
.rich-text-view ul {
  margin: 8px 0;
  padding-left: 24px;
  list-style-type: disc;
}

.rich-text-editor ol,
.rich-text-view ol {
  margin: 8px 0;
  padding-left: 24px;
  list-style-type: decimal;
}

.rich-text-editor li,
.rich-text-view li {
  margin: 4px 0;
}

.rich-text-editor a,
.rich-text-view a {
  color: var(--color-primary);
  text-decoration: underline;
}

.rich-text-editor a:hover,
.rich-text-view a:hover {
  color: #005a8f;
}

.rich-text-editor code,
.rich-text-view code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.rich-text-editor pre,
.rich-text-view pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.rich-text-editor pre code,
.rich-text-view pre code {
  background: transparent;
  padding: 0;
}

/* Размеры шрифта */
.rich-text-editor[style*="font-size: 10px"],
.rich-text-view[style*="font-size: 10px"] {
  font-size: 10px !important;
}

.rich-text-editor[style*="font-size: 12px"],
.rich-text-view[style*="font-size: 12px"] {
  font-size: 12px !important;
}

.rich-text-editor[style*="font-size: 14px"],
.rich-text-view[style*="font-size: 14px"] {
  font-size: 14px !important;
}

.rich-text-editor[style*="font-size: 16px"],
.rich-text-view[style*="font-size: 16px"] {
  font-size: 16px !important;
}

.rich-text-editor[style*="font-size: 18px"],
.rich-text-view[style*="font-size: 18px"] {
  font-size: 18px !important;
}

.rich-text-editor[style*="font-size: 20px"],
.rich-text-view[style*="font-size: 20px"] {
  font-size: 20px !important;
}

.rich-text-editor[style*="font-size: 24px"],
.rich-text-view[style*="font-size: 24px"] {
  font-size: 24px !important;
}

