/* ============================================================
   V14 Store Module - Modern 2026 Enhancements
   Ultra-safe: Additive only, enhances existing styles
   ============================================================ */

/* CSS Custom Properties for easy theming */
:root {
    --store-primary: #0d6efd;
    --store-primary-light: #e7f1ff;
    --store-secondary: #6c757d;
    --store-success: #198754;
    --store-warning: #ffc107;
    --store-danger: #dc3545;
    --store-info: #0dcaf0;
    --store-dark: #212529;
    --store-light: #f8f9fa;
    --store-border: #dee2e6;
    --store-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --store-shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
    --store-radius: 12px;
    --store-radius-sm: 8px;
    --store-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --store-font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dark Mode Variables */
[data-bs-theme="dark"] {
    --store-primary-light: #1a2744;
    --store-light: #1e2130;
    --store-dark: #e9ecef;
    --store-border: #374151;
    --store-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --store-shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.4);
}

/* ---- Global Enhancements ---- */
body {
    font-family: var(--store-font);
}

/* Smooth page transitions */
.page-wrapper {
    animation: fadeInPage 0.4s ease-out;
}

@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Product Card Modern Style ---- */
.product-card,
.product-item,
.col-product {
    transition: var(--store-transition);
}

.product-card:hover,
.product-item:hover {
    transform: translateY(-4px);
}

.product-card .card,
.product-item .card,
.product-card > div {
    border-radius: var(--store-radius) !important;
    box-shadow: var(--store-shadow);
    transition: var(--store-transition);
    overflow: hidden;
    border: none !important;
}

.product-card:hover .card,
.product-item:hover .card,
.product-card:hover > div {
    box-shadow: var(--store-shadow-hover);
}

/* Product image zoom on hover */
.product-card img,
.product-item img,
.product-card .product-image img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover img,
.product-item:hover img {
    transform: scale(1.05);
}

.product-card .product-image,
.product-item .card-img-top-wrapper {
    overflow: hidden;
    border-radius: var(--store-radius) var(--store-radius) 0 0;
}

