/* ============================================
   СТИЛИ ДЛЯ КОНТЕНТА СТАТЕЙ - КЕЙСЫ, КОНТАКТЫ, СЕКЦИИ
   ============================================ */

/* Заголовки секций с подчеркиванием */
.article-body h2 {
    position: relative;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.article-body h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

/* Блок "Профессиональная помощь" - исправление контраста
   РАНЬШЕ здесь были сложные правила с белым текстом, теперь мы их убрали,
   чтобы не ломать контраст. Оформление делаем минимальным: только рамка. */

.article-body > div[style*="background"],
.article-body > div[style*="gradient"],
.article-body > div[style*="linear-gradient"] {
    border-radius: 12px;
    padding: 25px 30px;
}

/* Блоки с кейсами - стилизация (две колонки) */
/* Если есть вложенные div с контентом кейсов */
.article-body > div > div {
    background: #f8f9fa;
    padding: 20px 25px;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Контейнер для нескольких кейсов рядом - применяется только если есть вложенные div */
.article-body > div:not([style*="background"]):not([style*="gradient"]):not([style*="linear-gradient"]) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin: 30px 0;
}

/* Заголовки в кейсах */
.article-body > div > div strong:first-child,
.article-body > div > div h4:first-child {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 15px 0;
    display: block;
}

/* Подзаголовки в кейсах */
.article-body > div > div strong,
.article-body > div > div h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #34495e;
    margin: 15px 0 10px 0;
    display: block;
}

/* Подзаголовки секций */
.article-body h3 {
    color: #34495e !important; /* тёмный читаемый цвет для подзаголовков */
}

.article-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 20px 0 12px 0;
}

/* Улучшение читаемости списков в секциях */
.article-body ul li,
.article-body ol li {
    margin-bottom: 12px;
    line-height: 1.7;
    color: #495057;
}

/* Выделение важных блоков - применяется через класс или стиль */
.article-body > div[style*="⚠️"],
.article-body > div[style*="Важно"],
.article-body > div[style*="❗"] {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 20px 25px;
    border-radius: 0 8px 8px 0;
    margin: 25px 0;
}

/* Адаптивность для кейсов */
@media (max-width: 768px) {
    .article-body > div:not([style*="background"]):not([style*="gradient"]):not([style*="linear-gradient"]) {
        grid-template-columns: 1fr !important;
        gap: 20px;
        display: block !important;
    }
    
    .article-body > div > div {
        margin: 15px 0;
        padding: 15px 20px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    /* Все блоки с inline стилями адаптируются */
    .article-body > div[style],
    .article-body div[style] {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box;
        padding: 20px 15px !important;
        margin: 20px 0 !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Заголовки в кейсах адаптивные */
    .article-body > div > div strong:first-child,
    .article-body > div > div h4:first-child {
        font-size: 1.2rem;
    }
    
    .article-body > div > div strong,
    .article-body > div > div h4 {
        font-size: 1rem;
    }
    
    /* Блоки контактов адаптивные */
    .article-body .custom-contacts-block,
    .article-body .custom-info-block {
        padding: 20px 15px !important;
        margin: 20px 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    
    .article-body .custom-contacts-block h3,
    .article-body .custom-contacts-block strong,
    .article-body .custom-info-block h3,
    .article-body .custom-info-block strong {
        font-size: 1.1rem;
    }
    
    .article-body .custom-contacts-block p,
    .article-body .custom-info-block p {
        font-size: 0.95rem;
        margin: 6px 0;
    }
}

@media (max-width: 480px) {
    .article-body > div > div {
        padding: 12px 15px;
    }
    
    .article-body > div > div strong:first-child,
    .article-body > div > div h4:first-child {
        font-size: 1.1rem;
    }
    
    .article-body > div > div strong,
    .article-body > div > div h4 {
        font-size: 0.95rem;
    }
    
    .article-body > div[style],
    .article-body div[style],
    .article-body .custom-contacts-block,
    .article-body .custom-info-block {
        padding: 15px 12px !important;
    }
}

/* ФИНАЛЬНОЕ ПРАВИЛО: делаем текст темным на светлых инфоблоках внутри статьи */
.article-body div[style*="background"],
.article-body div[style*="gradient"],
.article-body div[style*="linear-gradient"],
.article-body div[style*="#f8f9ff"],
.article-body div[style*="#e3f2fd"],
.article-body div[style*="#e7f3ff"] {
    color: #243b53 !important; /* темный читаемый текст */
}

.article-body div[style*="background"] *,
.article-body div[style*="gradient"] *,
.article-body div[style*="linear-gradient"] *,
.article-body div[style*="#f8f9ff"] *,
.article-body div[style*="#e3f2fd"] *,
.article-body div[style*="#e7f3ff"] * {
    color: #243b53 !important;
}

/* Точный фикс: блок контактов .custom-contacts-block в статьях */
.article-body .custom-contacts-block {
    background: #eaf4ff;
    border-radius: 16px;
    padding: 24px 28px;
    border-left: 4px solid #1e88e5;
    box-shadow: 0 8px 24px rgba(30, 136, 229, 0.12);
}

.article-body .custom-contacts-block h3,
.article-body .custom-contacts-block strong {
    color: #1b3a57 !important;
}

.article-body .custom-contacts-block p {
    color: #243b53 !important;
    margin: 8px 0;
}

/* Точный фикс: .custom-info-block внутри статей (отменяем белый текст из cert.css) */
.article-body .custom-info-block {
    background: #f4fbf0 !important;              /* мягкий светлый фон */
    border-radius: 16px;
    padding: 22px 24px;
    border-left: 4px solid #27ae60;
    box-shadow: 0 6px 18px rgba(39, 174, 96, 0.18);
}

.article-body .custom-info-block h3,
.article-body .custom-info-block strong {
    color: #1b3a57 !important;
}

.article-body .custom-info-block p {
    color: #243b53 !important;
    margin: 8px 0;
}

/* ================================
   Безопасный откат слишком общих правил
   ================================ */

/* Возвращаем обычный поток для обёрток первого уровня */
.article-body > div:not([style*="background"]):not([style*="gradient"]):not([style*="linear-gradient"]) {
    display: block;
    margin: 0 0 1.1em;
    gap: 0;
}

/* Внутренние div больше не оформляем как карточки по умолчанию */
.article-body > div > div {
    background: transparent;
    border-left: none;
    padding: 0;
    border-radius: 0;
    margin: 0 0 1.1em;
    box-shadow: none;
}

/* Блок «Главная страница категории» — только для статей категории 31 (доверенное ПО) */
.category-main-page-block {
    margin-bottom: 32px;
}

.category-main-page-block-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 22px 24px;
    background: linear-gradient(135deg, rgba(30, 60, 114, 0.08) 0%, rgba(42, 82, 152, 0.12) 100%);
    border: 1px solid rgba(30, 60, 114, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(30, 60, 114, 0.08);
}

.category-main-page-block-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    flex-shrink: 0;
}

.category-main-page-block-icon svg {
    width: 26px;
    height: 26px;
}

.category-main-page-block-text {
    flex: 1;
    min-width: 200px;
}

.category-main-page-block-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1e3c72;
    margin-bottom: 4px;
}

.category-main-page-block-desc {
    margin: 0;
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.5;
}

.category-main-page-block-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 22px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff !important;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    border-radius: 10px;
    white-space: nowrap;
    transition: box-shadow 0.25s ease, transform 0.2s ease;
}

