/* ===============================
   CUSTOM SHOP LAYOUT - FORCED STYLES
================================= */

/* Сброс для уверенности */
.custom-shop,
.custom-shop *,
.shop-layout,
.shop-sidebar,
.shop-products-wrapper,
.shop-products,
.product-card {
    box-sizing: border-box;
}

.custom-shop .container {
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 0 20px !important;
    width: 100% !important;
}

.shop-layout {
    display: flex !important;
    gap: 40px !important;
    align-items: flex-start !important;
    width: 100% !important;
    margin-top: 40px;
}

/* ========== SIDEBAR ========== */
.shop-sidebar {
    width: 280px !important;
    flex-shrink: 0 !important;
    background: #ffffff !important;
    border-radius: 24px !important;
    padding: 25px 20px !important;
    border: 1px solid rgba(0, 0, 0, 0.03) !important;
}

.shop-sidebar h3 {
    font-size: 18px !important;
    font-weight: 600 !important;
    margin: 0 0 20px 0 !important;
    color: #1a1a1a !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding-bottom: 12px !important;
    border-bottom: 3px solid #ff1a1a !important;
}

/* All products button */
.shop-sidebar .all-products {
    margin-bottom: 20px !important;
}

.shop-sidebar .all-products a {
    display: block !important;
    background: #1a1a1a !important;
    color: #ffffff !important;
    text-align: center !important;
    padding: 14px 16px !important;
    border-radius: 12px !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    transition: all 0.2s ease !important;
}

.shop-sidebar .all-products a:hover {
    background: #ff1a1a !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 10px 25px rgba(255, 26, 26, 0.3) !important;
}

/* Category list */
.shop-sidebar .category-list-level {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.shop-sidebar .parent-cat {
    margin-bottom: 6px !important;
}

.shop-sidebar .category-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: #f8f8f8 !important;
    border-radius: 12px !important;
    padding: 12px 16px !important;
    border: 1px solid rgba(0, 0, 0, 0.02) !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.shop-sidebar .category-header:hover {
    border-color: rgba(255, 26, 26, 0.3) !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 1px rgba(255, 26, 26, 0.1) !important;
}

.shop-sidebar .category-header a {
    text-decoration: none !important;
    color: #1a1a1a !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    transition: color 0.2s ease !important;
    flex: 1 !important;
}

.shop-sidebar .category-header:hover a {
    color: #ff1a1a !important;
}

/* Arrow */
.shop-sidebar .toggle-arrow {
    width: 24px !important;
    height: 24px !important;
    flex: 0 0 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
}

.shop-sidebar .toggle-arrow::before {
    content: "" !important;
    width: 7px !important;
    height: 7px !important;
    border-right: 2px solid #888 !important;
    border-bottom: 2px solid #888 !important;
    transform: rotate(-45deg) !important;
    transition: all 0.2s ease !important;
}

.shop-sidebar .category-header:hover .toggle-arrow::before {
    border-color: #ff1a1a !important;
}

/* Rotated arrow */
.shop-sidebar .parent-cat.is-open > .category-header .toggle-arrow::before {
    transform: rotate(45deg) !important;
    border-color: #ff1a1a !important;
}

/* Nested categories - CRITICAL FIX */
.shop-sidebar .parent-cat > ul.category-list-level {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    margin: 0 0 0 15px !important;
    padding: 0 !important;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.shop-sidebar .parent-cat.is-open > ul.category-list-level {
    max-height: 500px !important;
    opacity: 1 !important;
    margin: 6px 0 6px 15px !important;
    padding: 2px 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Subcategories */
.shop-sidebar .category-list-level .category-list-level .category-header {
    background: #ffffff !important;
    padding: 10px 14px !important;
    border: 1px solid rgba(0, 0, 0, 0.02) !important;
}

.shop-sidebar .category-list-level .category-list-level .category-header:hover {
    border-color: rgba(255, 26, 26, 0.2) !important;
    background: #fff5f5 !important;
    transform: translateX(3px) !important;
}

/* Active category */
.shop-sidebar .category-header a.active,
.shop-sidebar .category-header a.active:visited {
    color: #ff1a1a !important;
    font-weight: 600 !important;
}

.shop-sidebar .category-header:has(a.active) {
    border-color: rgba(255, 26, 26, 0.3) !important;
    background: #fff5f5 !important;
}

/* ========== PRODUCTS ========== */
.shop-products-wrapper {
    flex: 1 !important;
    width: 100% !important;
}

.shop-products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 30px !important;
    width: 100% !important;
}

/* Product card */
.product-card {
    background: #ffffff !important;
    border-radius: 24px !important;
    padding: 20px !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    border: 1px solid rgba(0, 0, 0, 0.03) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02) !important;
    transition: all 0.3s ease !important;
}

.product-card:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 30px 50px rgba(255, 26, 26, 0.08), 0 0 0 1px rgba(255, 26, 26, 0.15) !important;
    border-color: rgba(255, 26, 26, 0.2) !important;
}

