/* Стили для прогресса чтения */
.reading-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(0,0,0,0.1);
    z-index: 9999;
}

.reading-progress-bar {
    height: 4px;
    background: linear-gradient(to right, #95ce5a, #78a93a);
    width: 0%;
    transition: width 0.1s ease;
}

/* Стили для оглавления */
.toc-container {
    background-color: #1e222d;
    border-radius: 10px;
    margin: 20px 0 30px;
    border: 1px solid #2a2e39;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.toc-header {
    background: linear-gradient(135deg, #131722, #1e222d);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #2a2e39;
    cursor: pointer;
}

.toc-header i {
    color: #95ce5a;
    margin-right: 10px;
    font-size: 22px;
    opacity: 1;
    text-shadow: 0 0 5px rgba(149, 206, 90, 0.5);
}

/* Новый класс для замены h3 в оглавлении */
.toc-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #d1d4dc;
    flex-grow: 1;
}

.toc-toggle {
    background: transparent;
    border: none;
    color: #95ce5a;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.3s;
    padding: 5px;
}

.toc-toggle.collapsed i {
    transform: rotate(180deg);
}

.toc-content {
    padding: 15px 20px;
    max-height: 500px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.toc-content.collapsed {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
}

.toc-content ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: item;
}

.toc-content li {
    padding: 5px 0;
    position: relative;
}

.toc-content a {
    color: #d1d4dc;
    text-decoration: none;
    transition: color 0.2s;
    display: block;
    padding-left: 30px;
    position: relative;
    font-size: 14px;
}

.toc-content a:hover {
    color: #95ce5a;
}

.toc-content li:before {
    position: absolute;
    left: 0;
    color: #95ce5a;
    font-weight: bold;
}

.toc-content li.toc-level-2:before {
    content: counter(item) ".";
    counter-increment: item;
}

.toc-content li.toc-level-3 {
    counter-increment: subitem;
    padding-left: 15px !important;
}

.toc-content li.toc-level-3:before {
    content: counter(item) "." counter(subitem);
    counter-increment: none;
}

.toc-content li.toc-level-4 {
    padding-left: 30px !important;
    counter-increment: subsubitem;
}

.toc-content li.toc-level-4:before {
    content: counter(item) "." counter(subitem) "." counter(subsubitem);
    counter-increment: none;
}

.toc-content::-webkit-scrollbar {
    width: 5px;
}

.toc-content::-webkit-scrollbar-track {
    background: #1e222d;
}

.toc-content::-webkit-scrollbar-thumb {
    background: #95ce5a;
    border-radius: 5px;
}

/* Стили с гарантированной обрезкой по высоте */
.featured-image-wrapper {
    margin: 0 0 20px 0;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    width: 100%;
    background-color: #f9f9f9;
}

.featured-image-container {
    width: 100%;
    height: 0;
    padding-bottom: 46%; /* Фиксированная высота для всех */
    position: relative;
    overflow: hidden;
}

.featured-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Заполняет весь контейнер */
    object-fit: cover; /* Важно для обрезки */
    object-position: top center; /* Фокус на верхней части */
    border-radius: 12px;
    display: block;
}

/* Адаптивность для разных экранов */
@media (max-width: 992px) {
    .featured-image-container {
        padding-bottom: 50%;
    }
}

@media (max-width: 768px) {
    .featured-image-wrapper {
        margin: 0 0 15px 0;
        border-radius: 8px;
    }
    
    .featured-image-container {
        padding-bottom: 56%;
    }
    
    .featured-image-container img {
        border-radius: 8px;
    }
}

@media (max-width: 576px) {
    .featured-image-container {
        padding-bottom: 65%;
    }
}
/* Принудительное исправление для изображений в контенте на мобильных */
@media (max-width: 767px) {
    .entry-content p img:not(.featured-image-wrapper img):not(.wp-post-image) {
        margin-left: auto !important;
        margin-right: auto !important;
        float: none !important;
        display: block !important;
    }
}
/* Стили для темной темы чтения */
body.dark-theme {
    background-color: #131722 !important;
}

body.dark-theme #primary,
body.dark-theme #main,
body.dark-theme .site-main,
body.dark-theme article,
body.dark-theme .entry-content,
body.dark-theme .post-navigation,
body.dark-theme #secondary,
body.dark-theme .widget,
body.dark-theme .site-footer,
body.dark-theme .finance-author-card {
    background-color: #131722 !important;
    color: #d1d4dc !important;
}

body.dark-theme .entry-content p,
body.dark-theme .entry-content li,
body.dark-theme .entry-content span,
body.dark-theme .entry-content div:not([class*="finance-"]) {
    color: #bdbdbd !important;
}

