// Blog Data
const blogData = [
  {
    date: "November 2nd, 2025",
    tags: ["Buyers Guide", "Mumbai", "AVENTURINE"],
    title: "Factors Affecting Property Rates in Mumbai: Complete Guide 2025",
    excerpt:
      "Explore the key factors affecting property prices in Mumbai in 2025 – including demand trends, infrastructure, and market insights. Mumbai is home to a thriving economy, vibrant cultural scene, and some of the most sought-after real estate in India. The ever-increasing appetite for property, coupled with the constrained availability of land in this densely populated...",
    image:
      "https://images.unsplash.com/photo-1486325212027-8081e485255e?w=800&h=500&fit=crop",
  },
  {
    date: "October 28th, 2025",
    tags: ["Investment Tips", "Bangalore", "Real Estate"],
    title: "Why Bangalore Remains India's Premier Real Estate Hub in 2025",
    excerpt:
      "Bangalore continues to dominate the real estate market as the IT capital of India. With consistent growth, excellent infrastructure, and strong rental yields, Bangalore offers unprecedented investment opportunities. Learn about the emerging neighborhoods, infrastructure developments, and why property values continue to appreciate in this tech-driven city. Our comprehensive analysis reveals...",
    image:
      "https://images.unsplash.com/photo-1449844908441-8829872d2607?w=800&h=500&fit=crop",
  },
  {
    date: "October 15th, 2025",
    tags: ["Market Analysis", "Trends", "Hyderabad"],
    title:
      "Hyderabad Real Estate Market: Growth Opportunities and Investment Strategies",
    excerpt:
      "Hyderabad is experiencing rapid urbanization and has emerged as a major real estate destination in South India. With major IT companies establishing offices and continuous infrastructure development, the city offers excellent investment potential. Discover the emerging localities, upcoming projects, and investment opportunities that make Hyderabad an attractive choice for property buyers...",
    image: "./Assets/Images/commercial-4.png",
  },
  {
    date: "September 30th, 2025",
    tags: ["Buyer Guide", "Financing", "Home Loans"],
    title: "Complete Guide to Home Loan Approvals: Everything You Need to Know",
    excerpt:
      "Getting home loan approval is a crucial step in your property purchase journey. Understand the documentation required, eligibility criteria, and approval timeline. This comprehensive guide walks you through the entire process with expert tips on improving your loan approval chances. Learn about different loan options, interest rates, and how AVENTURINE assists buyers in securing...",
    image:
      "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=800&h=500&fit=crop",
  },
  {
    date: "September 12th, 2025",
    tags: ["Luxury Living", "Amenities", "Lifestyle"],
    title: "Luxury Living Redefined: Modern Amenities in AVENTURINE Projects",
    excerpt:
      "Experience world-class living with AVENTURINE's premium amenities designed for modern lifestyle. From smart homes to wellness centers, discover how our projects combine technology with comfort. Our architectural excellence and attention to detail create communities where residents enjoy exceptional quality of life. Explore the amenities that set AVENTURINE projects apart from the competition...",
    image:
      "https://images.unsplash.com/photo-1486312338219-ce68d2c6f44d?w=800&h=500&fit=crop",
  },
  {
    date: "August 25th, 2025",
    tags: ["Investment Guide", "ROI", "Properties"],
    title:
      "Maximizing Returns: Smart Real Estate Investment Strategies for 2025",
    excerpt:
      "Real estate remains one of the best investment options with consistent returns and capital appreciation. Learn proven strategies to maximize your investment returns and build wealth through property. This expert guide covers investment analysis, location selection, timing the market, and long-term wealth creation. Discover how seasoned investors are making smart choices in the current market...",
    image:
      "https://images.unsplash.com/photo-1449844908441-8829872d2607?w=800&h=500&fit=crop",
  },
  {
    date: "August 10th, 2025",
    tags: ["Market News", "Delhi NCR", "Property Prices"],
    title:
      "Delhi NCR Real Estate: Emerging Hotspots and Investment Opportunities",
    excerpt:
      "Delhi NCR region is witnessing unprecedented growth with new infrastructure projects and commercial developments. Identify the emerging hotspots that offer the best investment potential. This analysis covers different zones, price trends, and future growth prospects. Whether you're a first-time buyer or an experienced investor, learn which areas are expected to appreciate significantly...",
    image:
      "https://images.unsplash.com/photo-1449844908441-8829872d2607?w=800&h=500&fit=crop",
  },
  {
    date: "July 18th, 2025",
    tags: ["Sustainability", "Green Living", "Eco-Friendly"],
    title:
      "Sustainable Living: Green Real Estate Projects That Make a Difference",
    excerpt:
      "AVENTURINE is committed to sustainable development and eco-friendly construction practices. Explore how our green projects reduce environmental impact while providing healthy living spaces. Learn about green building certifications, energy-efficient designs, and sustainable materials used in our properties. Discover how choosing eco-friendly properties benefits both your health and the planet while ensuring...",
    image:
      "https://images.unsplash.com/photo-1486325212027-8081e485255e?w=800&h=500&fit=crop",
  },
  {
    date: "July 5th, 2025",
    tags: ["Buyer Tips", "Due Diligence", "Legal"],
    title:
      "Real Estate Due Diligence: Critical Steps Before Buying Your Dream Home",
    excerpt:
      "Before investing in property, thorough due diligence is essential to avoid costly mistakes. Learn the critical checks and verifications every buyer must perform. This guide covers title verification, legal clearances, structural inspection, and documentation. Understand what questions to ask, which documents to review, and how AVENTURINE ensures complete transparency in all our transactions...",
    image:
      "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=800&h=500&fit=crop",
  },
  {
    date: "June 20th, 2025",
    tags: ["Market Trends", "Analysis", "Forecast"],
    title: "2025 Real Estate Market Forecast: Trends and Predictions",
    excerpt:
      "As we move through 2025, market analysts share key trends and predictions for the real estate sector. Understand the factors driving market growth, price movements, and investment opportunities. This detailed forecast covers residential, commercial, and rental markets across major Indian cities. Get insights from industry experts on where the market is heading and how to position...",
    image:
      "https://images.unsplash.com/photo-1449844908441-8829872d2607?w=800&h=500&fit=crop",
  },
];