.card-image-wrap {
    position: relative !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    margin-bottom: 16px !important;
    background: #f8f8f8 !important;
    aspect-ratio: 1 / 1 !important;
}

.product-image {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.product-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: transform 0.6s ease !important;
}

.product-card:hover .product-image img {
    transform: scale(1.08) !important;
}

/* Badge */
.product-badge {
    position: absolute !important;
    bottom: 15px !important;
    left: 15px !important;
    background: #ffffff !important;
    color: #ff1a1a !important;
    padding: 6px 14px !important;
    border-radius: 50px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border: 1px solid rgba(255, 26, 26, 0.2) !important;
    z-index: 5 !important;
}

/* Wishlist */
.wishlist-btn {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    width: 40px !important;
    height: 40px !important;
    border: none !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.95) !important;
    color: #999 !important;
    font-size: 18px !important;
    cursor: pointer !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.wishlist-btn:hover {
    transform: scale(1.1) !important;
    border-color: #ff1a1a !important;
    box-shadow: 0 0 20px rgba(255, 26, 26, 0.3) !important;
}

.wishlist-btn.active {
    color: #ff1a1a !important;
}

/* Title */
.product-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    margin: 0 0 15px 0 !important;
    color: #1a1a1a !important;
}

.product-card:hover .product-title {
    color: #ff1a1a !important;
}

/* Price row */
.price-action-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 15px !important;
    margin-top: auto !important;
}

.price-label {
    font-size: 12px !important;
    color: #888 !important;
    margin-bottom: 2px !important;
    text-transform: uppercase !important;
}

.product-price {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #1a1a1a !important;
}

/* Add to cart button */
.card-button .button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #ffffff !important;
    color: #1a1a1a !important;
    border-radius: 40px !important;
    padding: 10px 22px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
}

.card-button .button:hover {
    background: #ff1a1a !important;
    color: #ffffff !important;
    border-color: #ff1a1a !important;
    box-shadow: 0 0 20px rgba(255, 26, 26, 0.3) !important;
    transform: scale(1.02) !important;
}

/* Pagination */
.custom-pagination {
    margin: 60px 0 !important;
    display: flex !important;
    justify-content: center !important;
    gap: 10px !important;
}

.custom-pagination a,
.custom-pagination span {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 45px !important;
    height: 45px !important;
    padding: 0 12px !important;
    border-radius: 12px !important;
    text-decoration: none !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
    font-weight: 500 !important;
    color: #1a1a1a !important;
    background: #ffffff !important;
}

.custom-pagination .current {
    background: #ff1a1a !important;
    color: #ffffff !important;
    border-color: #ff1a1a !important;
}

