:root {
    --market-primary: #ff9933;
    /* Saffron/Marigold */
    --market-secondary: #138808;
    /* India Green */
    --market-dark: #000080;
    /* Navy Blue (Chakra) */
    --market-bg: #fdfbf7;
    /* Off-white/Cream */
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.12);
}

/* Override global .contain grid layout for this page */
.contain {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-template-columns: unset !important;
}

body {
    background-color: var(--market-bg);
    font-family: 'Poppins', sans-serif;
    /* Adding a cleaner font preference */
}

/* Header Section */
.market-header {
    background: linear-gradient(135deg, var(--market-primary), #ffb366);
    padding: 20px 15px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    box-shadow: var(--shadow-md);
    color: white;
    margin-bottom: 25px;
    position: sticky;
    top: 60px;
    /* Adjust based on navbar height */
    z-index: 99;
}

.market-title {
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.location-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 5px;
    display: inline-block;
}

/* Location Request Card */
.location-request-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: var(--shadow-md);
    margin-top: 40px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.location-icon-circle {
    width: 80px;
    height: 80px;
    background: #eef2ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: var(--market-dark);
}

.btn-locate {
    background-color: var(--market-dark);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-weight: 600;
    transition: transform 0.2s;
}

.btn-locate:hover {
    transform: translateY(-2px);
    background-color: #000066;
}

/* Range Slider Control */
.range-control-panel {
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
}

/* Categories Scroll (The "Lanes") */
.cat-scroll-wrapper {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 15px;
    margin-top: -10px;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

.cat-pill {
    display: inline-block;
    background: white;
    border: 1px solid #eee;
    padding: 8px 18px;
    border-radius: 20px;
    margin-right: 10px;
    color: var(--text-main);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-decoration: none;
    /* Ensure link underline is removed */
    cursor: pointer;
}

.cat-pill:hover {
    background: #f8f9fa;
    color: var(--market-dark);
}

.cat-pill.active {
    background: var(--market-secondary);
    color: white;
    border-color: var(--market-secondary);
}

/* Product Grid */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 80px;
}

/* Override global .contain flex layout for this page */
.market-grid,
.market-header,
.range-control-panel,
.cat-scroll-wrapper {
    display: block !important;
}

.market-grid {
    display: grid !important;
}

/* Product Card Link Wrapper */
.product-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.product-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card-link:hover .product-card {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: var(--market-primary);
}

.product-card-link:hover .product-img-wrap img {
    transform: scale(1.05);
}

.product-img-wrap {
    position: relative;
    height: 160px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
}

.product-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.price-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, var(--market-primary), #ff7700);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(255, 153, 51, 0.4);
    display: flex;
    align-items: center;
    gap: 4px;
}

.price-tag::before {
    content: '₹';
    font-size: 0.85em;
    opacity: 0.9;
}

.card-body-custom {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prod-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--text-main);
    line-height: 1.3;
    text-transform: capitalize;
}

.prod-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.prod-meta {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.prod-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.prod-meta i {
    color: var(--market-primary);
}

.action-btn {
    width: 100%;
    margin-top: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 8px;
    font-weight: 600;
}

/* Floating Action Button */
.fab-sell {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: linear-gradient(135deg, var(--market-primary), #ff7700);
    color: white;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(255, 153, 51, 0.4);
    font-size: 26px;
    z-index: 100;
    transition: all 0.3s ease;
}

.fab-sell:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 8px 28px rgba(255, 153, 51, 0.6);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .market-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .fab-sell {
        bottom: 80px;
        right: 15px;
        width: 56px;
        height: 56px;
        font-size: 22px;
    }

    .product-img-wrap {
        height: 140px;
    }

    .prod-title {
        font-size: 0.95rem;
    }

    .price-tag {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .owned-shop-badge i {
        font-size: 11px;
    }
}

.card-notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 14px;
    height: 14px;
    background-color: #ef4444;
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 20;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .market-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }

    .product-img-wrap {
        height: 150px;
    }
}

@media (min-width: 1024px) {
    .market-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 18px;
    }

    .product-img-wrap {
        height: 180px;
    }
}

/* Owned Shop Highlighting */
.owned-shop-card {
    border: 2px solid var(--market-primary) !important;
    background: linear-gradient(to bottom, #fffef5, #ffffff) !important;
    position: relative;
    box-shadow: 0 8px 20px rgba(255, 153, 51, 0.15) !important;
}

.owned-shop-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--market-primary);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Closed Shop Card */
.shop-closed-card {
    opacity: 0.72;
    filter: grayscale(30%);
    cursor: not-allowed;
}

.product-card-link[data-closed="true"]:hover .product-card {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: #fca5a5;
    cursor: not-allowed;
}