.category-main-page-block-btn:hover {
    box-shadow: 0 6px 20px rgba(30, 60, 114, 0.4);
    transform: translateY(-1px);
}

@media (max-width: 640px) {
    .category-main-page-block-inner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        padding: 16px 14px;
        gap: 12px;
    }
    .category-main-page-block-icon {
        margin: 0 auto;
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }
    .category-main-page-block-icon svg {
        width: 20px;
        height: 20px;
    }
    .category-main-page-block-label {
        font-size: 0.75rem;
    }
    .category-main-page-block-desc {
        font-size: 0.9rem;
        line-height: 1.45;
    }
    .category-main-page-block-btn {
        width: 100%;
        padding: 11px 18px;
    }
}

/* ============================================
   FIX: контраст текста на тёмных "custom" карточках
   (в некоторых статьях фон задаётся градиентом, а текст остаётся тёмным)
   ============================================ */
.article-body .custom-challenge-card {
    color: #ffffff !important;
}

.article-body .custom-challenge-card h1,
.article-body .custom-challenge-card h2,
.article-body .custom-challenge-card h3,
.article-body .custom-challenge-card h4,
.article-body .custom-challenge-card p,
.article-body .custom-challenge-card span,
.article-body .custom-challenge-card li {
    color: #ffffff !important;
}

.article-body .custom-challenge-card p {
    opacity: 0.92;
}

/* Синие карточки cert.css (.custom-template-card, success, stat):
   правило .article-body > div > div h4:first-child { color: #2c3e50 } и
   .article-body > div > div h4 { color: #34495e } имеют специфичность (0,2,3) и
   перебивают .prose-article .custom-template-card h4 из inline article.php (0,2,1).
   Дублируем логику .custom-challenge-card — белый текст на тёмном градиенте. */
.article-body .custom-template-card,
.article-body .custom-success-box,
.article-body .custom-stat-item {
    color: #fff !important;
}

.article-body .custom-template-card h1,
.article-body .custom-template-card h2,
.article-body .custom-template-card h3,
.article-body .custom-template-card h4,
.article-body .custom-template-card h5,
.article-body .custom-template-card h6,
.article-body .custom-template-card > strong:first-child,
.article-body .custom-template-card strong,
.article-body .custom-success-box h1,
.article-body .custom-success-box h2,
.article-body .custom-success-box h3,
.article-body .custom-success-box h4,
.article-body .custom-success-box h5,
.article-body .custom-success-box h6,
.article-body .custom-success-box > strong:first-child,
.article-body .custom-success-box strong {
    color: #fff !important;
}

