html {
    font-size: 14px;
    height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    background-color: #f4f6f9;
    margin: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100dvh;
    padding-bottom: 70px;
}

@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }
}

header, main, footer {
    position: static;
}

main {
    padding-bottom: 2rem;
}

.footer {
    background-color: #fff;
    border-top: 1px solid #e9ecef;
    width: 100%;
}

.navbar {
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.navbar-brand img.brand-logo {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.navbar-search input {
    border-radius: 20px 0 0 20px;
    border-right: none;
}

.navbar-search button {
    border-radius: 0 20px 20px 0;
}

.hero-banner {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #fff;
    padding: 60px 0;
    border-radius: 20px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.hero-title {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.hero-logo {
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.3));
    border-radius: 15px;
}

.category-card-ref {
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

    .category-card-ref:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0,0,0,0.08);
        border-color: #0d6efd;
    }

.category-img-wrap {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .category-img-wrap img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        transition: transform 0.3s ease;
    }

.category-card-ref:hover .category-img-wrap img {
    transform: scale(1.1);
}

.category-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #e3f2fd;
    color: #0d6efd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.product-card {
    border: 1px solid #eaeaea;
    border-radius: 12px;
    transition: all 0.3s ease;
    background: #fff;
    overflow: hidden;
}

    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 24px rgba(0,0,0,0.1) !important;
        border-color: #0d6efd;
    }

.product-image-wrap {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

    .product-image-wrap img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain;
        transition: transform 0.3s ease;
    }

.product-card:hover .product-image-wrap img {
    transform: scale(1.05);
}

.price {
    font-size: 1.15rem;
    font-weight: 800;
    color: #d32f2f;
}

.old-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.9rem;
    margin-right: 5px;
}

.price-block {
    display: flex;
    align-items: baseline;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    padding: 10px 20px;
    transition: all 0.2s;
}

    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
    }

/* ============================================
   КНОПКА «НАЗАД В КАТАЛОГ» НА СТРАНИЦЕ ТОВАРА
   ============================================ */
.product-back-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.back-to-catalog {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fff;
    color: #0d6efd;
    border: 1px solid #dbe4f0;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.06);
}

    .back-to-catalog i {
        font-size: 1.1rem;
        transition: transform 0.2s ease;
    }

    .back-to-catalog:hover {
        background: #0d6efd;
        color: #fff;
        border-color: #0d6efd;
        box-shadow: 0 6px 16px rgba(13, 110, 253, 0.25);
        transform: translateY(-1px);
    }

        .back-to-catalog:hover i {
            transform: translateX(-3px);
        }

    .back-to-catalog:active {
        transform: translateY(0);
    }

/* ============================================
   ГАЛЕРЕЯ ТОВАРА — ГЛАВНОЕ ФОТО (ПК)
   ============================================ */
.main-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

    .main-image-container .main-image {
        display: block;
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }

/* ============================================
   ГАЛЕРЕЯ ТОВАРА — МИНИАТЮРЫ
   ============================================ */
.thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.thumb-image {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
    background: #fff;
    padding: 2px;
}

    .thumb-image:hover,
    .thumb-image.active {
        border-color: #0d6efd;
        transform: translateY(-1px);
    }

/* ============================================
   СЕТКА ТОВАРА
   ============================================ */
.product-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 15px !important;
    margin: 0 auto !important;
    box-sizing: border-box !important;
}

.product-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px;
    width: 100% !important;
}

@media (min-width: 992px) {
    .product-layout {
        flex-direction: row !important;
        align-items: flex-start;
    }

    .product-gallery {
        width: 50% !important;
        min-width: 0;
    }

    .product-details {
        width: 50% !important;
        min-width: 0;
    }
}

.product-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    width: 100% !important;
}

/* Форма: всегда колонка до 768px */
.cart-form-flex {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
    width: 100% !important;
}

/* В ряд только на широких экранах */
@media (min-width: 768px) {
    .cart-form-flex {
        flex-direction: row !important;
    }

    .quantity-input {
        width: 100px !important;
        flex-shrink: 0;
    }
}

.rating-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 5px;
    font-size: 2rem;
    line-height: 1;
}

    .rating-input input {
        display: none;
    }

    .rating-input label {
        color: #ddd;
        cursor: pointer;
        transition: color 0.15s;
        padding: 0 2px;
    }

        .rating-input label:hover, .rating-input label:hover ~ label, .rating-input input:checked ~ label {
            color: #ffc107;
        }

