/* ===== ОПТИМИЗИРОВАННЫЙ CSS ДЛЯ ТЕМАТИЧЕСКИХ ГРУПП V1.1 (ИСПРАВЛЕНО) ===== */

:root {
    --tg-primary: #c65d00;
    --tg-primary-hover: #a54d00;
    --tg-text: #2c3e50;
    --tg-text-secondary: #7f8c8d;
    --tg-text-muted: #95a5a6;
    --tg-quote-text: #6b7280; /* Темно-серый для улучшенного контраста */
    --tg-border: #e8e8e8;
    --tg-bg-cart: #ffffff;
    --tg-bg: #f2f2f2;
    --tg-bg-hover: #faf8f5;
    --tg-radius: 12px;
    --tg-transition: all 0.3s ease;
}

/* Базовая структура */
.thematic-groups-section {
    padding: 60px 20px;
    background: var(--tg-bg);
}

.thematic-groups-section .container {
    max-width: 100%;
    padding: 0 20px;
    margin: 0 auto;
}

/* Для сохранения читаемости на очень широких экранах */
@media (min-width: 1400px) {
    .thematic-groups-section .container {
        max-width: 1400px;
    }
}

/* Заголовок секции */
.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.section-title {
    margin-bottom: 16px;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.section-subtitle {
    font-size: 20px;
    color: var(--tg-text-secondary);
    font-weight: 400;
    line-height: 1.5;
}

/* Grid для карточек - ИСПРАВЛЕНО */
.groups-accordion {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: 20px;
    align-items: start; /* ← ИСПРАВЛЕНО: изменено с stretch на start */
}

/* Для больших экранов - ограничиваем до 2 колонок */
@media (min-width: 1200px) {
    .groups-accordion {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
        align-items: start; /* ← ДОБАВЛЕНО: явно указываем start */
    }
}

/* Для очень больших экранов - центрируем блок */
@media (min-width: 1600px) {
    .groups-accordion {
        max-width: 1400px;
        margin: 0 auto;
    }
}

/* Карточки - ИСПРАВЛЕНО */
.group-item {
    background: var(--tg-bg-cart);
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius);
    transition: var(--tg-transition), transform 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-self: start; /* ← ДОБАВЛЕНО: карточка не растягивается по высоте соседей */
}

.group-item:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.group-item.active {
    border-color: var(--tg-primary);
    box-shadow: 0 12px 32px rgba(198, 93, 0, 0.15);
}

/* === СТРУКТУРА ЗАГОЛОВКА === */
.group-header {
    display: flex;
    align-items: flex-start;
    padding: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-height: 160px;
}

.group-header:hover {
    background: var(--tg-bg-hover);
}

.group-header:focus {
    outline: 2px solid var(--tg-primary);
    outline-offset: 2px;
}

/* Иконка */
.group-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    border-radius: var(--tg-radius);
    margin-right: 20px;
    font-size: 28px;
    line-height: 1;
}

/* Основной контейнер для текста */
.group-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/* Верхний уровень: заголовок + кнопка */
.group-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.group-title {
    font-size: 1.5rem;
    color: var(--tg-text);
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.01em;
    flex: 1;
    min-width: 0;
}

/* Переключатель (кнопка) */
.group-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--tg-primary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--tg-transition);
    flex-shrink: 0;
}

.toggle-icon {
    transition: transform 0.3s ease;
    will-change: transform;
}

.group-item.active .toggle-icon {
    transform: rotate(180deg);
}

/* Нижний уровень: подзаголовок + превью */
.group-preview-block {
    width: 100%;
}

.group-subtitle {
    font-size: 1rem;
    color: var(--tg-text-secondary);
    margin: 0 0 6px 0;
    font-weight: 500;
    line-height: 1.4;
}

.group-preview {
    font-size: 1rem;
    color: var(--tg-quote-text);
    font-style: italic;
    margin-top: 8px;
    opacity: 1;
    font-weight: 400;
    line-height: 1.5;
    margin: 0;
}

/* Контент карточки (раскрытое состояние) */
.group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    padding: 0 32px;
}

