/* ===================================
   III PM_Ranger - Homepage Styles
   =================================== */

/* ── Hero Banner / Slider ── */
.hero-banner {
    position: relative;
    width: 100%;
    height: clamp(300px, 50vh, 420px);
    overflow: hidden;
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-8);
}

.hero-slides {
    display: flex;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.hero-slide {
    min-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-8);
    position: relative;
}

.hero-slide::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
}

.hero-slide-content {
    position: relative;
    z-index: 1;
    max-width: 700px;
}

.hero-slide h1 {
    font-size: clamp(var(--font-size-2xl), 8vw, var(--font-size-4xl));
    font-weight: var(--font-weight-bold);
    color: var(--white);
    margin-bottom: var(--space-4);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.hero-slide p {
    font-size: var(--font-size-lg);
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: var(--space-6);
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.hero-slide .btn {
    font-size: var(--font-size-base);
    padding: var(--space-4) var(--space-8);
    background: var(--white);
    color: var(--primary-dark);
    font-weight: var(--font-weight-bold);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
}

.hero-slide .btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

/* Banner Dots */
.hero-dots {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: var(--space-2);
    z-index: 2;
}

.hero-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    padding: 0;
}

.hero-dot.active {
    width: 32px;
    background: var(--white);
}

/* Banner Arrows */
.hero-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--white);
    font-size: var(--font-size-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: all var(--transition-base);
}

.hero-arrow:hover {
    background: rgba(249, 115, 22, 0.7);
}

.hero-arrow.prev {
    left: var(--space-4);
}

.hero-arrow.next {
    right: var(--space-4);
}

/* ── Featured Products ── */
.featured-section {
    margin-bottom: var(--space-12);
}

.featured-scroll {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    padding-bottom: var(--space-4);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.featured-scroll::-webkit-scrollbar {
    height: 4px;
}

.featured-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: var(--radius-full);
}

.featured-card {
    min-width: 280px;
    max-width: 100%;
    flex-shrink: 0;
    scroll-snap-align: start;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
}

.featured-card:hover {
    border-color: var(--primary);
    transform: translateY(-6px) scale(1.01);
    box-shadow: 0 0 30px rgba(249, 115, 22, 0.25), 0 10px 40px rgba(0, 0, 0, 0.4);
}

.featured-card-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--orange-800), var(--orange-600));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: var(--font-size-3xl);
    position: relative;
    overflow: hidden;
}

.featured-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.featured-card-img::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.4));
}

.featured-card-badge {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 1;
}

.featured-card-body {
    padding: var(--space-5);
}

.featured-card-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.featured-card-desc {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.featured-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.featured-card-price {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--primary);
}

.featured-card-price small {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    text-decoration: line-through;
    margin-left: var(--space-2);
    font-weight: var(--font-weight-regular);
}

/* ── Categories Grid ── */
.categories-section {
    margin-bottom: var(--space-12);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.category-card {
    aspect-ratio: 940 / 480;
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border-default);
    transition: all 0.3s ease;
}

.category-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.15), 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(249, 115, 22, 0.4);
}

.category-card-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
}

.category-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.category-card:hover .category-card-img {
    opacity: 0.9;
    transform: scale(1.05);
}

.category-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-5);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
}

.category-card-name {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--white);
    margin-bottom: var(--space-1);
}

.category-card-count {
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.7);
}

/* ── All Products Section ── */
.products-section {
    margin-bottom: var(--space-12);
}

.products-layout {
    display: flex;
    gap: var(--space-6);
}

.products-main {
    flex: 1;
    min-width: 0;
}

/* Price Filter Sidebar */
.products-filter {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    align-self: flex-start;
    max-height: calc(100vh - var(--header-height) - var(--space-8));
    overflow-y: auto;
}

.filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.filter-title {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-group {
    margin-bottom: var(--space-5);
}

.filter-group-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

/* Price Range Slider */
.price-range-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.price-range-display .price-value {
    color: var(--primary);
    font-weight: var(--font-weight-bold);
}

.range-slider {
    position: relative;
    width: 100%;
    height: 40px;
}

.range-slider input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-default);
    border-radius: var(--radius-full);
    outline: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--white);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    pointer-events: all;
}

.range-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--white);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    pointer-events: all;
}

/* Category Filter */
.filter-category-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-category-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: var(--font-size-sm);
}

.filter-category-item:hover {
    background: rgba(249, 115, 22, 0.1);
}

.filter-category-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.filter-category-item .cat-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

