/* Catalog hero and helpers from catalog.php */

.catalog-hero {
    position: relative;
    overflow: hidden;
    padding: 2rem 0;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 55%, #f8fbff 100%);
    border: 1px solid #dbeafe;
    border-radius: 1.5rem;
    box-shadow: 0 18px 40px rgba(37, 99, 235, 0.08);
}

.catalog-hero::before {
    content: "";
    position: absolute;
    top: -60px;
    right: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0) 72%);
}

.catalog-hero::after {
    content: "";
    position: absolute;
    left: -40px;
    bottom: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.12) 0%, rgba(14, 165, 233, 0) 70%);
}

.catalog-hero > .row,
.catalog-hero .breadcrumb,
.catalog-hero .catalog-hero-top {
    position: relative;
    z-index: 1;
}

.catalog-hero-top {
    margin-bottom: 1rem;
}

.catalog-hero .breadcrumb {
    display: inline-flex;
    margin-bottom: 0;
    background: rgba(255, 255, 255, 0.92);
    border-color: #dbeafe;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.catalog-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.catalog-hero-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    line-height: 1.1;
    color: #0f172a;
    margin-bottom: 0.85rem;
}

.catalog-hero-description {
    max-width: 760px;
    color: #475569;
    font-size: 1rem;
    line-height: 1.75;
    margin-bottom: 1.25rem;
}

.catalog-hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.catalog-hero-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid #dbeafe;
    border-radius: 1rem;
    color: #0f172a;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.catalog-hero-stat i {
    color: #2563eb;
    font-size: 1.15rem;
}

.catalog-hero-stat strong {
    display: block;
    font-size: 1rem;
}

.catalog-hero-stat span {
    display: block;
    font-size: 0.78rem;
    color: #64748b;
}

.catalog-hero-visual {
    display: flex;
    justify-content: center;
}

.catalog-hero-media {
    width: min(100%, 360px);
    min-height: 280px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid #dbeafe;
    border-radius: 1.5rem;
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.09);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.catalog-hero-image {
    width: 100%;
    max-height: 230px;
    object-fit: contain;
    border-radius: 1rem;
}

.catalog-hero-placeholder {
    width: 110px;
    height: 110px;
    border-radius: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(14, 165, 233, 0.14));
    color: #2563eb;
    font-size: 2.2rem;
}

.catalog-hero-media-caption {
    color: #64748b;
    font-size: 0.9rem;
}

.category-description-card {
    background: #f8f9fa;
    border-color: #dee2e6 !important;
}

.category-description-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

[data-theme="dark"] .category-description-card {
    background: #1e293b;
    border-color: #334155 !important;
}