let currentPage = 1;
const blogsPerPage = 3;
let totalPages = Math.ceil(blogData.length / blogsPerPage);

// Initialize
function init() {
  renderBlogs();
  updatePagination();
}

// Render Blogs
function renderBlogs() {
  const start = (currentPage - 1) * blogsPerPage;
  const end = start + blogsPerPage;
  const paginatedBlogs = blogData.slice(start, end);

  const grid = document.getElementById("blogsGrid");
  grid.innerHTML = "";

  paginatedBlogs.forEach((blog) => {
    const card = document.createElement("div");
    card.className = "blog-card";
    card.innerHTML = `
                    <div class="blog-image-container">
                        <img src="${blog.image}" alt="${blog.title}">
                    </div>
                    <div class="blog-content">
                        <div>
                            <div class="blog-meta">
                                <span class="blog-date">${blog.date}</span>
                            </div>
                            <div class="blog-tags">
                                ${blog.tags
                                  .map(
                                    (tag) =>
                                      `<span class="blog-tag">${tag}</span>`
                                  )
                                  .join(", ")}
                            </div>
                            <h2 class="blog-title">${blog.title}</h2>
                            <p class="blog-excerpt">${blog.excerpt}</p>
                        </div>
                        <div class="blog-footer">
                
                            <a href="blog_detail.html" class="read-more-btn">Continue Reading...</a>
                            <div class="blog-social">
                                <a href="#" class="social-icon" title="Share on Facebook">
                                    <i class="fab fa-facebook-f"></i>
                                </a>
                                <a href="#" class="social-icon" title="Share on Twitter">
                                    <i class="fab fa-twitter"></i>
                                </a>
                                <a href="#" class="social-icon" title="Share on LinkedIn">
                                    <i class="fab fa-linkedin-in"></i>
                                </a>
                                <a href="#" class="social-icon" title="Share via Email">
                                    <i class="fas fa-envelope"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                `;
    grid.appendChild(card);
  });

  window.scrollTo({ top: 0, behavior: "smooth" });
}

// Update Pagination
function updatePagination() {
  const prevBtn = document.getElementById("prevBtn");
  const nextBtn = document.getElementById("nextBtn");
  const pageInfo = document.getElementById("pageInfo");

  prevBtn.disabled = currentPage === 1;
  nextBtn.disabled = currentPage === totalPages;

  pageInfo.textContent = `Page ${currentPage} of ${totalPages}`;
}

// Next Page
function nextPage() {
  if (currentPage < totalPages) {
    currentPage++;
    renderBlogs();
    updatePagination();
  }
}

// Previous Page
function previousPage() {
  if (currentPage > 1) {
    currentPage--;
    renderBlogs();
    updatePagination();
  }
}

// Initialize on load
init();