body.dark-theme .entry-content h1, 
body.dark-theme .entry-content h2, 
body.dark-theme .entry-content h3, 
body.dark-theme .entry-content h4, 
body.dark-theme .entry-content h5, 
body.dark-theme .entry-content h6,
body.dark-theme .entry-title {
    color: #fff !important;
}

body.dark-theme .entry-content a:not(.share-button) {
    color: #a9dd78 !important;
}

body.dark-theme .entry-content blockquote {
    background-color: #1e222d !important;
    border-left-color: #95ce5a !important;
}

body.dark-theme .post-navigation .nav-previous,
body.dark-theme .post-navigation .nav-next {
    background-color: #1e222d !important;
}

body.dark-theme .post-navigation .nav-previous a,
body.dark-theme .post-navigation .nav-next a {
    color: #fff !important;
}

body.dark-theme .article-meta-bar {
    background-color: #1e222d !important;
}

body.dark-theme .article-meta-item {
    color: #bdbdbd !important;
}

body.dark-theme .article-meta-label {
    color: #d1d4dc !important;
}

body.dark-theme .reading-time {
    background-color: #1e222d !important;
    color: #bdbdbd !important;
}

/* Темная тема для блока случайных статей */
body.dark-theme .random-category-posts {
    background-color: #1e222d !important;
    border-color: #2a2e39 !important;
}

body.dark-theme .posts-header {
    background: linear-gradient(to right, #131722, #1e222d) !important;
    border-color: #2a2e39 !important;
}

body.dark-theme .posts-section-title {
    color: #d1d4dc !important;
}

body.dark-theme .posts-content {
    background-color: #1e222d !important;
}

body.dark-theme .post-card {
    background: #131722 !important;
    border-color: #2a2e39 !important;
}

body.dark-theme .post-footer {
    background: #131722 !important;
    border-color: #2a2e39 !important;
}

body.dark-theme .post-title a {
    color: #d1d4dc !important;
}

body.dark-theme .post-excerpt {
    color: #9ca3af !important;
}

body.dark-theme .post-meta {
    border-color: #2a2e39 !important;
    color: #9ca3af !important;
}

/* Стили для функционального блока */
.post-utility-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 0;
    padding: 15px;
    background: #f9fbf6;
    border-radius: 8px;
    border-left: 3px solid #95ce5a;
}

.reading-theme-toggle {
    background: #1e222d;
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    transition: all 0.3s ease;
}

.reading-theme-toggle i {
    margin-right: 5px;
}

.reading-theme-toggle:hover {
    background: #95ce5a;
}

/* Стили для времени чтения */
.reading-time {
    font-size: 14px;
    color: #666;
    display: inline-flex;
    align-items: center;
}

.reading-time i {
    margin-right: 6px;
    color: #95ce5a;
}

/* Стили для кнопок шеринга */
.share-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.share-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    font-size: 14px;
    transition: all 0.3s ease;
    text-decoration: none !important;
}

.share-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.share-vk {
    background: #4C75A3;
}

.share-vk:hover {
    background: #5b88bb;
}

.share-telegram {
    background: #0088cc;
}

.share-telegram:hover {
    background: #0099e5;
}

.share-facebook {
    background: #3b5998;
}

.share-facebook:hover {
    background: #4c70ba;
}

.share-twitter {
    background: #1DA1F2;
}

.share-twitter:hover {
    background: #39adfc;
}

.share-linkedin {
    background: #0077b5;
}

.share-linkedin:hover {
    background: #0088ce;
}

/* Убираем отступы между блоком утилит и контентом */
.entry-content > p:first-of-type {
    margin-top: 0;
}

.post-utility-bar + * {
    margin-top: 0 !important;
}

/* Стили для хлебных крошек */
.breadcrumbs {
    margin: 0;
    padding: 0;
    font-size: 12px;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none !important;
}

.breadcrumbs li {
    display: inline-flex;
    margin: 0;
    padding: 0;
    list-style: none !important;
    counter-increment: none !important;
}

.breadcrumbs li:before {
    display: none !important;
    content: none !important;
}

.breadcrumbs li:not(:last-child):after {
    content: "/";
    margin: 0 8px;
    color: #ccc;
}