[data-theme="dark"] .category-description-card .fw-semibold {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .category-description-card .text-muted {
    color: #94a3b8 !important;
}

[data-theme="dark"] .category-description-thumb {
    border-color: #334155;
}

[data-theme="dark"] .category-description-placeholder {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #94a3b8 !important;
}

[data-theme="dark"] .catalog-hero {
    background: linear-gradient(135deg, #0f172a 0%, #172554 50%, #111827 100%);
    border-color: #334155;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .catalog-hero .breadcrumb {
    background: rgba(30, 41, 59, 0.92);
    border-color: #334155;
}

[data-theme="dark"] .catalog-hero-badge {
    background: rgba(96, 165, 250, 0.14);
    color: #93c5fd;
}

[data-theme="dark"] .catalog-hero-title {
    color: #f8fafc;
}

[data-theme="dark"] .catalog-hero-description,
[data-theme="dark"] .catalog-hero-media-caption {
    color: #94a3b8;
}

[data-theme="dark"] .catalog-hero-stat,
[data-theme="dark"] .catalog-hero-media {
    background: rgba(15, 23, 42, 0.82);
    border-color: #334155;
    color: #f8fafc;
}

[data-theme="dark"] .catalog-hero-stat span {
    color: #94a3b8;
}

[data-theme="dark"] .catalog-hero-stat i,
[data-theme="dark"] .catalog-hero-placeholder {
    color: #60a5fa;
}

@media (max-width: 991.98px) {
    .catalog-hero {
        padding: 1.5rem 0;
    }

    .catalog-hero-visual {
        margin-top: 1.5rem;
    }
}

/* Modern Pagination Styles */
.pagination {
    gap: 0.35rem;
}

.pagination .page-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;
    height: 2.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #2563eb;
    background: #ffffff;
    border: 1.5px solid #dbeafe;
    border-radius: 0.75rem;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pagination .page-link:hover {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #93c5fd;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18), 0 2px 4px rgba(15, 23, 42, 0.06);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border-color: #2563eb;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4), 0 2px 6px rgba(15, 23, 42, 0.1);
    transform: translateY(-1px);
}

.pagination .page-item.disabled .page-link {
    color: #94a3b8;
    background: #f8fafc;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination .page-item.disabled .page-link:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
    transform: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pagination .page-item:not(.active):not(.disabled) .page-link:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pagination .page-link i {
    font-size: 0.85rem;
    line-height: 1;
}

.pagination .page-item:first-child .page-link {
    border-top-left-radius: 0.75rem;
    border-bottom-left-radius: 0.75rem;
}

.pagination .page-item:last-child .page-link {
    border-top-right-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
}

/* Pagination info text */
.pagination + .text-center,
.pagination ~ .text-center {
    font-size: 0.9rem;
    color: #64748b;
    padding: 0.75rem 0 0;
    letter-spacing: 0.01em;
}

.pagination + .text-center strong,
.pagination ~ .text-center strong {
    color: #0f172a;
    font-weight: 700;
}

/* Dark theme pagination */
[data-theme="dark"] .pagination .page-link {
    background: #1e293b;
    border-color: #334155;
    color: #60a5fa;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .pagination .page-link:hover {
    color: #93c5fd;
    background: #1e3a5f;
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .pagination .page-item.disabled .page-link {
    color: #64748b;
    background: #0f172a;
    border-color: #1e293b;
}

[data-theme="dark"] .pagination + .text-center,
[data-theme="dark"] .pagination ~ .text-center {
    color: #94a3b8;
}

[data-theme="dark"] .pagination + .text-center strong,
[data-theme="dark"] .pagination ~ .text-center strong {
    color: #f1f5f9;
}

/* Responsive adjustments */
@media (max-width: 575.98px) {
    .pagination {
        gap: 0.25rem;
    }

    .pagination .page-link {
        min-width: 2.5rem;
        height: 2.5rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
        border-radius: 0.6rem;
    }

    .pagination + .text-center,
    .pagination ~ .text-center {
        font-size: 0.85rem;
    }
}

/* ============================================================
   Catalog View Toggle (Grid / List)
   ============================================================ */

.catalog-view-toggle {
    flex-shrink: 0;
}

.catalog-view-toggle .catalog-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 0.625rem;
    transition: all 0.2s ease;
}

.catalog-view-toggle .catalog-view-btn i {
    font-size: 1.1rem;
    line-height: 1;
}

.catalog-view-toggle .catalog-view-btn.active {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border-color: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.catalog-view-toggle .catalog-view-btn:not(.active):hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

[data-theme="dark"] .catalog-view-toggle .catalog-view-btn:not(.active):hover {
    background: #1e3a5f;
    border-color: #3b82f6;
    color: #93c5fd;
}

/* ============================================================
   Product Quantity Controls
   ============================================================ */

.product-order-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

/* Grid view: stack qty + button vertically in narrow cards */
#productsGrid:not(.catalog-view-list) .product-order-row {
    flex-direction: column;
    align-items: stretch;
}

#productsGrid:not(.catalog-view-list) .product-qty-block {
    align-self: center;
}

#productsGrid:not(.catalog-view-list) .btn-add-cart {
    width: 100%;
    justify-content: center;
}

/* Quantity block with label */
.product-qty-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.product-qty-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
    white-space: nowrap;
}

[data-theme="dark"] .product-qty-label {
    color: #94a3b8;
}

