/*
 * Общие стили для контента, созданного rich-text-редактором (TinyMCE)
 * Применяются к .rich-content и к областям рендера контента из админки:
 * .program-rules-content, .stnew-task-modal-subject, и т.п.
 *
 * Главная задача — НЕ подавлять inline-стили (font-size, color, background-color),
 * которые редактор сохраняет напрямую в HTML.
 */

.rich-content,
.program-rules-content,
.stnew-task-modal-subject {
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Параграфы — глобальный сброс p { margin: 0 } перебиваем через !important */
.rich-content p,
.program-rules-content p,
.stnew-task-modal-subject p {
    margin: 0 0 12px 0 !important;
}

.rich-content p:last-child,
.program-rules-content p:last-child,
.stnew-task-modal-subject p:last-child {
    margin-bottom: 0 !important;
}

/* Заголовки */
.rich-content h1, .rich-content h2, .rich-content h3,
.rich-content h4, .rich-content h5, .rich-content h6,
.program-rules-content h1, .program-rules-content h2, .program-rules-content h3,
.program-rules-content h4, .program-rules-content h5, .program-rules-content h6,
.stnew-task-modal-subject h1, .stnew-task-modal-subject h2, .stnew-task-modal-subject h3,
.stnew-task-modal-subject h4, .stnew-task-modal-subject h5, .stnew-task-modal-subject h6 {
    margin: 16px 0 8px 0;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.rich-content h1, .program-rules-content h1, .stnew-task-modal-subject h1 { font-size: 1.6em; }
.rich-content h2, .program-rules-content h2, .stnew-task-modal-subject h2 { font-size: 1.4em; }
.rich-content h3, .program-rules-content h3, .stnew-task-modal-subject h3 { font-size: 1.25em; }
.rich-content h4, .program-rules-content h4, .stnew-task-modal-subject h4 { font-size: 1.1em; }
.rich-content h5, .program-rules-content h5, .stnew-task-modal-subject h5 { font-size: 1em; }
.rich-content h6, .program-rules-content h6, .stnew-task-modal-subject h6 { font-size: 0.9em; }

/* Списки
 * Глобальный сброс в mylayout.css (`ul li { list-style: none }`, `ul { padding:0; margin:0 }`)
 * слишком агрессивный. Используем !important чтобы вернуть нормальный рендер списков
 * только внутри контейнеров TinyMCE-контента.
 */
.rich-content ul, .rich-content ol,
.program-rules-content ul, .program-rules-content ol,
.stnew-task-modal-subject ul, .stnew-task-modal-subject ol {
    margin: 0 0 12px 0 !important;
    padding-left: 28px !important;
    list-style-position: outside;
}

.rich-content ul, .rich-content ul li,
.program-rules-content ul, .program-rules-content ul li,
.stnew-task-modal-subject ul, .stnew-task-modal-subject ul li {
    list-style-type: disc !important;
}

.rich-content ol, .rich-content ol li,
.program-rules-content ol, .program-rules-content ol li,
.stnew-task-modal-subject ol, .stnew-task-modal-subject ol li {
    list-style-type: decimal !important;
}

.rich-content li,
.program-rules-content li,
.stnew-task-modal-subject li {
    margin: 4px 0;
    padding: 0;
    display: list-item !important;
    /* НЕ ставим font-size/color — пусть inline-стили работают */
}

/* Вложенные списки */
.rich-content ul ul, .program-rules-content ul ul, .stnew-task-modal-subject ul ul,
.rich-content ul ul li, .program-rules-content ul ul li, .stnew-task-modal-subject ul ul li {
    list-style-type: circle !important;
}

.rich-content ul ul ul, .program-rules-content ul ul ul, .stnew-task-modal-subject ul ul ul,
.rich-content ul ul ul li, .program-rules-content ul ul ul li, .stnew-task-modal-subject ul ul ul li {
    list-style-type: square !important;
}

.rich-content ul ul, .rich-content ol ol, .rich-content ul ol, .rich-content ol ul,
.program-rules-content ul ul, .program-rules-content ol ol,
.program-rules-content ul ol, .program-rules-content ol ul,
.stnew-task-modal-subject ul ul, .stnew-task-modal-subject ol ol,
.stnew-task-modal-subject ul ol, .stnew-task-modal-subject ol ul {
    margin: 4px 0 4px 0 !important;
}

/* Inline форматирование */
.rich-content strong, .rich-content b,
.program-rules-content strong, .program-rules-content b,
.stnew-task-modal-subject strong, .stnew-task-modal-subject b {
    font-weight: 700;
}

.rich-content em, .rich-content i,
.program-rules-content em, .program-rules-content i,
.stnew-task-modal-subject em, .stnew-task-modal-subject i {
    font-style: italic;
}

.rich-content u,
.program-rules-content u,
.stnew-task-modal-subject u {
    text-decoration: underline;
}

.rich-content s, .rich-content strike,
.program-rules-content s, .program-rules-content strike,
.stnew-task-modal-subject s, .stnew-task-modal-subject strike {
    text-decoration: line-through;
}

.rich-content sub, .program-rules-content sub, .stnew-task-modal-subject sub {
    vertical-align: sub;
    font-size: smaller;
}

.rich-content sup, .program-rules-content sup, .stnew-task-modal-subject sup {
    vertical-align: super;
    font-size: smaller;
}

/* Ссылки */
.rich-content a,
.program-rules-content a,
.stnew-task-modal-subject a {
    color: #1976d2;
    text-decoration: underline;
}

.rich-content a:hover,
.program-rules-content a:hover,
.stnew-task-modal-subject a:hover {
    color: #4CAF50;
    text-decoration: none;
}

/* Изображения */
.rich-content img,
.program-rules-content img,
.stnew-task-modal-subject img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

/* Таблицы */
.rich-content table,
.program-rules-content table,
.stnew-task-modal-subject table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.rich-content table th, .rich-content table td,
.program-rules-content table th, .program-rules-content table td,
.stnew-task-modal-subject table th, .stnew-task-modal-subject table td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    vertical-align: top;
}

.rich-content table th,
.program-rules-content table th,
.stnew-task-modal-subject table th {
    background: #f5f5f5;
    font-weight: 700;
}

/* Цитаты */
.rich-content blockquote,
.program-rules-content blockquote,
.stnew-task-modal-subject blockquote {
    margin: 12px 0;
    padding: 10px 16px;
    border-left: 4px solid #4CAF50;
    background: #f8f9fa;
    color: #555;
    font-style: italic;
}

/* Код */
.rich-content code,
.program-rules-content code,
.stnew-task-modal-subject code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.rich-content pre,
.program-rules-content pre,
.stnew-task-modal-subject pre {
    background: #f4f4f4;
    padding: 12px 16px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 12px 0;
}

.rich-content pre code,
.program-rules-content pre code,
.stnew-task-modal-subject pre code {
    background: transparent;
    padding: 0;
}

/* HR */
.rich-content hr,
.program-rules-content hr,
.stnew-task-modal-subject hr {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 16px 0;
}

/* Выравнивание (TinyMCE сохраняет через style="text-align: ...;") */
/* inline-стили работают сами; этот блок просто страховка */
.rich-content [style*="text-align: center"],
.program-rules-content [style*="text-align: center"],
.stnew-task-modal-subject [style*="text-align: center"] { text-align: center; }

.rich-content [style*="text-align: right"],
.program-rules-content [style*="text-align: right"],
.stnew-task-modal-subject [style*="text-align: right"] { text-align: right; }

.rich-content [style*="text-align: justify"],
.program-rules-content [style*="text-align: justify"],
.stnew-task-modal-subject [style*="text-align: justify"] { text-align: justify; }