.breadcrumbs a {
    color: #78a93a;
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumbs a:hover {
    color: #95ce5a;
    text-decoration: underline;
}

.breadcrumbs .current {
    color: #666;
    font-weight: 400;
}

/* Темная тема для хлебных крошек */
body.dark-theme .breadcrumbs {
    color: #9ca3af;
}

body.dark-theme .breadcrumbs li:not(:last-child):after {
    color: #2a2e39;
}

body.dark-theme .breadcrumbs a {
    color: #95ce5a;
}

body.dark-theme .breadcrumbs .current {
    color: #d1d4dc;
}

/* Стили для однострочного блока метаданных */
.article-meta-bar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    background-color: #f9fbf6;
    border-left: 3px solid #95ce5a;
    padding: 10px 15px;
    margin-bottom: 25px;
    border-radius: 0 4px 4px 0;
    font-size: 13px;
    color: #666;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.article-meta-item {
    display: flex;
    align-items: center;
    margin-right: 20px;
    white-space: nowrap;
}

.article-meta-item:last-child {
    margin-right: 0;
}

.article-meta-item i {
    color: #95ce5a;
    margin-right: 6px;
    font-size: 14px;
}

.article-meta-label {
    font-weight: 600;
    color: #444;
    margin-right: 5px;
}

.article-meta-value {
    color: #666;
}

.article-meta-value a {
    color: #95ce5a;
    text-decoration: none;
    transition: color 0.2s;
}

.article-meta-value a:hover {
    color: #78a93a;
    text-decoration: underline;
}

.article-meta-divider {
    width: 1px;
    height: 16px;
    background-color: #e0e0e0;
    margin: 0 15px;
}

/* Стили для финансового блока автора */
:root {
    --main-bg: #131722;
    --darker-bg: #1e222d;
    --border-color: #2a2e39;
    --accent-color: #95ce5a;
    --secondary-accent: #5a95ce;
    --tertiary-accent: #304FFE;
    --text-light: #d1d4dc;
    --text-lighter: #fff;
    --text-muted: #9ca3af;
    --chart-green: #26a69a;
    --chart-red: #ef5350;
}

.finance-author-card {
    max-width: 100%;
    margin: 25px 0;
    background-color: var(--darker-bg);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: block;
    border: 1px solid var(--border-color);
    position: relative;
    color: var(--text-light);
    padding: 20px;
}

.finance-author-image {
    width: 150px;
    height: 150px;
    float: left;
    margin-right: 25px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, #95ce5a, #78a93a);
}

.finance-author-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.finance-author-info {
    overflow: hidden;
}

.finance-author-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.finance-author-name {
    display: flex;
    align-items: center;
}

/* Новый класс для замены h2 в блоке автора */
.author-name-heading {
    font-size: 22px;
    color: var(--text-lighter);
    margin: 0;
    margin-right: 10px;
    font-weight: 700;
}

.finance-author-name .verified {
    color: var(--accent-color);
    font-size: 18px;
}

.finance-social-links {
    display: flex;
    gap: 12px;
}

.finance-social-links a {
    width: 36px;
    height: 36px;
    background: var(--main-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.3s;
    text-decoration: none;
    border: 1px solid var(--border-color);
}

.finance-social-links a:hover {
    background: var(--accent-color);
    color: var(--main-bg);
    transform: translateY(-3px);
    border-color: var(--accent-color);
}

.finance-author-title {
    font-size: 16px;
    color: var(--accent-color);
    margin-bottom: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
}

.finance-author-quote {
    position: relative;
    margin: 12px 0;
    font-style: italic;
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.5;
    padding: 10px 18px;
    background-color: rgba(149, 206, 90, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--accent-color);
    text-align: left;
}

.finance-author-quote:before {
    content: '\201C';
    position: absolute;
    top: 0;
    left: 8px;
    font-size: 30px;
    line-height: 1;
    color: var(--accent-color);
    opacity: 0.3;
    font-family: Georgia, serif;
}

.finance-author-stats-wrap {
    clear: both;
    margin-top: 5px;
}

.finance-author-stats {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.finance-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.finance-stat-item i {
    margin-bottom: 5px;
    color: var(--accent-color);
    font-size: 16px;
}

.finance-stat-item .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-color);
}

.finance-stat-item .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.finance-author-cta {
    display: inline-block;
    background: var(--accent-color);
    color: var(--main-bg) !important;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    margin-top: 0;
    margin-left: auto;
}

.finance-author-cta:hover {
    background: #7fbf40;
    transform: translateY(-2px);
    text-decoration: none;
}

