/* Контейнер главы */
.chapter-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 60vh;
}

/* Заметное состояние загрузки без пустого каркаса страницы. */
.chapter-loading {
    flex: 1;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #b8b8d0;
    font-size: 17px;
}

.chapter-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(138, 122, 255, 0.25);
    border-top-color: #8a7aff;
    border-radius: 50%;
    animation: chapter-loading-spin 0.8s linear infinite;
}

@keyframes chapter-loading-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .chapter-loading-spinner { animation: none; }
}

.chapter-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Основной контент - растягивается на всю доступную высоту */
.chapter-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Основной текстовый контент с скроллом */
.chapter-scrollable {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 20px;
    min-height: 0;
    font-size: 17px;
}

/* Стилизация скроллбара */
.chapter-scrollable::-webkit-scrollbar {
    width: 6px;
}

.chapter-scrollable::-webkit-scrollbar-track {
    background: rgba(138, 122, 255, 0.1);
    border-radius: 3px;
}

.chapter-scrollable::-webkit-scrollbar-thumb {
    background: rgba(138, 122, 255, 0.3);
    border-radius: 3px;
}

.chapter-scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(138, 122, 255, 0.5);
}

/* Заголовок части */
.part-title {
    font-size: 16px;
    font-weight: 300;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #8a7aff;
    margin-bottom: 10mm;
    border-left: 2px solid #8a7aff;
    padding-left: 12px;
}

/* Заголовок главы */
.chapter-title {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8mm !important;
    background: linear-gradient(135deg, #ffffff 0%, #8a7aff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.chapter-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #8a7aff, transparent);
}

/* Вступительный блок с буквицей */
.intro-block {
    background: rgba(26, 26, 42, 0.8);
    border-left: 4px solid #8a7aff;
    padding: 25px;
    margin-bottom: 30px;
    position: relative;
    backdrop-filter: blur(10px);
}

.intro-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #8a7aff, transparent);
}

.drop-cap {
    float: left;
    font-size: 68px;
    font-weight: 700;
    line-height: 0.8;
    margin: 8px 15px 5px 0;
    background: linear-gradient(135deg, #8a7aff, #4a3aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.intro-text {
    font-size: 17px;
    text-align: justify;
    color: #e8e8f0;
    line-height: 1.7;
}

/* Двухколоночный блок */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 35px 0;
}

.column {
    font-size: 17px;
    color: #e8e8f0;
    text-align: justify;
    line-height: 1.7;
}

.content-subtitle {
    font-size: 16px !important;
    color: #8a7aff !important;
    margin-bottom: 12px !important;
    font-weight: 600 !important;
}