.article-body .custom-template-card p,
.article-body .custom-success-box p {
    color: rgba(255, 255, 255, 0.92) !important;
}

.article-body .custom-template-card ul li,
.article-body .custom-template-card ol li,
.article-body .custom-success-box ul li,
.article-body .custom-success-box ol li {
    color: rgba(255, 255, 255, 0.92) !important;
}

.article-body .custom-template-card a,
.article-body .custom-success-box a {
    color: #fff !important;
    border-bottom-color: rgba(255, 255, 255, 0.45) !important;
}

.article-body .custom-stat-item .custom-stat-number {
    color: #fff !important;
}

.article-body .custom-stat-item .custom-stat-label {
    color: rgba(255, 255, 255, 0.88) !important;
}

/* Контакты в фирменной палитре сайта: светлая карточка + читаемый темный текст */
.article-body .custom-contacts-block {
    background: linear-gradient(135deg, #eaf3ff 0%, #dcecff 100%) !important;
    border: 1px solid rgba(37, 99, 235, 0.26) !important;
    border-left: 4px solid #2563eb !important;
    border-radius: 12px !important;
    padding: 22px 24px !important;
    margin: 28px 0 !important;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.12) !important;
    color: #1e3a8a !important;
}

.article-body .custom-contacts-block h2,
.article-body .custom-contacts-block h3,
.article-body .custom-contacts-block h4,
.article-body .custom-contacts-block strong,
.article-body .custom-contacts-block > strong:first-child {
    color: #1e3a8a !important;
    font-weight: 700 !important;
}

.article-body .custom-contacts-block p,
.article-body .custom-contacts-block li {
    color: #1f2a44 !important;
    margin: 8px 0 !important;
    line-height: 1.6 !important;
}

.article-body .custom-contacts-block a {
    color: #2563eb !important;
    text-decoration: none !important;
    border-bottom: 1px solid rgba(37, 99, 235, 0.35) !important;
}

.article-body .custom-contacts-block a:hover {
    color: #1e40af !important;
    border-bottom-color: #1e40af !important;
}

/* Универсальный фикс для акцентных CTA/strategy-блоков во всех новостях:
   иногда utility-класс задаёт белый текст, но фон у блока остаётся светлым.
   Делаем самодостаточный тёмный контейнер + гарантируем читаемость. */
.article-body .custom-accent-card {
    background: linear-gradient(135deg, #0b1220 0%, #1e3a8a 100%) !important;
    border: 1px solid rgba(180, 197, 255, 0.24) !important;
    box-shadow: 0 18px 36px rgba(6, 18, 38, 0.2) !important;
    color: #ffffff !important;
}

.article-body .custom-accent-card *,
.article-body .custom-accent-card h1,
.article-body .custom-accent-card h2,
.article-body .custom-accent-card h3,
.article-body .custom-accent-card h4,
.article-body .custom-accent-card p,
.article-body .custom-accent-card li,
.article-body .custom-accent-card span,
.article-body .custom-accent-card strong {
    color: #ffffff !important;
}

.article-body .custom-accent-card p,
.article-body .custom-accent-card li {
    color: rgba(255, 255, 255, 0.9) !important;
}

.article-body .custom-accent-card .text-blue-100,
.article-body .custom-accent-card .text-blue-200,
.article-body .custom-accent-card .text-on-primary-container {
    color: rgba(226, 232, 255, 0.92) !important;
}

.article-body .custom-accent-card .text-accent-orange,
.article-body .custom-accent-card .mat-filled {
    color: #f59e0b !important;
}

/* Fallback для блоков с utility-классами без custom-accent-card */
.article-body .bg-primary.text-white,
.article-body .bg-navy-deep.text-white {
    background-color: #0b1220 !important;
    background-image: linear-gradient(135deg, #0b1220 0%, #1e3a8a 100%) !important;
    color: #ffffff !important;
}

.article-body .bg-primary.text-white *,
.article-body .bg-navy-deep.text-white * {
    color: #ffffff !important;
}

.article-body .bg-primary.text-white p,
.article-body .bg-primary.text-white li,
.article-body .bg-navy-deep.text-white p,
.article-body .bg-navy-deep.text-white li {
    color: rgba(255, 255, 255, 0.92) !important;
}

.article-body .bg-primary.text-white .text-blue-100,
.article-body .bg-primary.text-white .text-blue-200,
.article-body .bg-primary.text-white .text-on-primary-container,
.article-body .bg-navy-deep.text-white .text-blue-100,
.article-body .bg-navy-deep.text-white .text-blue-200,
.article-body .bg-navy-deep.text-white .text-on-primary-container {
    color: rgba(226, 232, 255, 0.92) !important;
}

.article-body .bg-primary.text-white .text-accent-orange,
.article-body .bg-primary.text-white .mat-filled,
.article-body .bg-navy-deep.text-white .text-accent-orange,
.article-body .bg-navy-deep.text-white .mat-filled {
    color: #f59e0b !important;
}