/* Адаптив для мобильных устройств */
@media (max-width: 768px) {
    .post-utility-bar {
        flex-wrap: wrap;
        gap: 15px;
        justify-content: space-between;
    }
    
    .reading-time {
        width: 100%;
        order: -1;
    }
    
    .reading-theme-toggle, .share-buttons {
        margin: 0;
    }
    
    .share-buttons {
        display: flex;
        align-items: center;
    }
    
    .breadcrumbs {
        font-size: 12px;
    }
    
    .article-meta-bar {
        overflow-x: auto;
        padding: 10px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .article-meta-bar::-webkit-scrollbar {
        display: none;
    }
    
    .article-meta-item {
        flex-shrink: 0;
    }
    
    .article-meta-divider {
        flex-shrink: 0;
    }
    
    .finance-author-image {
        float: none;
        width: 100px;
        height: 100px;
        margin: 0 auto 15px;
        display: block;
    }
    
    .finance-author-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .finance-social-links {
        margin-top: 10px;
    }
    
    .finance-author-stats {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 18px;
    }
    
    .finance-author-cta {
        margin-left: 0;
        margin-top: 12px;
        width: 100%;
        text-align: center;
    }
    
    .finance-stat-item {
        min-width: 70px;
    }
}

@media (max-width: 480px) {
    .finance-author-card {
        padding: 15px;
    }
}

body.dark-theme .finance-author-card {
    background-color: #1a1a1a;
    border-color: #333;
}

body.dark-theme .finance-author-quote {
    background-color: rgba(149, 206, 90, 0.05);
}

/* Дополнительные оптимизации для мобильных */
@media (max-width: 767px) {
    .featured-image {
        /* Специальные оптимизации для мобильных */
        contain: layout paint; /* Оптимизация рендеринга для мобильных */
    }
    
    .article-meta-bar {
        /* Упрощенный вариант для мобильных */
        padding: 8px 10px;
    }
    
    /* Оптимизация для последовательной загрузки на медленных соединениях */
    .toc-container, 
    .post-utility-bar, 
    .finance-author-card {
        content-visibility: auto;
        contain-intrinsic-size: 1px 5000px; /* Примерная оценка размера */
    }
}
/* Универсальные стили для виджетов TradingView на мобильных */
@media (max-width: 768px) {
    /* Базовые стили для контейнера */
    .tradingview-widget-container {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: relative !important;
        overflow: hidden !important;
        margin: 20px 0 !important;
        padding: 0 !important;
    }
    
    /* КЛЮЧЕВОЕ: Масштабируем виджеты с фиксированной шириной */
    .tradingview-widget-container__widget {
        transform: scale(0.4);
        transform-origin: top left;
        width: 250% !important; /* 100% / 0.4 = 250% */
        max-width: none !important;
        position: relative;
    }
    
    /* Устанавливаем высоту контейнера в зависимости от содержимого */
    .tradingview-widget-container:has(iframe[height="610"]),
    .tradingview-widget-container:has(iframe[height="600"]) {
        height: 244px; /* 610 * 0.4 */
    }
    
    .tradingview-widget-container:has(iframe[height="500"]),
    .tradingview-widget-container:has(iframe[height="512"]) {
        height: 200px; /* 500 * 0.4 */
    }
    
    /* Скрываем копирайт на мобильных для экономии места */
    .tradingview-widget-copyright {
        display: none !important;
    }
    
    /* Для iframe внутри виджетов */
    .tradingview-widget-container iframe {
        max-width: none !important;
        position: absolute;
        top: 0;
        left: 0;
    }
}

/* Для маленьких экранов (380-480px) - чуть больше масштаб */
@media (min-width: 380px) and (max-width: 480px) {
    .tradingview-widget-container__widget {
        transform: scale(0.45);
        width: 222% !important; /* 100% / 0.45 */
    }
    
    .tradingview-widget-container:has(iframe[height="610"]),
    .tradingview-widget-container:has(iframe[height="600"]) {
        height: 275px; /* 610 * 0.45 */
    }
    
    .tradingview-widget-container:has(iframe[height="500"]),
    .tradingview-widget-container:has(iframe[height="512"]) {
        height: 225px; /* 500 * 0.45 */
    }
}

/* Для больших мобильных (480-768px) - больше масштаб */
@media (min-width: 480px) and (max-width: 768px) {
    .tradingview-widget-container__widget {
        transform: scale(0.5);
        width: 200% !important; /* 100% / 0.5 */
    }
    
    .tradingview-widget-container:has(iframe[height="610"]),
    .tradingview-widget-container:has(iframe[height="600"]) {
        height: 305px; /* 610 * 0.5 */
    }
    
    .tradingview-widget-container:has(iframe[height="500"]),
    .tradingview-widget-container:has(iframe[height="512"]) {
        height: 250px; /* 500 * 0.5 */
    }
}

/* Альтернатива если :has() не поддерживается */
@media (max-width: 768px) {
    .tradingview-widget-container {
        min-height: 200px;
        height: auto;
    }
    
    /* Фоллбэк высоты для всех виджетов */
    .tradingview-widget-container:not(:empty) {
        height: 250px;
    }
}