.call-fab, .cart-fab {
    position: fixed;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 9999;
    transition: transform 0.2s;
    text-decoration: none;
}

.call-fab {
    right: 20px;
    background-color: #28a745;
    color: white;
}

.cart-fab {
    right: 90px;
    background-color: #0d6efd;
    color: white;
}

    .call-fab:hover, .cart-fab:hover {
        transform: scale(1.1);
        color: white;
    }

.call-fab-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #28a745;
    opacity: 0.5;
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    70% {
        transform: scale(1.5);
        opacity: 0;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.cart-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #dc3545;
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.cart-toast {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
    border-left: 4px solid #28a745;
    animation: slideInRight 0.3s ease-out;
    max-width: 380px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.cart-toast.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    z-index: 99999;
    border-top: 1px solid #eaeaea;
}

    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: #6c757d;
        font-size: 0.7rem;
        font-weight: 600;
        gap: 4px;
    }

        .mobile-bottom-nav .nav-item i {
            font-size: 1.5rem;
        }

        .mobile-bottom-nav .nav-item.active {
            color: #0d6efd;
        }

        .mobile-bottom-nav .nav-item.text-success {
            color: #28a745 !important;
        }

/* ============================================
   МОБИЛЬНАЯ ВЕРСИЯ
   ============================================ */
@media (max-width: 767.98px) {
    .call-fab, .cart-fab, .call-fab-pulse {
        display: none !important;
    }

    .hero-banner {
        padding: 30px 15px !important;
        text-align: center !important;
        border-radius: 0 !important;
        margin-bottom: 1.5rem !important;
    }

    .hero-title {
        font-size: 1.8rem !important;
    }

    .hero-logo {
        margin-top: 15px !important;
        max-height: 180px !important;
    }

    .product-image-wrap {
        height: 140px !important;
        padding: 10px !important;
    }

    .product-card .card-body {
        padding: 0.75rem !important;
    }

    .product-card .card-title {
        font-size: 0.85rem !important;
    }

    .product-card .price {
        font-size: 1rem !important;
    }

    .category-img-wrap {
        height: 80px !important;
    }

    .category-card-ref {
        padding: 10px !important;
    }

    .rating-input {
        font-size: 1.8rem !important;
        gap: 3px !important;
    }

    .product-title {
        font-size: 1.4rem !important;
        word-break: normal !important;
    }

    .price-block {
        display: block !important;
        text-align: left !important;
        margin-bottom: 15px !important;
    }

    .price.fs-2 {
        font-size: 1.8rem !important;
        display: block !important;
    }

    .old-price.fs-5 {
        font-size: 1rem !important;
        display: block !important;
    }

    .cart-toast {
        left: 20px !important;
        right: 20px !important;
        bottom: 80px !important;
        max-width: none !important;
    }

    /* Кнопка «Назад в каталог» на мобилке */
    .product-back-row {
        margin-bottom: 12px;
    }

    .back-to-catalog {
        width: auto !important;
        padding: 10px 20px;
        margin: 0 auto;
        font-size: 0.95rem;
    }

    /* ============================================
       НОВАЯ МОБИЛЬНАЯ ГАЛЕРЕЯ (ЧИСТЫЙ CSS СВАЙП)
       ============================================ */
    .mobile-native-swipe-gallery {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        gap: 10px;
        padding-bottom: 5px;
    }

        .mobile-native-swipe-gallery::-webkit-scrollbar {
            display: none;
        }

    .mobile-native-swipe-gallery {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .mobile-swipe-item {
        flex: 0 0 100%;
        scroll-snap-align: center;
        height: 300px;
        background: #fff;
        border: 1px solid #eaeaea;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 10px;
    }

        .mobile-swipe-item img {
            display: block;
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto;
            object-fit: contain;
        }

    /* ============================================
       МОБИЛЬНЫЕ ФИЛЬТРЫ (ШТОРКИ СВЕРХУ)
       ============================================ */
    .sticky-mobile-toolbar {
        position: sticky;
        top: 10px;
        z-index: 100;
    }

    .mobile-filter-sheet-top {
        height: auto !important;
        max-height: 85vh;
        border-radius: 0 0 20px 20px !important;
        border: none;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    }
}

/* Очень маленькие экраны — миниатюры чуть меньше */
@media (max-width: 575.98px) {
    .thumbnails-grid {
        grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
        gap: 6px;
    }
}