.custom-pagination a:hover {
    border-color: #ff1a1a !important;
    color: #ff1a1a !important;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .shop-products {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 992px) {
    .shop-layout {
        flex-direction: column !important;
    }
    
    .shop-sidebar {
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    .shop-products {
        gap: 20px !important;
    }
}

@media (max-width: 576px) {
    .shop-products {
        grid-template-columns: 1fr !important;
    }
    
    .product-card {
        flex-direction: row !important;
        align-items: center !important;
        gap: 15px !important;
    }
    
    .card-image-wrap {
        width: 100px !important;
        height: 100px !important;
        margin-bottom: 0 !important;
    }
    
    .price-action-row {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
}



/* =====================================
   MOBILE SIDEBAR / FILTER BURGER
===================================== */

/* По умолчанию кнопку не показываем */
.mobile-filter-toggle {
    display: none !important;
}

/* Обёртка мобильного фильтра */
.mobile-filter-content {
    display: block;
}

/* Начиная с планшета и ниже */
@media (max-width: 992px) {
    .custom-shop .container {
        padding: 0 16px !important;
    }

    .shop-layout {
        flex-direction: column !important;
        gap: 20px !important;
        margin-top: 24px !important;
    }

    /* ВАЖНО:
       sidebar больше не показываем сразу,
       а прячем внутрь mobile-filter-content */
    .shop-sidebar {
        width: 100% !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
    }

    /* Кнопка открытия фильтра */
    .mobile-filter-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        background: #1a1a1a !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 14px !important;
        padding: 14px 18px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        line-height: 1 !important;
        cursor: pointer !important;
        margin-bottom: 14px !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08) !important;
        transition: all 0.25s ease !important;
    }

    .mobile-filter-toggle:hover {
        background: #ff1a1a !important;
    }

    .mobile-filter-toggle::after {
        content: "" !important;
        width: 9px !important;
        height: 9px !important;
        border-right: 2px solid #fff !important;
        border-bottom: 2px solid #fff !important;
        transform: rotate(45deg) !important;
        transition: transform 0.25s ease !important;
        margin-left: 12px !important;
        flex-shrink: 0 !important;
    }

    .mobile-filter-toggle.is-open::after {
        transform: rotate(-135deg) !important;
        margin-top: 4px !important;
    }

    /* Скрытый контейнер */
    .mobile-filter-content {
        display: none !important;
        width: 100% !important;
    }

    .mobile-filter-content.is-open {
        display: block !important;
        animation: mobileFilterFade 0.25s ease;
    }

    @keyframes mobileFilterFade {
        from {
            opacity: 0;
            transform: translateY(-6px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Само меню категорий внутри раскрытия */
    .mobile-filter-content .category-list-level,
    .shop-sidebar .category-list-level {
        margin-top: 0 !important;
    }

    .mobile-filter-content > .category-list-level,
    .shop-sidebar > .category-list-level {
        background: #ffffff !important;
        border: 1px solid rgba(0, 0, 0, 0.05) !important;
        border-radius: 18px !important;
        padding: 14px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03) !important;
    }

    .shop-sidebar h3 {
        display: none !important;
    }

    .shop-sidebar .all-products {
        margin-bottom: 12px !important;
    }

    .shop-sidebar .all-products a {
        padding: 12px 14px !important;
        font-size: 13px !important;
        border-radius: 12px !important;
    }

    .shop-sidebar .category-header {
        padding: 11px 14px !important;
        border-radius: 12px !important;
    }

    .shop-sidebar .category-header a {
        font-size: 14px !important;
        line-height: 1.35 !important;
    }

    .shop-sidebar .parent-cat > ul.category-list-level {
        margin-left: 10px !important;
    }

    .shop-sidebar .parent-cat.is-open > ul.category-list-level {
        margin: 6px 0 6px 10px !important;
    }

    /* Карточки */
    .shop-products-wrapper {
        width: 100% !important;
    }

    .shop-products {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 20px !important;
    }

    .product-card {
        padding: 16px !important;
        border-radius: 20px !important;
    }

    .product-title {
        font-size: 15px !important;
        margin-bottom: 12px !important;
    }

    .product-price {
        font-size: 18px !important;
    }

    .card-button .button {
        padding: 10px 18px !important;
        font-size: 12px !important;
    }
}

/* Телефоны */
@media (max-width: 576px) {
    .custom-shop .container {
        padding: 0 12px !important;
    }

    .shop-layout {
        gap: 16px !important;
        margin-top: 18px !important;
    }

    .mobile-filter-toggle {
        padding: 13px 16px !important;
        border-radius: 12px !important;
        font-size: 13px !important;
        margin-bottom: 12px !important;
    }

    .mobile-filter-content > .category-list-level,
    .shop-sidebar > .category-list-level {
        padding: 12px !important;
        border-radius: 16px !important;
    }

    .shop-products {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .product-card {
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 12px !important;
        min-width: 0 !important;
    }

    .card-image-wrap {
        width: 96px !important;
        height: 96px !important;
        flex: 0 0 96px !important;
        margin-bottom: 0 !important;
        border-radius: 14px !important;
    }

    .product-image,
    .product-image img {
        width: 100% !important;
        height: 100% !important;
    }

    .product-card > * {
        min-width: 0 !important;
    }

    .product-title {
        font-size: 14px !important;
        line-height: 1.35 !important;
        word-break: break-word !important;
    }

    .price-action-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .wishlist-btn {
        width: 34px !important;
        height: 34px !important;
        top: 8px !important;
        right: 8px !important;
        font-size: 15px !important;
    }
}

/* Очень маленькие телефоны */
@media (max-width: 400px) {
    .product-card {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .card-image-wrap {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
    }

    .price-action-row {
        align-items: stretch !important;
    }

    .card-button .button {
        width: 100% !important;
        justify-content: center !important;
    }
}


/* =====================================
   MOBILE CATEGORY SIDEBAR - OFF CANVAS
===================================== */

.mobile-filter-toggle,
.mobile-filter-overlay {
    display: none;
}

@media (max-width: 992px) {
    .shop-sidebar h3 {
        display: none !important;
    }

    .mobile-filter-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        padding: 14px 18px !important;
        background: #1a1a1a !important;
        color: #fff !important;
        border: none !important;
        border-radius: 14px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        margin-bottom: 16px !important;
        position: relative !important;
        z-index: 1001 !important;
    }

    .mobile-filter-toggle::after {
        content: "☰";
        font-size: 16px;
        line-height: 1;
    }

    .mobile-filter-toggle.is-open::after {
        content: "✕";
    }

    .mobile-filter-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.28s ease, visibility 0.28s ease;
        z-index: 1002;
    }

    .mobile-filter-overlay.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-filter-content {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 86%;
        max-width: 340px;
        height: 100vh;
        overflow-y: auto;
        background: #fff;
        padding: 20px 16px 24px;
        box-shadow: 12px 0 30px rgba(0, 0, 0, 0.12);
        transform: translateX(-105%);
        transition: transform 0.3s ease;
        z-index: 1003;
        border-radius: 0 20px 20px 0;
    }

    .mobile-filter-content.is-open {
        transform: translateX(0);
    }

    .mobile-filter-content > .category-list-level {
        margin: 0 !important;
        padding: 0 !important;
        list-style: none !important;
    }

    .shop-sidebar .all-products a,
    .shop-sidebar .category-header a {
        display: block;
        padding: 12px 14px !important;
        border-radius: 12px !important;
        text-decoration: none !important;
    }

    .shop-sidebar .all-products a {
        background: #f7f7f7;
        margin-bottom: 10px;
    }

    .shop-sidebar .category-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        cursor: pointer;
    }

    .shop-sidebar .category-header a {
        flex: 1;
    }

    .shop-sidebar .toggle-arrow {
        width: 10px;
        height: 10px;
        border-right: 2px solid #1a1a1a;
        border-bottom: 2px solid #1a1a1a;
        transform: rotate(45deg);
        transition: transform 0.25s ease;
        flex-shrink: 0;
        margin-right: 6px;
    }

    .shop-sidebar .parent-cat.is-open > .category-header .toggle-arrow {
        transform: rotate(-135deg);
        margin-top: 6px;
    }

    .shop-sidebar .parent-cat > .category-list-level {
        display: none;
        padding-left: 10px !important;
        margin: 6px 0 8px !important;
    }

    .shop-sidebar .parent-cat.is-open > .category-list-level {
        display: block;
    }

    body.mobile-filter-open {
        overflow: hidden;
    }
}


/* =========================================
   MOBILE PRODUCT CARDS FIX
   iPhone 12 Pro / 13 / 14 / 15 sizes
========================================= */

@media (max-width: 430px) {
    .custom-shop .container {
        padding: 0 10px !important;
    }

    .shop-layout {
        gap: 14px !important;
        margin-top: 18px !important;
    }

    .shop-products {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .product-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 14px !important;
        padding: 12px !important;
        border-radius: 22px !important;
        min-height: 150px !important;
    }

    .card-image-wrap {
        width: 112px !important;
        height: 112px !important;
        min-width: 112px !important;
        flex: 0 0 112px !important;
        margin-bottom: 0 !important;
        border-radius: 16px !important;
        aspect-ratio: auto !important;
        overflow: hidden !important;
    }

    .product-image,
    .product-image img {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
        object-fit: cover !important;
    }

    .card-content {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
    }

    .product-title {
        font-size: 14px !important;
        line-height: 1.35 !important;
        margin: 0 0 10px 0 !important;
        word-break: break-word !important;
    }

    .price-action-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        margin-top: 0 !important;
    }

    .price-label {
        font-size: 12px !important;
        margin-bottom: 3px !important;
    }

    .product-price {
        font-size: 17px !important;
        line-height: 1.2 !important;
    }

    .card-button {
        width: 100% !important;
    }

    .card-button .button,
    .card-button a.button,
    .card-button .added_to_cart {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 36px !important;
        padding: 9px 18px !important;
        font-size: 12px !important;
        border-radius: 999px !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }

    .wishlist-btn {
        top: 8px !important;
        right: 8px !important;
        width: 34px !important;
        height: 34px !important;
        font-size: 15px !important;
    }

    .product-badge {
        left: 8px !important;
        bottom: 8px !important;
        padding: 6px 12px !important;
        font-size: 11px !important;
        border-radius: 999px !important;
    }
}

/* Чуть уже экран — немного компактнее, но тот же вид */
@media (max-width: 390px) {
    .product-card {
        gap: 12px !important;
        padding: 11px !important;
        min-height: 144px !important;
    }

    .card-image-wrap {
        width: 115px !important;
        height: 142px !important;
        min-width: 151px !important;
        flex: 0 0 104px !important;
    }

    .product-title {
        font-size: 13px !important;
        margin-bottom: 8px !important;
    }

    .product-price {
        font-size: 16px !important;
    }

    .card-button .button,
    .card-button a.button,
    .card-button .added_to_cart {
        min-height: 34px !important;
        padding: 8px 16px !important;
        font-size: 12px !important;
    }
}