.group-item.active .group-content {
    max-height: 1200px;
    padding: 0 32px 32px;
}

/* Внутренняя структура контента */
.group-content-inner {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
}

/* Строка с изображением и текстом */
.group-content-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
}

/* Изображение */
.group-image {
    flex-shrink: 0;
    width: 180px;
    height: 180px;
    border-radius: var(--tg-radius);
    overflow: hidden;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.group-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.group-image:hover img {
    transform: scale(1.05);
}

/* Текст */
.group-text {
    flex: 1;
    min-width: 0;
}

.group-description {
    font-size: 17px;
    color: #555;
    margin-bottom: 20px;
    line-height: 1.7;
    font-weight: 400;
}

/* Вопросы */
.group-questions {
    width: 100%;
    padding-bottom: 8px;
}

.group-questions ul {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 32px;
    margin: 0;
}

.group-questions li {
    position: relative;
    padding-left: 24px;
    margin: 0;
    color: #666;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 400;
    break-inside: avoid;
}

.group-questions li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--tg-primary);
    font-weight: bold;
}

/* CTA кнопки */
.cta-button-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding-top: 16px;
    width: 100%;
    flex-wrap: wrap;
}

.cta-button {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tg-transition), transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    text-align: center;
    min-width: 180px;
    border: 2px solid transparent;
    letter-spacing: -0.01em;
}

/* Кнопка "Получить консультацию" */
.cta-button--consult {
    background: white;
    color: var(--tg-primary);
    border: 2px solid var(--tg-primary);
}