.product-qty-wrapper {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 25px;
    background: var(--bg-card, #ffffff);
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.product-qty-wrapper:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.product-qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.product-qty-btn:hover {
    background: rgba(37, 99, 235, 0.08);
    color: #2563eb;
}

.product-qty-btn:active {
    transform: scale(0.9);
}

.product-qty-input {
    width: 36px;
    padding: 0;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Adaptive width for large quantities (catalog cards + cart) */
.product-qty-wrapper .product-qty-input {
    width: auto;
    min-width: 36px;
    max-width: 120px;
    padding: 0 2px;
}

.product-qty-input::-webkit-outer-spin-button,
.product-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.product-qty-input:focus {
    outline: none;
}

[data-theme="dark"] .product-qty-wrapper {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .product-qty-btn {
    color: #94a3b8;
}

[data-theme="dark"] .product-qty-btn:hover {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
}

[data-theme="dark"] .product-qty-input {
    color: #f1f5f9;
}

/* ============================================================
   Catalog List View
   ============================================================ */

#productsGrid.catalog-view-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    --bs-gutter-x: 0;
    margin-right: 0;
    margin-left: 0;
}

#productsGrid.catalog-view-list > .col {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    display: flex;
    padding-right: 0;
    padding-left: 0;
}

#productsGrid.catalog-view-list .popular-product-card,
#productsGrid.catalog-view-list .product-card {
    flex-direction: row;
    width: 100%;
    min-width: 0;
    align-items: stretch;
}

#productsGrid.catalog-view-list .product-image-wrapper {
    flex: 0 0 180px;
    width: 180px;
    height: auto;
    min-height: 180px;
    max-height: 220px;
}

#productsGrid.catalog-view-list .product-card-content {
    flex: 1;
    min-width: 0;
    padding: 1.25rem 1.5rem;
}

#productsGrid.catalog-view-list .product-description {
    -webkit-line-clamp: 2;
    line-clamp: 2;
    margin-bottom: 0.75rem;
}

#productsGrid.catalog-view-list .product-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 0.75rem;
}

#productsGrid.catalog-view-list .product-price {
    justify-content: flex-start;
    flex-shrink: 0;
}

#productsGrid.catalog-view-list .btn-add-cart {
    width: auto;
    min-width: 160px;
    justify-content: center;
}

@media (max-width: 767.98px) {
    #productsGrid.catalog-view-list .popular-product-card,
    #productsGrid.catalog-view-list .product-card {
        flex-direction: column;
    }

    #productsGrid.catalog-view-list .product-image-wrapper {
        flex: 0 0 auto;
        width: 100%;
        height: 200px;
        min-height: 0;
        max-height: none;
    }

    #productsGrid.catalog-view-list .product-footer {
        flex-direction: column;
        align-items: stretch;
    }

    #productsGrid.catalog-view-list .product-price {
        justify-content: center;
    }

    #productsGrid.catalog-view-list .btn-add-cart {
        width: 100%;
        min-width: 0;
    }
}

/* ============================================================
   Catalog List View 2.0 — полная переделка (≥992px)
   Строка-карточка: миниатюра | инфо (шапка + описание) | действия
   Правая колонка фиксированной ширины: цена сверху, количество и
   кнопка снизу. Никакой «плавающей» раскладки.
   ============================================================ */

.product-specs {
    display: none;
}