/* Sort Dropdown */
.sort-select {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.sort-select:focus {
    border-color: var(--primary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-4);
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
}

.product-card:hover {
    border-color: rgba(249, 115, 22, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.12), 0 8px 30px rgba(0, 0, 0, 0.3);
}

.product-card-img-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: linear-gradient(135deg, var(--gray-800), var(--gray-700));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.product-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.product-card:hover .product-card-img-wrap img {
    transform: scale(1.08);
}

.product-card-badge {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 1;
}

.product-card-stock {
    position: absolute;
    bottom: var(--space-3);
    right: var(--space-3);
    z-index: 1;
    font-size: var(--font-size-xs);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.product-card-body {
    padding: var(--space-4);
}

.product-card-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    min-height: calc(var(--font-size-sm) * 1.4 * 2);
}

.product-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.product-card-pricing {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.product-card-price {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--primary);
}

.product-card-original {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-decoration: line-through;
}

.product-card-discount {
    font-size: var(--font-size-xs);
    color: var(--danger);
    font-weight: var(--font-weight-semibold);
}

.product-card-actions {
    display: flex;
    gap: var(--space-2);
}

.product-card-actions .btn {
    flex: 1;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-4);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-text {
    font-size: var(--font-size-lg);
}

/* ── Purchase Modal ── */
.purchase-modal-product {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
}

.purchase-modal-img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--gray-700), var(--gray-600));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    flex-shrink: 0;
    overflow: hidden;
}

.purchase-modal-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.purchase-modal-unit {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: var(--font-weight-regular);
}

.purchase-modal-stock {
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
}

/* ── Purchase Quantity Control ── */
.purchase-quantity-section {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.purchase-quantity-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.purchase-quantity-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}

.purchase-quantity-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.purchase-quantity-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

.purchase-quantity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.purchase-quantity-input {
    width: 80px;
    height: 44px;
    text-align: center;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    -moz-appearance: textfield;
}

.purchase-quantity-input::-webkit-outer-spin-button,
.purchase-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.purchase-quantity-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.purchase-total-price {
    color: var(--primary);
    font-weight: var(--font-weight-bold);
}

/* ── Stock Warning Modal ── */
.stock-warning-content {
    animation: fadeIn 0.3s ease;
}

.stock-warning-message strong {
    font-weight: var(--font-weight-bold);
}

.purchase-modal-info {
    flex: 1;
}

.purchase-modal-name {
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-2);
}

.purchase-modal-price {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--primary);
}

.purchase-summary {
    padding: var(--space-4);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.purchase-summary-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) 0;
    font-size: var(--font-size-sm);
}

.purchase-summary-row.total {
    border-top: 1px solid var(--border-default);
    margin-top: var(--space-2);
    padding-top: var(--space-3);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-base);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .products-filter {
        position: fixed;
        inset: auto 0 0 0;
        width: 100%;
        height: 70vh;
        z-index: var(--z-modal);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        background: var(--bg-card);
        padding: var(--space-6);
        box-shadow: var(--shadow-xl);
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        display: block;
        /* Overwrite sidebar display */
    }

    .products-filter.mobile-open {
        transform: translateY(0);
    }

    .filter-mobile-toggle {
        display: flex !important;
    }
}

@media (min-width: 1025px) {
    .filter-mobile-toggle {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .hero-banner {
        height: 300px;
        border-radius: var(--radius-lg);
    }

    .hero-slide {
        padding: var(--space-6) var(--space-4);
    }

    .hero-slide h1 {
        font-size: clamp(var(--font-size-2xl), 8vw, var(--font-size-3xl));
    }

    .hero-arrow {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-lg);
    }

    .featured-scroll {
        gap: var(--space-3);
        margin: 0 calc(var(--container-padding) * -1);
        padding-left: var(--container-padding);
        padding-right: var(--container-padding);
    }

    .featured-card {
        min-width: 260px;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    .product-card-body {
        padding: var(--space-3);
    }

    .product-card-name {
        font-size: var(--font-size-xs);
        min-height: calc(var(--font-size-xs) * 1.4 * 2);
    }

    .product-card-price {
        font-size: var(--font-size-base);
    }
}

@media (max-width: 480px) {
    .hero-banner {
        height: 240px;
    }

    .hero-slide h1 {
        margin-bottom: var(--space-2);
    }

    .hero-slide p {
        font-size: var(--font-size-sm);
        margin-bottom: var(--space-4);
    }

    .hero-slide .btn {
        padding: var(--space-3) var(--space-6);
        font-size: var(--font-size-sm);
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    .category-card-name {
        font-size: var(--font-size-base);
    }
}