.cta-button--consult:hover {
    background: var(--tg-bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(198, 93, 0, 0.2);
    text-decoration: none;
    color: var(--tg-primary);
}

.cta-button--consult:focus {
    outline: 2px solid var(--tg-primary);
    outline-offset: 2px;
}

/* Кнопка "Читать статью" */
.cta-button:not(.cta-button--consult) {
    background: var(--tg-primary);
    color: white;
    border: 2px solid var(--tg-primary);
}

.cta-button:not(.cta-button--consult):hover {
    background: transparent;
    color: var(--tg-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(198, 93, 0, 0.3);
    text-decoration: none;
}

.cta-button:not(.cta-button--consult):focus {
    outline: 2px solid var(--tg-primary);
    outline-offset: 2px;
}

/* Цветовые схемы групп */
.group-item[data-group="1"] .group-icon { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.group-item[data-group="1"]:hover { border-color: #4f46e5; }
.group-item[data-group="2"] .group-icon { background: linear-gradient(135deg, #e0f2fe, #bae6fd); }
.group-item[data-group="2"]:hover { border-color: #0284c7; }
.group-item[data-group="3"] .group-icon { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); }
.group-item[data-group="3"]:hover { border-color: #9333ea; }
.group-item[data-group="4"] .group-icon { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); }
.group-item[data-group="4"]:hover { border-color: #475569; }
.group-item[data-group="5"] .group-icon { background: linear-gradient(135deg, #fed7aa, #fdba74); }
.group-item[data-group="5"]:hover { border-color: #ea580c; }
.group-item[data-group="6"] .group-icon { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.group-item[data-group="6"]:hover { border-color: #16a34a; }
.group-item[data-group="7"] .group-icon { background: linear-gradient(135deg, #fee2e2, #fecaca); }
.group-item[data-group="7"]:hover { border-color: #dc2626; }
.group-item[data-group="8"] .group-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); }
.group-item[data-group="8"]:hover { border-color: #d97706; }

/* === АДАПТИВНОСТЬ === */
/* Планшеты */
@media (min-width: 769px) and (max-width: 1024px) {
    .groups-accordion {
        grid-template-columns: 1fr;
        gap: 20px;
        align-items: start; /* Сохраняем правильное выравнивание */
    }
    
    .group-header {
        min-height: 140px;
    }
    
    .group-preview {
        font-size: 0.938rem;
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .thematic-groups-section { 
        padding: 40px 15px; 
    }
    
    .thematic-groups-section .container {
        padding: 0;
    }
    
    .groups-accordion { 
        grid-template-columns: 1fr; 
        gap: 16px;
        align-items: start; /* Сохраняем правильное выравнивание */
    }
    
    .section-title { font-size: 2rem; }
    .section-subtitle { font-size: 1.125rem; }
    
    .group-header { 
        padding: 20px; 
        min-height: 140px; 
    }
    
    .group-icon { 
        width: 48px; 
        height: 48px; 
        margin-right: 16px; 
        font-size: 24px; 
    }
    
    .group-main {
        gap: 10px;
    }
    
    .group-top-row {
        gap: 12px;
    }
    
    .group-title { 
        font-size: 1.25rem; 
    }
    
    .group-subtitle {
        font-size: 0.938rem;
        margin-bottom: 4px;
    }
    
    .group-preview {
        font-size: 0.938rem;
        line-height: 1.4;
        margin-top: 10px;
    }
    
    .group-content { 
        padding: 0 20px; 
    }
    
    .group-item.active .group-content { 
        padding: 0 20px 24px;
        max-height: 2000px;
    }
    
    .group-content-inner { 
        gap: 20px; 
    }
    
    .group-content-row { 
        flex-direction: column; 
        align-items: center; 
        gap: 20px; 
    }
    
    .group-image { 
        width: 160px; 
        height: 160px; 
        align-self: center; 
    }
    
    .group-description { 
        font-size: 16px; 
        margin-bottom: 16px; 
    }
    
    .group-questions ul { 
        grid-template-columns: 1fr; 
        gap: 10px; 
    }
    
    .group-questions li { 
        font-size: 15px; 
    }
    
    .cta-button-wrapper { 
        padding-top: 20px; 
        margin-top: auto;
        flex-direction: column;
        gap: 12px;
    }
    
    .cta-button { 
        width: 100%; 
        max-width: 280px; 
        text-align: center; 
        padding: 16px 20px;
    }
}

/* Маленькие мобильные устройства */
@media (max-width: 480px) {
    .thematic-groups-section { 
        padding: 30px 10px; 
    }
    
    .section-header {
        margin-bottom: 40px;
    }
    
    .section-title { font-size: 28px; }
    .section-subtitle { font-size: 16px; }
    
    .group-header { 
        padding: 16px;
        min-height: 130px; 
    }
    
    .group-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin-right: 12px;
    }
    
    .group-main {
        gap: 8px;
    }
    
    .group-title {
        font-size: 1.125rem;
    }
    
    .group-subtitle {
        font-size: 0.875rem;
    }
    
    .group-preview {
        font-size: 0.875rem;
        font-weight: 450;
        margin-top: 12px;
    }
    
    .group-toggle {
        font-size: 12px;
    }
    
    .group-content { 
        padding: 0 16px; 
    }
    
    .group-item.active .group-content { 
        padding: 0 16px 20px;
        max-height: 2000px;
    }
    
    .group-content-inner { 
        gap: 16px; 
    }
    
    .group-content-row { 
        gap: 16px; 
    }
    
    .group-image { 
        width: 140px; 
        height: 140px; 
    }
    
    .group-description { 
        font-size: 15px; 
        margin-bottom: 12px; 
    }
    
    .group-questions ul { 
        gap: 8px; 
    }
    
    .group-questions li { 
        font-size: 14px; 
        line-height: 1.5; 
    }
    
    .cta-button-wrapper { 
        padding-top: 16px; 
    }
    
    .cta-button { 
        font-size: 15px; 
        width: 100%; 
        max-width: none; 
    }
}

/* Оптимизация анимаций */
html { 
    scroll-behavior: smooth; 
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* Фикс для карточек внутри Collapsible Container */
.cc-content-wrapper .thematic-groups-section {
    padding-top: 0;
    background: transparent;
}

.cc-content-wrapper .group-item {
    cursor: pointer;
}

.cc-content-wrapper .group-header {
    cursor: pointer !important;
}

/* Убеждаемся, что стили применяются */
.cc-content-wrapper .group-item.active .group-content {
    max-height: 1200px !important;
    padding: 0 32px 32px !important;
}

.cc-content-wrapper .group-item .group-content {
    transition: all 0.4s ease !important;
}