/**
 * Manga Custom Shortcodes Styles
 * Version: 2.0
 */

/* ======== ОБЩИЕ СТИЛИ ДЛЯ ВСЕХ БЛОКОВ ======== */
.manga-history-block,
.manga-popular-block,
.new-manga-block,
.updated-manga-block,
.trending-now-block {
    background: #fff;
    border-radius: 20px;
    padding: 25px 20px 20px 20px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* ======== ЗАГОЛОВКИ ======== */
.manga-history-title,
.manga-popular-title,
.new-manga-title,
.updated-manga-title,
.trending-now-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin: 0 0 20px 0;
    padding: 0 5px;
    position: relative;
    display: inline-block;
}

.manga-history-title:after,
.manga-popular-title:after,
.new-manga-title:after,
.updated-manga-title:after,
.trending-now-title:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 5px;
    width: 60px;
    height: 3px;
    background: #FCA311;
    border-radius: 2px;
}

/* ======== КОНТЕЙНЕРЫ ДЛЯ СКРОЛЛА ======== */
.history-scroll-container,
.manga-scroll-container,
.trending-scroll-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 5px 0 10px 0;
    margin: 0;
    scrollbar-width: none;
}

.history-scroll-container::-webkit-scrollbar,
.manga-scroll-container::-webkit-scrollbar,
.trending-scroll-container::-webkit-scrollbar {
    display: none;
}

.history-scroll-wrapper,
.manga-scroll-wrapper,
.trending-scroll-wrapper {
    display: flex;
    gap: 15px;
    width: max-content;
    padding: 0 5px;
}

/* ======== ЭЛЕМЕНТЫ ======== */
.history-item,
.manga-scroll-item,
.trending-scroll-item {
    flex: 0 0 auto;
    width: 160px;
}

.history-item a,
.manga-scroll-item a,
.trending-scroll-item a {
    display: block;
    text-decoration: none;
    color: inherit;
}

/* ======== ОБЛОЖКИ - БАЗОВЫЕ СТИЛИ ДЛЯ КОНТЕЙНЕРОВ ======== */
.history-item-cover,
.manga-scroll-cover,
.trending-scroll-cover,
.manga-desktop-cover,
.manga-mobile-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    border: 3px solid #FCA311;
    border-radius: 20px;
    overflow: hidden;
    transition: transform 0.2s ease;
    box-sizing: border-box;
    background: #f5f5f5;
}