.divider-section {
    height: 2px !important;
    background: linear-gradient(to right, transparent, #8a7aff, #44446a, transparent) !important;
    margin: 30px 0 !important;
    width: 100% !important;
}
 /* Разделитель */
.section-divider {
    height: 2px;
    background: linear-gradient(to right, transparent, #8a7aff, #44446a, transparent);
    margin: 30px 0;
    width: 100%;
}

/* Для светлой темы */
body.light-theme .section-divider {
    background: linear-gradient(to right, transparent, #6a5acd, #d1d1e0, transparent);
}

/* Списки */
.content-list {
    list-style: none;
    margin: 20px 0;
    font-size: 17px;
}

.content-list li {
    margin-bottom: 12px;
    padding-left: 25px;
    position: relative;
    line-height: 1.6;
}

.content-list li:before {
    content: "•";
    color: #8a7aff;
    position: absolute;
    left: 10px;
    font-size: 20px;
}

/* Декоративная цитата */
.decorative-quote {
    font-style: italic;
    font-size: 17px;
    color: #a0a0ff;
    border-left: 3px solid #8a7aff;
    padding-left: 25px;
    margin: 15px 0;
    background: rgba(138, 122, 255, 0.08);
    padding: 10px 25px;
    border-radius: 0 8px 8px 0;
    line-height: 1.7;
}

/* Абзацы основного текста */
.main-text {
    font-size: 17px;
    color: #e8e8f0;
    text-align: justify;
    margin-bottom: 24px;
    line-height: 1.7;
}

.highlight {
    color: #a0a0ff;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Пагинация - всегда внизу контейнера */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0 10px;
    border-top: 1px solid #33334a;
    flex-shrink: 0;
    margin-top: auto;
}

.nav-button {
    background: rgba(138, 122, 255, 0.1);
    border: 1px solid #8a7aff;
    color: #8a7aff;
    padding: 14px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Georgia', serif;
    font-size: 16px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav-button:hover {
    background: rgba(138, 122, 255, 0.2);
    transform: translateY(-2px);
}

.nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.chapter-indicator {
    text-align: center;
    color: #66668a;
    font-size: 16px;
    flex-shrink: 0;
    margin: 0 16px;
}

/* Стили для картинки в главе */
.chapter-image {
    margin: 0 0 40px 0;
    text-align: center;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #33334a;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.chapter-image img {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    display: block;
}

.image-caption {
    padding: 15px 20px;
    background: rgba(26, 26, 42, 0.9);
    color: #b8b8d0;
    font-size: 14px;
    text-align: center;
    font-style: italic;
    border-top: 1px solid #33334a;
}

/* Стили для галереи */
.gallery-container {
    margin: 40px 0;
    width: 100%;
    max-width: none !important;
}

.gallery-item {
    background: rgba(26, 26, 42, 0.9);
    border: 1px solid #33334a;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    margin-bottom: 40px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.9) 0%, rgba(26, 26, 42, 0.9) 100%);
    max-width: none !important;
}

.chapter-content .gallery-container,
.chapter-main .gallery-container,
.page-container .gallery-container {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.gallery-item:last-child {
    margin-bottom: 0;
}

.gallery-item:hover {
    transform: translateY(-8px);
    border-color: #8a7aff;
    box-shadow: 0 15px 40px rgba(138, 122, 255, 0.2);
    background: linear-gradient(135deg, rgba(35, 35, 60, 0.9) 0%, rgba(30, 30, 50, 0.9) 100%);
}

.gallery-item img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    border: 1px solid #44446a;
    transition: all 0.3s ease;
}

.gallery-item:hover img {
    border-color: #8a7aff;
    box-shadow: 0 5px 20px rgba(138, 122, 255, 0.1);
}

.gallery-caption {
    padding: 20px 10px 10px 10px;
    color: #d8d8f0;
    font-size: 16px;
    text-align: center;
    font-style: italic;
    line-height: 1.5;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

/* Стили для подзаголовков глав */
.chapter-subtitle {
    font-size: 20px;
    color: #b8b8d0;
    margin-bottom: 30px;
    font-style: italic;
    border-left: 3px solid #8a7aff;
    padding-left: 15px;
}

/* Стили для подразделов */
.subsection {
    margin: 15px 0;
}

.subsection-title {
    font-size: 18px;
    color: #8a7aff;
    margin-bottom: 15px;
    font-weight: 600;
}

.subsection-content {
    font-size: 17px;
    color: #d8d8f0;
    text-align: justify;
    margin-bottom: 20px;
    line-height: 1.7;
}

/* Разделительная линия */
.divider-line {
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        #33334a 20%,
        #8a7aff 50%,
        #33334a 80%,
        transparent 100%);
    margin: 10px 0;
    width: 100%;
    opacity: 0.6;
}

/* Адаптивность для контента */
@media (max-width: 768px) {
    .two-columns {
        grid-template-columns: 1fr;
    }
    .chapter-navigation {
        flex-direction: column;
        gap: 15px;
        padding: 15px 0 5px;
    }
    .nav-button {
        width: 100%;
        text-align: center;
        order: 2;
    }
    .chapter-indicator {
        order: 1;
        margin: 0;
    }
    .prev-button {
        order: 3;
    }
    .next-button {
        order: 4;
    }
    .chapter-title {
        font-size: 28px;
    }
    .intro-block {
        padding: 20px;
    }
    .gallery-container {
        margin: 30px 0;
    }
    .gallery-item {
        margin-bottom: 30px;
        padding: 15px;
        border-radius: 12px;
    }
    .gallery-item img {
        height: 300px;
        border-radius: 8px;
    }
    .gallery-caption {
        padding: 15px 5px 5px 5px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .gallery-container {
        margin: 25px 0;
    }
    .gallery-item {
        margin-bottom: 25px;
        padding: 12px;
        border-radius: 10px;
    }
    .gallery-item img {
        height: 250px;
        border-radius: 6px;
    }
    .gallery-caption {
        padding: 12px 5px 5px 5px;
        font-size: 14px;
    }
}

/* ========================================================================= */
/* СВЕТЛАЯ ТЕМА ДЛЯ КОНТЕНТА */
/* ========================================================================= */

body.light-theme .part-title {
    color: #6a5acd;
    border-left: 2px solid #6a5acd;
}

body.light-theme .chapter-title {
    background: linear-gradient(135deg, #2a2a2a 0%, #6a5acd 50%, #8a7aff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.light-theme .chapter-title::after {
    background: linear-gradient(90deg, #6a5acd, transparent);
}

body.light-theme .intro-block {
    background: rgba(255, 255, 255, 0.95);
    border-left: 4px solid #6a5acd;
}

body.light-theme .intro-block::before {
    background: linear-gradient(90deg, transparent, #6a5acd, transparent);
}

body.light-theme .drop-cap {
    background: linear-gradient(135deg, #6a5acd, #8a7aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .intro-text {
    color: #3a3a3a;
    font-weight: 500;
}

body.light-theme .main-text {
    color: #3a3a3a;
    font-weight: 500;
}

body.light-theme .highlight {
    color: #5a4acd;
    font-weight: 600;
    background: rgba(138, 122, 255, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

body.light-theme .subsection-title {
    color: #6a5acd;
}

body.light-theme .subsection-content {
    color: #3a3a3a !important;
    font-weight: 500;
}

body.light-theme .column {
    color: #3a3a3a;
    font-weight: 500;
}

body.light-theme .content-list li {
    color: #3a3a3a;
    font-weight: 500;
}

body.light-theme .content-list li:before {
    color: #6a5acd;
}

body.light-theme .decorative-quote {
    color: #6a5acd;
    background: rgba(138, 122, 255, 0.08);
}

body.light-theme .nav-button {
    background: rgba(138, 122, 255, 0.15);
    border: 1px solid #8a7aff;
    color: #6a5acd;
    font-weight: 600;
}

body.light-theme .nav-button:hover {
    background: rgba(138, 122, 255, 0.25);
}

body.light-theme .chapter-indicator {
    color: #7a7a9a;
    font-weight: 600;
}

body.light-theme .chapter-navigation {
    border-top: 1px solid #e0e0f0;
}

body.light-theme .chapter-image {
    border: 1px solid #e0e0f0;
}

body.light-theme .image-caption {
    background: rgba(255, 255, 255, 0.9);
    color: #666666;
    border-top: 1px solid #e0e0f0;
}

body.light-theme .gallery-item {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e0e0f0;
}

body.light-theme .gallery-item:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #8a7aff;
}

body.light-theme .gallery-item img {
    border: 1px solid #e0e0f0;
}

body.light-theme .gallery-caption {
    color: #5a5a7a;
    font-weight: 500;
}

body.light-theme .chapter-subtitle {
    color: #7a7a9a;
}

body.light-theme .divider-line {
    background: linear-gradient(90deg,
        transparent 0%,
        #e0e0f0 20%,
        #8a7aff 50%,
        #e0e0f0 80%,
        transparent 100%);
}

/* Светлая тема для таблиц */
body.light-theme .symptom-table {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e0e0f0;
}

body.light-theme .table-header {
    background: rgba(138, 122, 255, 0.15);
    color: #5a5a7a;
    font-weight: 600;
}

body.light-theme .table-row {
    border-bottom: 1px solid #f0f0f0;
}

body.light-theme .table-row:hover {
    background: rgba(138, 122, 255, 0.05);
}

body.light-theme .symptom-col {
    color: #3a3a3a;
    font-weight: 500;
    border-right: 1px solid #f0f0f0;
}

body.light-theme .justification-col {
    color: #5a5a7a;
    font-weight: 500;
}

body.light-theme .archetype-tag {
    background: rgba(138, 122, 255, 0.1);
    color: #6a5acd;
    border: 1px solid rgba(138, 122, 255, 0.2);
}

/* Светлая тема для блоков контента */
body.light-theme .content-block {
    background: rgba(255, 255, 255, 0.9);
    border-left: 3px solid #8a7aff;
}

body.light-theme .content-subtitle {
    color: #6a5acd;
    font-weight: 600;
}

body.light-theme .miasma-block {
    background: rgba(255, 255, 255, 0.9);
}

body.light-theme .miasma-title {
    color: #6a5acd;
}

body.light-theme .patient-portrait {
    background: linear-gradient(135deg, rgba(138, 122, 255, 0.05) 0%, rgba(74, 58, 255, 0.02) 100%);
    border: 1px solid rgba(138, 122, 255, 0.2);
}

body.light-theme .conclusion-block {
    background: linear-gradient(135deg, rgba(138, 122, 255, 0.05) 0%, rgba(74, 58, 255, 0.02) 100%);
    border: 1px solid rgba(138, 122, 255, 0.2);
}

body.light-theme .key-point {
    background: rgba(255, 255, 255, 0.8);
}

body.light-theme .key-point-number {
    color: #6a5acd;
}

body.light-theme .key-block {
    background: rgba(255, 255, 255, 0.9);
}

body.light-theme .key-category {
    color: #6a5acd;
}

body.light-theme .references-block {
    background: rgba(255, 255, 255, 0.9);
}

body.light-theme .references-title {
    color: #6a5acd;
}

body.light-theme .reference-link {
    color: #5a5a7a;
}

body.light-theme .reference-link:hover {
    color: #8a7aff;
}

/* Стили для горизонтального расположения картинки и текста */
.image-text-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin: 30px 0;
    min-height: 300px; /* Минимальная высота для блока */
}

/* Обратный порядок на мобильных (текст будет сверху) */
.image-text-layout.reverse {
    flex-direction: column;
}

@media (min-width: 1024px) {
    .image-text-layout {
        flex-direction: row;
        align-items: stretch; /* Растягиваем оба блока на всю высоту */
    }

    .image-text-layout.reverse {
        flex-direction: row-reverse; /* Обратный порядок на десктопе */
    }

    .image-side {
        flex: 0 0 45%;
        max-width: 45%;
        display: flex;
        flex-direction: column;
    }

    .text-side {
        flex: 0 0 55%;
        max-width: 55%;
        display: flex;
        flex-direction: column;
        padding-left: 30px;
    }

    /* Для обратного порядка добавляем отступ справа, а не слева */
    .image-text-layout.reverse .text-side {
        padding-left: 0;
        padding-right: 30px;
    }

    /* Обертка для изображения с фиксированной высотой */
    .image-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* Обертка для текста с фиксированной высотой */
    .text-wrapper {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* Подгоняем изображение в пределах обертки */
    .image-wrapper img {
        width: 100%;
        height: auto;
        max-height: 350px; /* Ограничиваем максимальную высоту */
        object-fit: contain; /* Сохраняем пропорции */
        object-position: center;
        border-radius: 8px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    /* Подпись под изображением */
    .image-wrapper .image-caption {
        margin-top: 10px;
        font-style: italic;
        color: #8888aa;
        font-size: 14px;
        line-height: 1.4;
        text-align: center;
        flex-shrink: 0; /* Не сжимается */
    }

    /* Контент в текстовой части растягиваем */
    .text-wrapper .subsection-content {
        flex: 1;
    }

    .text-wrapper .fact-table {
        flex-shrink: 0; /* Таблица не сжимается */
    }
}

/* Для светлой темы */
.light-theme .image-wrapper .image-caption {
    color: #666;
}

/* Стили для обычных блоков с изображением */
.image-block {
    margin: 30px 0;
    text-align: center;
}

.image-block img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.image-block img:hover {
    transform: scale(1.01);
}

.image-block .image-caption {
    font-style: italic;
    color: #8888aa;
    margin-top: 10px;
    font-size: 14px;
    text-align: center;
    line-height: 1.4;
}

.light-theme .image-block .image-caption {
    color: #666;
}

/* Стили для блока с характеристиками */
.content-list li {
    margin-bottom: 12px;
    line-height: 1.6;
    position: relative;
    padding-left: 20px;
}

.content-list li::before {
    content: "•";
    color: #ff6b6b;
    font-size: 20px;
    position: absolute;
    left: 0;
    top: 0;
}

.content-list li strong {
    color: #ffd700;
}

/* Для светлой темы */
.light-theme .content-list li::before {
    color: #2c5282;
}

.light-theme .content-list li strong {
    color: #2c5282;
}

/* Стили для фактов */
.fact-table {
    background: rgba(40, 40, 70, 0.3);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border-left: 4px solid #ff6b6b;
}

.light-theme .fact-table {
    background: rgba(236, 240, 247, 0.8);
    border-left: 4px solid #2c5282;
}

.fact-row {
    display: flex;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.light-theme .fact-row {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.fact-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.fact-label {
    flex: 1;
    font-weight: bold;
    color: #ffd700;
}

.light-theme .fact-label {
    color: #2c5282;
}

.fact-value {
    flex: 2;
    color: #b8b8d0;
}

.light-theme .fact-value {
    color: #4a5568;
}

/* Стили для верхнего интро */
.intro-block {
    margin: 40px 0;
    position: relative;
}

.drop-cap {
    float: left;
    font-size: 80px;
    line-height: 60px;
    padding-top: 18px;
    padding-right: 8px;
    padding-left: 3px;
    font-weight: bold;
    color: #ff6b6b;
}

.light-theme .drop-cap {
    color: #2c5282;
}

.intro-text {
    font-size: 18px;
    line-height: 1.7;
    color: #d0d0e7;
    text-align: justify;
}

.light-theme .intro-text {
    color: #2d3748;
}

/* На мобильных устройствах */
@media (max-width: 1023px) {
    .image-wrapper img {
        width: 100%;
        height: auto;
        max-height: 300px;
        object-fit: contain;
    }

    .image-text-layout {
        gap: 20px;
    }
}