/* ---- Badges ---- */
.badge-trending,
.badge-best-seller,
.badge-new,
.badge-sale,
.badge-out-of-stock {
    position: absolute;
    top: 12px;
    z-index: 2;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.badge-trending { left: 12px; background: linear-gradient(135deg, #ff6b35, #ff3d00); color: #fff; }
.badge-best-seller { left: 12px; background: linear-gradient(135deg, #ffc107, #ff9800); color: #212529; }
.badge-new { left: 12px; background: linear-gradient(135deg, #00c853, #198754); color: #fff; }
.badge-sale { right: 12px; background: linear-gradient(135deg, #dc3545, #c62828); color: #fff; }
.badge-out-of-stock { left: 12px; background: rgba(0,0,0,0.7); color: #fff; }

/* ---- Quick View Button ---- */
.product-card .quick-view-btn,
.product-item .quick-view-btn {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    color: var(--store-dark);
    border: none;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: var(--store-transition);
    cursor: pointer;
    white-space: nowrap;
    z-index: 3;
}

.product-card:hover .quick-view-btn,
.product-item:hover .quick-view-btn {
    bottom: 15px;
}

.quick-view-btn:hover {
    background: var(--store-primary);
    color: #fff;
}

/* ---- Modern Buttons ---- */
.btn-add-to-cart {
    background: linear-gradient(135deg, var(--store-primary), #0a58ca);
    color: #fff;
    border: none;
    border-radius: var(--store-radius-sm);
    padding: 10px 24px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: var(--store-transition);
}

.btn-add-to-cart:hover {
    background: linear-gradient(135deg, #0a58ca, #084298);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
}

/* ---- Instant Search ---- */
.instant-search-wrapper {
    position: relative;
    z-index: 1050;
}

.instant-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 0 0 var(--store-radius) var(--store-radius);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1051;
}

[data-bs-theme="dark"] .instant-search-results {
    background: #2d3748;
}

.instant-search-results.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    gap: 12px;
    border-bottom: 1px solid var(--store-border);
}

.search-result-item:hover {
    background: var(--store-primary-light);
    text-decoration: none;
    color: inherit;
}

.search-result-item img {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: var(--store-radius-sm);
}

.search-result-item .product-info {
    flex: 1;
}

.search-result-item .product-info .name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.search-result-item .product-info .category {
    font-size: 12px;
    color: var(--store-secondary);
}

.search-result-item .price {
    font-weight: 700;
    color: var(--store-primary);
    font-size: 15px;
}

/* ---- Filter Sidebar ---- */
.filter-sidebar {
    background: #fff;
    border-radius: var(--store-radius);
    box-shadow: var(--store-shadow);
    padding: 24px;
}

[data-bs-theme="dark"] .filter-sidebar {
    background: #2d3748;
}

.filter-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--store-border);
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.filter-section h6 {
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Price range slider */
.price-range-slider .noUi-connect {
    background: var(--store-primary);
}

/* ---- Social Proof ---- */
.social-proof-notification {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #fff;
    border-radius: var(--store-radius);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 350px;
    z-index: 9999;
    animation: slideInLeft 0.5s ease-out;
    transition: var(--store-transition);
}

[data-bs-theme="dark"] .social-proof-notification {
    background: #2d3748;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-100px); }
    to { opacity: 1; transform: translateX(0); }
}

.social-proof-notification.fade-out {
    opacity: 0;
    transform: translateX(-100px);
}

.social-proof-notification img {
    width: 50px;
    height: 50px;
    border-radius: var(--store-radius-sm);
    object-fit: cover;
}

.social-proof-notification .info {
    flex: 1;
}

.social-proof-notification .info .name {
    font-weight: 700;
    font-size: 13px;
}

.social-proof-notification .info .detail {
    font-size: 12px;
    color: var(--store-secondary);
}

.social-proof-notification .close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 14px;
    color: var(--store-secondary);
    cursor: pointer;
}

/* Purchase counter on product page */
.purchase-counter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--store-primary-light);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--store-primary);
}

.purchase-counter i {
    font-size: 14px;
}

/* Review summary bar */
.review-summary-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.review-summary-bar .stars {
    width: 40px;
    font-size: 13px;
    font-weight: 600;
}

.review-summary-bar .bar-bg {
    flex: 1;
    height: 8px;
    background: var(--store-border);
    border-radius: 4px;
    overflow: hidden;
}

.review-summary-bar .bar-fill {
    height: 100%;
    background: var(--store-warning);
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.review-summary-bar .count {
    width: 30px;
    font-size: 12px;
    color: var(--store-secondary);
    text-align: right;
}

/* ---- Sticky Add to Cart Bar ---- */
.sticky-add-to-cart {
    position: fixed;
    top: -80px;
    left: 0;
    right: 0;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 12px 0;
    z-index: 1040;
    transition: top 0.3s ease;
}

[data-bs-theme="dark"] .sticky-add-to-cart {
    background: #1e2130;
}

.sticky-add-to-cart.visible {
    top: 0;
}

.sticky-add-to-cart .product-summary {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sticky-add-to-cart img {
    width: 45px;
    height: 45px;
    border-radius: var(--store-radius-sm);
    object-fit: cover;
}

.sticky-add-to-cart .product-name {
    font-weight: 600;
    font-size: 14px;
}

.sticky-add-to-cart .product-price {
    font-weight: 700;
    color: var(--store-primary);
    font-size: 18px;
}

/* ---- Recently Viewed ---- */
.recently-viewed-section {
    padding: 40px 0;
}

.recently-viewed-section h5 {
    font-weight: 700;
    margin-bottom: 20px;
}

.recently-viewed-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.recently-viewed-scroll::-webkit-scrollbar {
    height: 4px;
}

.recently-viewed-scroll::-webkit-scrollbar-track {
    background: var(--store-border);
    border-radius: 2px;
}

.recently-viewed-scroll::-webkit-scrollbar-thumb {
    background: var(--store-primary);
    border-radius: 2px;
}

.recently-viewed-item {
    flex: 0 0 180px;
    scroll-snap-align: start;
    text-decoration: none;
    color: inherit;
}

.recently-viewed-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: var(--store-radius);
    margin-bottom: 8px;
}

.recently-viewed-item .name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recently-viewed-item .price {
    font-size: 14px;
    font-weight: 700;
    color: var(--store-primary);
}

/* ---- Quick View Modal ---- */
#quickViewModal .modal-content {
    border-radius: var(--store-radius);
    overflow: hidden;
    border: none;
}

#quickViewModal .modal-body {
    padding: 30px;
}

/* ---- Loading Skeletons ---- */
.skeleton-card {
    background: #fff;
    border-radius: var(--store-radius);
    box-shadow: var(--store-shadow);
    overflow: hidden;
}

.skeleton-image {
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 14px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin: 12px 16px;
}

.skeleton-text.short {
    width: 60%;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ---- Cart Cross-Sell ---- */
.cross-sell-section {
    padding: 30px 0;
    border-top: 1px solid var(--store-border);
    margin-top: 30px;
}

.cross-sell-section h5 {
    font-weight: 700;
    margin-bottom: 20px;
}

/* ---- Mobile Bottom Nav ---- */
@media (max-width: 768px) {
    .store-mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        display: flex;
        justify-content: space-around;
        padding: 8px 0;
        z-index: 1050;
    }

    [data-bs-theme="dark"] .store-mobile-bottom-nav {
        background: #1e2130;
    }

    .store-mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--store-secondary);
        font-size: 10px;
        font-weight: 600;
        padding: 4px 0;
    }

    .store-mobile-bottom-nav a.active {
        color: var(--store-primary);
    }

    .store-mobile-bottom-nav a i {
        font-size: 20px;
        margin-bottom: 2px;
    }

    /* Add padding to body so content isn't hidden behind bottom nav */
    body {
        padding-bottom: 70px;
    }

    /* Product card adjustments for mobile */
    .product-card .card,
    .product-item .card {
        border-radius: var(--store-radius-sm) !important;
    }
}

/* ---- Product page image gallery zoom ---- */
.product-gallery-zoom {
    position: relative;
    overflow: hidden;
    cursor: zoom-in;
}

.product-gallery-zoom:hover img {
    transform: scale(1.3);
    transition: transform 0.3s ease;
}

/* ---- Lazy load fade-in ---- */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.4s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"][complete] {
    opacity: 1;
}

/* ---- Animation classes ---- */
.store-fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.store-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Cross-sell horizontal scroll ---- */
.recommendations-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 10px 0;
    scroll-snap-type: x mandatory;
}

.recommendations-scroll .rec-card {
    flex: 0 0 200px;
    scroll-snap-align: start;
    text-decoration: none;
    color: inherit;
}

.recommendations-scroll .rec-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--store-radius);
}

.recommendations-scroll .rec-card .rec-name {
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recommendations-scroll .rec-card .rec-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--store-primary);
}