/* ======== ОБЛОЖКИ - УСИЛЕННЫЕ СТИЛИ ДЛЯ ИЗОБРАЖЕНИЙ ======== */
/* Сбрасываем возможные стили темы */
.manga-history-block img,
.manga-popular-block img,
.new-manga-block img,
.updated-manga-block img,
.trending-now-block img {
    max-width: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* История чтения */
.manga-history-block .history-item-cover img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Популярная манга */
.manga-popular-block .manga-scroll-cover img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Новые тайтлы */
.new-manga-block .manga-scroll-cover img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Обновленная манга - десктоп */
.updated-manga-block .manga-desktop-cover img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Обновленная манга - мобильная */
.updated-manga-block .manga-mobile-cover img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Тренды */
.trending-now-block .trending-scroll-cover img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Поддержка старых браузеров */
.history-item-cover img,
.manga-scroll-cover img,
.trending-scroll-cover img,
.manga-desktop-cover img,
.manga-mobile-cover img {
    font-family: 'object-fit: cover;';
}

/* Эффект при наведении */
.history-item a:hover .history-item-cover,
.manga-scroll-item a:hover .manga-scroll-cover,
.trending-scroll-item a:hover .trending-scroll-cover,
.manga-desktop-item a:hover .manga-desktop-cover,
.manga-mobile-item a:hover .manga-mobile-cover {
    transform: scale(1.02);
}

/* ======== НАЗВАНИЯ ======== */
.history-item-title,
.manga-scroll-title,
.trending-scroll-title {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.3;
    text-align: center;
    color: #333;
    font-weight: 500;
    padding: 0 5px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    height: 36px;
    transition: color 0.2s ease;
}

.history-item a:hover .history-item-title,
.manga-scroll-item a:hover .manga-scroll-title,
.trending-scroll-item a:hover .trending-scroll-title {
    color: #FCA311;
}

/* ======== МЕТА-ИНФОРМАЦИЯ ======== */
.history-item-meta {
    margin-top: 8px;
    text-align: center;
}

.history-item-chapter {
    display: inline-block;
    background: #fef0e8;
    color: #FCA311;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.history-item-chapter:hover {
    background: #FCA311;
    color: #fff;
}

.manga-scroll-views,
.trending-scroll-views {
    font-size: 12px;
    color: #FCA311;
    text-align: center;
    margin-top: 5px;
    font-weight: 600;
}

/* ======== СПЕЦИАЛЬНЫЕ СТИЛИ ДЛЯ updated_manga ======== */
.manga-desktop-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.manga-desktop-row {
    display: flex;
    gap: 25px;
    width: 100%;
}

.manga-desktop-item {
    flex: 0 0 calc(33.333% - 16.67px);
    max-width: calc(33.333% - 16.67px);
}

.manga-desktop-item a {
    display: flex;
    text-decoration: none;
    color: inherit;
    align-items: flex-start;
    gap: 15px;
}

.manga-desktop-cover {
    position: relative;
    width: 84px;
    height: 112px;
    flex-shrink: 0;
    border: 2px solid #FCA311;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.manga-desktop-title {
    font-size: 15px;
    line-height: 1.5;
    color: #333;
    font-weight: 500;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.manga-desktop-item a:hover .manga-desktop-title {
    color: #FCA311;
}

/* Мобильные стили для updated_manga */
.manga-mobile-container {
    display: none;
}

/* ======== МЕДИА-ЗАПРОСЫ ======== */
@media (max-width: 992px) {
    .manga-desktop-cover {
        width: 76px;
        height: 101px;
    }
    .manga-desktop-title {
        font-size: 14px;
    }
    .manga-desktop-row {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .manga-history-block,
    .manga-popular-block,
    .new-manga-block,
    .updated-manga-block,
    .trending-now-block {
        padding: 20px 15px 15px 15px;
    }
    
    .manga-history-title,
    .manga-popular-title,
    .new-manga-title,
    .updated-manga-title,
    .trending-now-title {
        font-size: 22px;
        margin-bottom: 15px;
    }
    
    .history-item,
    .manga-scroll-item,
    .trending-scroll-item {
        width: 140px;
    }
    
    .history-item-title,
    .manga-scroll-title,
    .trending-scroll-title {
        font-size: 13px;
        height: 34px;
    }
    
    .history-item-chapter {
        font-size: 15px;
        padding: 3px 10px;
    }
    
    .manga-scroll-views,
    .trending-scroll-views {
        font-size: 11px;
    }
    
    /* Адаптация обложек для планшетов */
    .history-item-cover,
    .manga-scroll-cover,
    .trending-scroll-cover,
    .manga-desktop-cover,
    .manga-mobile-cover {
        border-width: 2px;
        border-radius: 15px;
    }
    
    /* Мобильная версия для updated_manga */
    .manga-desktop-grid {
        display: none;
    }
    
    .manga-mobile-container {
        display: block;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 5px 0 15px 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .manga-mobile-container::-webkit-scrollbar {
        display: none;
        width: 0;
        height: 0;
    }
    
    .manga-mobile-wrapper {
        display: flex;
        flex-direction: column;
        gap: 15px;
        width: max-content;
        min-width: 100%;
    }
    
    .manga-mobile-row {
        display: flex;
        gap: 15px;
        width: max-content;
    }
    
    .manga-mobile-item {
        flex: 0 0 auto;
        width: 160px;
    }
    
    .manga-mobile-item a {
        display: flex;
        text-decoration: none;
        color: inherit;
        align-items: flex-start;
        gap: 8px;
    }
    
    .manga-mobile-cover {
        position: relative;
        width: 60px;
        height: 80px;
        flex-shrink: 0;
        border: 2px solid #FCA311;
        border-radius: 8px;
        overflow: hidden;
        transition: transform 0.2s ease;
    }
    
    .manga-mobile-item a:hover .manga-mobile-cover {
        transform: scale(1.02);
    }
    
    .manga-mobile-title {
        font-size: 11px;
        line-height: 1.3;
        color: #333;
        font-weight: 500;
        word-break: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        max-width: 85px;
        flex: 1;
    }
    
    .manga-mobile-item a:hover .manga-mobile-title {
        color: #FCA311;
    }
}

@media (max-width: 480px) {
    .manga-history-block,
    .manga-popular-block,
    .new-manga-block,
    .updated-manga-block,
    .trending-now-block {
        padding: 15px 12px 12px 12px;
        border-radius: 15px;
    }
    
    .manga-history-title,
    .manga-popular-title,
    .new-manga-title,
    .updated-manga-title,
    .trending-now-title {
        font-size: 20px;
        margin-bottom: 12px;
    }
    
    .manga-history-title:after,
    .manga-popular-title:after,
    .new-manga-title:after,
    .updated-manga-title:after,
    .trending-now-title:after {
        width: 50px;
        height: 2px;
    }
    
    .history-item,
    .manga-scroll-item,
    .trending-scroll-item {
        width: 120px;
    }
    
    .history-scroll-wrapper,
    .manga-scroll-wrapper,
    .trending-scroll-wrapper {
        gap: 12px;
    }
    
    .history-item-cover,
    .manga-scroll-cover,
    .trending-scroll-cover,
    .manga-desktop-cover,
    .manga-mobile-cover {
        border-width: 2px;
        border-radius: 15px;
    }
    
    .history-item-title,
    .manga-scroll-title,
    .trending-scroll-title {
        font-size: 12px;
        margin-top: 8px;
        height: 32px;
    }
    
    .history-item-chapter {
        font-size: 14px;
        padding: 3px 8px;
    }
    
    .manga-scroll-views,
    .trending-scroll-views {
        font-size: 10px;
    }
}

/* ======== ДОПОЛНИТЕЛЬНАЯ ЗАЩИТА ОТ СТИЛЕЙ ТЕМЫ ======== */
/* Эти правила гарантируют, что наши изображения всегда будут растягиваться правильно */
.manga-history-block .history-item-cover img,
.manga-popular-block .manga-scroll-cover img,
.new-manga-block .manga-scroll-cover img,
.updated-manga-block .manga-desktop-cover img,
.updated-manga-block .manga-mobile-cover img,
.trending-now-block .trending-scroll-cover img {
    -webkit-object-fit: cover !important;
    -moz-object-fit: cover !important;
    -o-object-fit: cover !important;
    object-fit: cover !important;
}

/* Фикс для Internet Explorer */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .manga-history-block .history-item-cover img,
    .manga-popular-block .manga-scroll-cover img,
    .new-manga-block .manga-scroll-cover img,
    .updated-manga-block .manga-desktop-cover img,
    .updated-manga-block .manga-mobile-cover img,
    .trending-now-block .trending-scroll-cover img {
        width: auto !important;
        height: auto !important;
        min-width: 100% !important;
        min-height: 100% !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}