/* Home Page Sections - Modern Mobile App Style */

/* ===== Page Layout ===== */
.km-page {
    min-height: calc(100vh - 56px);
}


/* Sidebar sticky layout fix */
.km-wrap > .row {
    align-items: flex-start;
}

.km-wrap > .row > aside {
    position: sticky;
    top: calc(var(--header-height-mobile) + var(--spacing-lg));
}

@media (min-width: 768px) {
    .km-wrap > .row > aside {
        top: calc(var(--header-height-desktop) + var(--spacing-lg));
    }
}

/* ===== Banner Slider ===== */
.banner-slider {
    margin-bottom: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 8px 32px rgba(132, 0, 135, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04);
}

.banner-slider .carousel-inner {
    border-radius: var(--border-radius-lg);
}

.banner-slide-link {
    display: block;
    text-decoration: none;
}

.banner-slide-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.banner-slide-placeholder {
    width: 100%;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: linear-gradient(135deg, 
        rgba(132, 0, 135, 0.05) 0%, 
        rgba(132, 0, 135, 0.02) 100%);
}

/* Carousel Controls Styling */
.banner-slider .carousel-control-prev,
.banner-slider .carousel-control-next {
    width: 40px;
    height: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--border-radius-full);
    opacity: 0;
    transition: all var(--transition-base);
    margin: 0 var(--spacing-md);
}

.banner-slider:hover .carousel-control-prev,
.banner-slider:hover .carousel-control-next {
    opacity: 1;
}

.banner-slider .carousel-control-prev:hover,
.banner-slider .carousel-control-next:hover {
    background: rgba(255, 255, 255, 0.95);
}

.banner-slider .carousel-control-prev-icon,
.banner-slider .carousel-control-next-icon {
    width: 16px;
    height: 16px;
    filter: invert(20%) sepia(50%) saturate(5000%) hue-rotate(290deg) brightness(80%) contrast(100%);
}

/* Carousel Indicators Styling */
.banner-slider .carousel-indicators {
    margin-bottom: var(--spacing-md);
}

.banner-slider .carousel-indicators [data-bs-target] {
    width: 8px;
    height: 8px;
    border-radius: var(--border-radius-full);
    background-color: rgba(255, 255, 255, 0.5);
    border: none;
    margin: 0 4px;
    transition: all var(--transition-base);
}

.banner-slider .carousel-indicators .active {
    width: 24px;
    background-color: var(--color-primary);
}

@media (min-width: 768px) {
    .banner-slide-placeholder {
        min-height: 240px;
    }
    
    .banner-slider .carousel-control-prev,
    .banner-slider .carousel-control-next {
        width: 48px;
        height: 48px;
    }
    
    .banner-slider .carousel-control-prev-icon,
    .banner-slider .carousel-control-next-icon {
        width: 20px;
        height: 20px;
    }
}

@media (min-width: 1200px) {
    .banner-slide-placeholder {
        min-height: 300px;
    }
}

/* ===== Hero Banner (Legacy - keep for compatibility) ===== */
.hero-banner {
    padding: 0 !important;
    overflow: hidden;
    min-height: 180px;
    margin-bottom: var(--spacing-lg);
}

.hero-banner:hover {
    transform: none;
}

.hero-banner-inner {
    width: 100%;
    min-height: 180px;
    background-image: var(--hero-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: var(--border-radius-lg);
}

.hero-banner-placeholder {
    width: 100%;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    background: linear-gradient(135deg, 
        rgba(132, 0, 135, 0.05) 0%, 
        rgba(132, 0, 135, 0.02) 100%);
}

@media (min-width: 768px) {
    .hero-banner,
    .hero-banner-inner,
    .hero-banner-placeholder {
        min-height: 240px;
    }
}

@media (min-width: 1200px) {
    .hero-banner,
    .hero-banner-inner,
    .hero-banner-placeholder {
        min-height: 300px;
    }
}

/* ===== Section Base ===== */
.home-section {
    margin-bottom: var(--spacing-2xl);
}

.home-section:last-child {
    margin-bottom: 0;
}

/* ===== Section Header ===== */
.home-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding: 0 var(--spacing-xs);
}

.home-section-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin: 0;
}

.home-section-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.home-section-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--border-radius-full);
}

.home-section-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.home-section-link:hover {
    color: var(--color-primary-hover);
}

.home-section-link svg {
    transition: transform var(--transition-fast);
}

.home-section-link:hover svg {
    transform: translateX(2px);
}

/* ===== Horizontal Scroll Container ===== */
.home-scroll {
    display: flex;
    gap: var(--spacing-md);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: var(--spacing-xs) 0 var(--spacing-md);
    margin: 0 calc(var(--spacing-xs) * -1);
    padding-left: var(--spacing-xs);
    padding-right: var(--spacing-xs);
}

.home-scroll > * {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* Products scroll variant */
.home-scroll--products {
    gap: var(--spacing-lg);
}

.home-product-item {
    width: 180px;
    flex-shrink: 0;
}

/* ===== Category Card ===== */
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg) !important;
    min-width: 100px;
    text-align: center;
}