@media (min-width: 992px) {

    /* --- Карточка-строка --- */
    #productsGrid.catalog-view-list {
        gap: 0.45rem;
    }

    #productsGrid.catalog-view-list > .col {
        padding-right: var(--bs-gutter-x, 0);
        padding-left: var(--bs-gutter-x, 0);
    }

    #productsGrid.catalog-view-list .popular-product-card,
    #productsGrid.catalog-view-list .product-card {
        min-height: 172px;
        border-radius: 14px;
        transition: box-shadow 0.25s ease, border-color 0.25s ease;
    }

    #productsGrid.catalog-view-list .popular-product-card:hover,
    #productsGrid.catalog-view-list .product-card:hover {
        box-shadow: 0 10px 30px rgba(37, 99, 235, 0.14);
        border-color: rgba(37, 99, 235, 0.35);
    }

    [data-theme="dark"] #productsGrid.catalog-view-list .popular-product-card:hover,
    [data-theme="dark"] #productsGrid.catalog-view-list .product-card:hover,
    .dark-theme #productsGrid.catalog-view-list .popular-product-card:hover,
    .dark-theme #productsGrid.catalog-view-list .product-card:hover {
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
        border-color: rgba(96, 165, 250, 0.45);
    }

    /* --- Миниатюра слева с разделителем --- */
    #productsGrid.catalog-view-list .product-image-wrapper {
        flex: 0 0 190px;
        width: 190px;
        min-height: 172px;
        max-height: none;
        aspect-ratio: auto;
        height: auto;
        align-self: stretch;
        border-right: 1px solid var(--border-color, #e2e8f0);
        border-radius: 0;
    }

    [data-theme="dark"] #productsGrid.catalog-view-list .product-image-wrapper,
    .dark-theme #productsGrid.catalog-view-list .product-image-wrapper {
        border-right-color: #334155;
    }

    /* --- Контент: две колонки через grid --- */
    #productsGrid.catalog-view-list .product-card-content {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        height: auto;
        position: static;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) max-content;
        grid-template-rows: auto auto 1fr;
        gap: 0.55rem 2.25rem;
        align-items: center;
        align-content: center;
        padding: 1.25rem 1.75rem;
    }

    /* Превью характеристик — только в режиме списка */
    #productsGrid.catalog-view-list .product-specs {
        grid-column: 1;
        grid-row: 2;
        display: flex;
        align-items: baseline;
        gap: 0.35rem 1.4rem;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        font-size: 0.8rem;
        color: var(--text-secondary, #64748b);
        -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent 99%);
        mask-image: linear-gradient(90deg, #000 82%, transparent 99%);
    }

    #productsGrid.catalog-view-list .product-spec {
        flex: 0 0 auto;
        max-width: 260px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #productsGrid.catalog-view-list .product-spec-name {
        color: var(--text-primary, #334155);
        font-weight: 600;
    }

    [data-theme="dark"] #productsGrid.catalog-view-list .product-specs,
    .dark-theme #productsGrid.catalog-view-list .product-specs {
        color: #94a3b8;
    }

    [data-theme="dark"] #productsGrid.catalog-view-list .product-spec-name,
    .dark-theme #productsGrid.catalog-view-list .product-spec-name {
        color: #cbd5e1;
    }

    /* Шапка: артикул + чипы категории/бренда в одну линию */
    #productsGrid.catalog-view-list .product-card-head {
        grid-column: 1;
        grid-row: 1;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-width: 0;
    }

    #productsGrid.catalog-view-list .product-sku {
        margin: 0;
        font-size: 1.02rem;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 60px;
        flex: 0 1 auto;
    }

    #productsGrid.catalog-view-list .product-category,
    #productsGrid.catalog-view-list .product-manufacturer {
        display: inline-flex;
        align-items: center;
        margin: 0;
        padding: 0.28rem 0.7rem;
        border-radius: 999px;
        background: var(--bg-light, #f1f5f9);
        border: 1px solid var(--border-color, #e2e8f0);
        font-size: 0.78rem;
        font-weight: 500;
        color: var(--text-secondary, #475569);
        white-space: nowrap;
        flex-shrink: 0;
    }

    #productsGrid.catalog-view-list .product-category i,
    #productsGrid.catalog-view-list .product-manufacturer i {
        opacity: 0.7;
    }

    [data-theme="dark"] #productsGrid.catalog-view-list .product-category,
    [data-theme="dark"] #productsGrid.catalog-view-list .product-manufacturer,
    .dark-theme #productsGrid.catalog-view-list .product-category,
    .dark-theme #productsGrid.catalog-view-list .product-manufacturer {
        background: rgba(51, 65, 85, 0.55);
        border-color: #334155;
        color: #cbd5e1;
    }

    /* Описание — третья строка левой колонки */
    #productsGrid.catalog-view-list .product-description {
        grid-column: 1;
        grid-row: 3;
        margin: 0;
        flex-grow: 0;
        max-width: none;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    /* Правая колонка действий: цена сверху, управление снизу */
    #productsGrid.catalog-view-list .product-footer {
        grid-column: 2;
        grid-row: 1 / span 3;
        margin-top: 0;
        border-top: none;
        padding-top: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 0.7rem;
        min-width: 230px;
    }

    #productsGrid.catalog-view-list .product-price {
        justify-content: flex-end;
        text-align: right;
    }

    #productsGrid.catalog-view-list .product-price .price-value {
        font-size: 1.22rem;
        font-weight: 700;
    }

    #productsGrid.catalog-view-list .product-order-row {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 0.6rem;
    }

    #productsGrid.catalog-view-list .btn-add-cart {
        width: auto;
        min-width: 148px;
        justify-content: center;
    }

    /* Узкие десктопы: правая колонка уже */
    @media (min-width: 992px) and (max-width: 1199.98px) {
        #productsGrid.catalog-view-list .product-image-wrapper {
            flex-basis: 160px;
            width: 160px;
        }

        #productsGrid.catalog-view-list .product-card-content {
            gap: 0.5rem 1.25rem;
            padding: 1rem;
        }

        #productsGrid.catalog-view-list .product-footer {
            min-width: 200px;
        }

        #productsGrid.catalog-view-list .product-manufacturer {
            display: none;
        }
    }
}
