/*
 * Busya: стили шаблона templates/taxonomy-category.php (пакет 8г, Е.15; раньше — блок <style> в HTML страницы).
 * Подключается в Busya::enqueue_assets() после busya-site.css, когда выбран этот шаблон (Busya::remember_template()).
 */

/* Основной лейаут (как на странице магазина) */
.busya-single-shop-layout {
    /* Общая ширина сайта: контент слева, сайдбар справа */
    width: 100%;
    max-width: var(--busya-w, 1000px);
    margin: 20px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 24px;
    font-family: system-ui, -apple-system, sans-serif;
    align-items: start;
    box-sizing: border-box;
}

/* Блоки левой колонки — прямые дети грида */
.busya-block-cat-header,
.busya-block-coupons,
.busya-block-seo {
    min-width: 0;
    width: 100%;
    grid-column: 1;
}

/* Сайдбар — правая колонка */
.busya-single-sidebar {
    grid-column: 2;
    grid-row: 1 / span 3;
    align-self: start;
}

/* Единый стиль плашки */
.busya-plaque-container {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 20px 0;
    padding: 20px;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.busya-cat-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
    text-align: left;
}

.busya-cat-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    color: var(--busya-text, #1e293b);
    line-height: 1.2;
}

.busya-cat-stats {
    font-size: 14px;
    color: var(--busya-muted, #64748b);
}

.busya-cat-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Сетка магазинов (4 колонки) - простой список */
.busya-shops-grid-4 {
    /* Поток имён (как было), но каждая строка растянута по ширине блока:
       items пакуются слева с минимальным гэпом, а остаток места
       распределяется между ними (space-between) — правый край строки
       дотягивается до края блока. */
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px 30px;
}

/* Невидимый «растягивающийся хвост»: на НЕПОЛНОЙ последней строке он съедает
   свободное место (flex-grow) и прижимает имена влево; на полных строках
   уходит на отдельную строку и не виден (пустой, высота 0). */
.busya-shops-grid-4::after {
    content: "";
    flex-grow: 1;
}

.busya-shop-card-simple {
    text-align: left;
}

.busya-shop-card-simple a {
    display: inline-block;
    white-space: nowrap;
    text-decoration: none;
    color: var(--busya-text, #1e293b);
    font-size: 16px;
    line-height: 1.4;
}

.busya-shop-card-simple a:hover {
    color: #3b82f6;
    text-decoration: none;
}

/* Разделитель внутри плашки */
.busya-plaque-divider {
    height: 1px;
    background-color: var(--busya-border, #e2e8f0);
    margin: 30px -40px;
    width: calc(100% + 80px);
}

/* Особенности купонных карточек */
.busya-plaque-container .busya-coupon-card .bcc-link {
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    transform: none !important;
    min-height: auto !important;
}

.busya-plaque-container.busya-compact {
    padding: 10px 20px;
    margin-bottom: 15px;
}

.busya-compact .bcc-content {
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 3px;
}

.busya-compact .bcc-info {
    padding: 5px 15px !important;
    justify-content: center;
    min-width: 0 !important;
}

.busya-compact .bcc-excerpt {
    margin: 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    display: block !important;
    max-width: 100%;
    line-height: 1.4;
}

.busya-compact .bcc-link {
    min-height: 50px !important;
}

.busya-compact .bcc-discount {
    padding: 5px !important;
}

.busya-compact .bcc-discount img {
    max-height: 40px !important;
    width: auto !important;
    object-fit: contain !important;
}

.busya-plaque-container .busya-coupon-card .bcc-link:hover .bcc-excerpt {
    color: #3b82f6 !important;
    transition: color 0.2s;
}

/* САЙДБАР */
.busya-single-sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.busya-sidebar-plaque {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.cats-widget-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1e293b;
}

.cats-vertical-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cat-vertical-item {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #334155;
    font-size: 15px;
    padding: 8px 0;
    transition: color 0.2s;
    border-bottom: 1px solid #f1f5f9;
    box-sizing: border-box;
}

.cat-vertical-item:last-child {
    border-bottom: none;
}

.cat-vertical-item:hover {
    color: #3b82f6;
}

.cat-vertical-icon {
    width: 48px;
    height: 40px;
    flex-shrink: 0;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cat-vertical-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cat-bullet {
    color: #cbd5e1;
    font-size: 20px;
    margin-right: 12px;
}

.shop-link-btn {
    display: block;
    width: fit-content;
    min-width: 140px;
    margin-left: auto;
    margin-right: auto;
    padding: 8px 20px;
    background: #3b82f6;
    color: #fff;
    border: none;
    text-align: center;
    border-radius: var(--busya-radius-btn, 8px);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
    box-sizing: border-box;
}

.shop-link-btn:hover {
    background: #2563eb;
    color: #fff;
    border: none;
}

/* Пагинация */
.busya-pagination {
    display: flex;
    justify-content: center;
    margin: 40px 0;
}

.busya-pagination .page-numbers {
    display: block;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none !important;
    background: #f1f5f9;
    color: #1e293b;
    font-weight: 500;
    transition: all 0.2s;
    margin: 0 4px;
    border: none;
}

.busya-pagination .page-numbers:hover {
    background: #3b82f6;
    color: #fff;
}

.busya-pagination .page-numbers.current {
    background: #3b82f6;
    color: #fff;
    font-weight: 600;
}

/* MOBILE / TABLET < 1100px */
@media (max-width: 1100px) {
    .busya-single-shop-layout {
        grid-template-columns: 1fr;
    }

    /* Сбрасываем explicit grid-placement — иначе браузер создаёт implicit 2-ю колонку */
    .busya-block-cat-header,
    .busya-block-coupons,
    .busya-block-seo,
    .busya-single-sidebar {
        grid-column: 1;
        grid-row: auto;
    }

    /* Порядок блоков на мобайле: карточка → купоны → популярные → SEO */
    .busya-block-cat-header { order: 1; }
    .busya-block-coupons    { order: 2; }
    .busya-single-sidebar   { order: 3; }
    .busya-block-seo        { order: 4; }
}

@media (max-width: 768px) {
    .busya-shops-grid-4 {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 480px) {
    .busya-shops-grid-4 {
        grid-template-columns: 1fr;
    }

    .busya-plaque-container {
        padding: 20px;
    }

    .busya-plaque-divider {
        margin: 20px -20px;
        width: calc(100% + 40px);
    }
}