.category-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius-md);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all var(--transition-base);
}

.category-card:hover .category-card-icon {
    background: linear-gradient(135deg, rgba(132, 0, 135, 0.15) 0%, rgba(132, 0, 135, 0.08) 100%);
    transform: scale(1.05);
}

.category-card-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-card-placeholder {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
    color: var(--color-primary);
    text-transform: uppercase;
}

.category-card-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Shop Card ===== */
.shop-card {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) !important;
    min-width: 180px;
    max-width: 220px;
}

.shop-card-top {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.shop-card-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.shop-card:hover .shop-card-logo {
    border-color: rgba(132, 0, 135, 0.2);
    box-shadow: 0 4px 12px rgba(132, 0, 135, 0.1);
}

.shop-card-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shop-card-placeholder {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
    color: var(--color-primary);
    text-transform: uppercase;
}

.shop-card-meta {
    min-width: 0;
    flex: 1;
}

.shop-card-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.shop-card-price {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.shop-card-bottom {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--color-border-subtle);
}

.shop-card-rating {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--color-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.shop-card-rating svg {
    color: var(--color-secondary);
}

/* ===== Product Card Styles ===== */
.product-card-wrapper {
    height: 100%;
}

/* Product card glassmorphism override */
.product-card.ui-card {
    padding: 0 !important;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: linear-gradient(135deg, 
        rgba(132, 0, 135, 0.03) 0%, 
        rgba(132, 0, 135, 0.01) 100%);
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

.product-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.product-card-overlay.active {
    display: flex;
}

.product-card-overlay-count {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
}

.product-card-overlay-sum {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
}

.product-card-overlay-nomore {
    font-size: var(--font-size-xs);
    margin-top: var(--spacing-sm);
    display: none;
}

.product-card-badge {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--color-danger);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--border-radius-full);
}

.product-card-favorite {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--color-text-muted);
}

.product-card-favorite:hover {
    background: white;
    color: var(--color-danger);
    transform: scale(1.1);
}

.product-card-favorite.active {
    color: var(--color-danger);
}

.product-card-content {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    flex: 1;
}

.product-card-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.product-card-shop {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
}

.product-card-actions {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--border-radius-full);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.product-card-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--border-radius-full);
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    font-size: var(--font-size-lg);
    transition: all var(--transition-fast);
}

.product-card-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.product-card-btn:active {
    transform: scale(0.95);
}

.product-card-price {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

/* ===== Responsive ===== */
@media (max-width: 576px) {
    .home-section-head {
        flex-wrap: wrap;
    }
    
    /* Увеличиваем заголовки секций на мобильных */
    .home-section-title {
        font-size: var(--font-size-xl);
    }
    
    .home-section-chip {
        font-size: var(--font-size-sm);
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .home-section-link {
        font-size: var(--font-size-base);
    }
    
    .home-section-actions {
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .category-card {
        min-width: 100px;
        padding: var(--spacing-md) !important;
    }
    
    .category-card-icon {
        width: 52px;
        height: 52px;
    }
    
    /* Увеличиваем текст категорий */
    .category-card-name {
        font-size: var(--font-size-base);
        max-width: 110px;
    }
    
    .category-card-placeholder {
        font-size: var(--font-size-xl);
    }
    
    .shop-card {
        min-width: 170px;
        padding: var(--spacing-md) !important;
    }
    
    .shop-card-logo {
        width: 44px;
        height: 44px;
    }
    
    /* Увеличиваем текст магазинов */
    .shop-card-name {
        font-size: var(--font-size-base);
    }
    
    .shop-card-price {
        font-size: var(--font-size-sm);
    }
    
    .shop-card-rating {
        font-size: var(--font-size-base);
    }
    
    .shop-card-placeholder {
        font-size: var(--font-size-xl);
    }
}

/* ===== Marquee with manual drag (auto + ручной) ===== */

.home-scroll.js-marquee {
    overflow: hidden;
    scroll-snap-type: none;
    position: relative;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y; /* разрешаем вертикальный скролл страницы */
}

    .home-scroll.js-marquee:active {
        cursor: grabbing;
    }

    .home-scroll.js-marquee .marquee-track {
        display: flex;
        width: max-content;
        will-change: transform;
        gap: inherit;
        transform: translateX(var(--marquee-x, 0px));
    }

/* Лево -> право: начинаем с -50% (вторая копия слева) и приезжаем в 0 */
@keyframes marquee-ltr {
    from {
        transform: translateX(-50%);
    }

    to {
        transform: translateX(0%);
    }
}

/* Право -> лево: 0 -> -50% */
@keyframes marquee-rtl {
    from {
        transform: translateX(0%);
    }

    to {
        transform: translateX(-50%);
    }
}

/* Пауза при наведении (если не нужно — удали) */
@media (hover: hover) {
    .home-scroll.js-marquee:hover .marquee-track {
        animation-play-state: paused;
    }
}

/* Уважение prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .home-scroll.js-marquee .marquee-track {
        animation: none !important;
        transform: none !important;
    }
}