<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DEALKO - Varanasi Ka Online Marketplace | Buy Sell Property Car Phone</title>

    <meta name="description" content="Varanasi mein property, car, phone kharido ya becho. Free listing, direct seller contact. No broker, no commission. DEALKO.in">
    <meta name="keywords" content="varanasi property, varanasi car sale, varanasi buy sell, property dealer varanasi, second hand car varanasi, phone sale varanasi, dealko">
    <meta name="author" content="DEALKO">
    <meta name="robots" content="index, follow">
    <link rel="canonical" href="https://dealko.in/">

    <meta property="og:type" content="website">
    <meta property="og:title" content="DEALKO - Varanasi Ka Online Marketplace">
    <meta property="og:description" content="Property, car, phone kharido ya becho Varanasi mein. Free listing. Direct contact.">
    <meta property="og:url" content="https://dealko.in/">
    <meta property="og:image" content="https://dealko.in/icons/icon-512.png">
    <meta property="og:image:width" content="512">
    <meta property="og:image:height" content="512">
    <meta property="og:locale" content="hi_IN">
    <meta property="og:site_name" content="DEALKO">

    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:title" content="DEALKO - Varanasi Ka Online Marketplace">
    <meta name="twitter:description" content="Free listing. Direct seller. No broker. DEALKO.in">
    <meta name="twitter:image" content="https://dealko.in/icons/og-image.jpg">

    <link rel="preconnect" href="https://firebasestorage.googleapis.com">
    <link rel="preconnect" href="https://www.gstatic.com">
    <link rel="dns-prefetch" href="https://firebasestorage.googleapis.com">
    <link rel="preload" href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" as="style">
    <link rel="preload" href="/icons/icon-192.png" as="image">

    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "WebSite",
      "name": "DEALKO",
      "url": "https://dealko.in",
      "description": "Varanasi ka online marketplace for property, cars, phones and more",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "https://dealko.in/listings.html?q={search_term_string}",
        "query-input": "required name=search_term_string"
      }
    }
    </script>
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      "name": "DEALKO",
      "description": "Varanasi ka online marketplace for property, cars, phones and more",
      "url": "https://dealko.in",
      "logo": "https://dealko.in/icons/icon-512.png",
      "image": "https://dealko.in/icons/og-image.jpg",
      "address": {
        "@type": "PostalAddress",
        "addressLocality": "Varanasi",
        "addressRegion": "Uttar Pradesh",
        "addressCountry": "IN"
      },
      "geo": {
        "@type": "GeoCoordinates",
        "latitude": "25.3176",
        "longitude": "82.9739"
      },
      "areaServed": {
        "@type": "City",
        "name": "Varanasi"
      },
      "priceRange": "Free",
      "sameAs": [
        "https://www.youtube.com/@dealko",
        "https://www.facebook.com/dealko"
      ]
    }
    </script>
    <meta name="theme-color" content="#6C5CE7">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="apple-mobile-web-app-title" content="DEALKO">
    <meta name="mobile-web-app-capable" content="yes">

    <link rel="manifest" href="/manifest.json">
    <link rel="icon" type="image/svg+xml" href="/icon.svg">
    <link rel="apple-touch-icon" href="/icon.svg">

    <!-- Cache Busting: Force refresh when new version deployed -->
    <script src="/cache-bust.js"></script>

        <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="/design-system.css">
<script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-app-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-auth-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore-compat.js"></script>
    <script src="https://www.gstatic.com/firebasejs/9.22.0/firebase-storage-compat.js"></script>
    <script src="theme.js"></script>
    <script type="module" src="/tracking.js" defer></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Poppins', 'Inter', 'Segoe UI', sans-serif;
            background-color: #FFFFFF;
            color: #2D3436;
            line-height: 1.6;
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 1 - NAVBAR
           ═══════════════════════════════════════════════════════════ */
        .navbar {
            position: sticky;
            top: 0;
            z-index: 1000;
            background-color: #FFFFFF;
            padding: 16px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            width: 100%;
        }

        .nav-brand h1 {
            font-size: 1.8em;
            font-weight: 700;
            color: #6C5CE7;
            margin: 0;
        }

        .nav-menu {
            display: flex;
            gap: 12px;
            align-items: center;
        }

        .nav-btn {
            padding: 10px 20px;
            border-radius: 8px;
            border: 2px solid #6C5CE7;
            background: transparent;
            color: #6C5CE7;
            cursor: pointer;
            font-size: 0.95em;
            font-weight: 600;
            transition: all 0.3s ease;
        }

        .nav-btn:hover {
            background-color: #6C5CE7;
            color: white;
        }

        .nav-btn.filled {
            background-color: #6C5CE7;
            color: white;
        }

        .nav-btn.filled:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 2 - HERO
           ═══════════════════════════════════════════════════════════ */
        .hero {
            background: linear-gradient(135deg, #FFFFFF 0%, #F9F7F4 100%);
            padding: 80px 20px;
            text-align: center;
            min-height: 500px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .hero h1 {
            font-size: 3.2em;
            font-weight: 700;
            color: #6C5CE7;
            margin-bottom: 16px;
            line-height: 1.2;
        }

        .hero .subheadline {
            font-size: 1.4em;
            color: #2D3436;
            margin-bottom: 32px;
            font-weight: 500;
        }

        .search-section {
            max-width: 600px;
            margin: 0 auto 32px;
            width: 100%;
        }

        .search-bar {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .search-input {
            flex: 1;
            min-width: 250px;
            padding: 14px 20px;
            border: 2px solid #E8E8E8;
            border-radius: 8px;
            font-size: 1em;
            transition: all 0.3s ease;
        }

        .search-input:focus {
            outline: none;
            border-color: #6C5CE7;
            box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
        }

        .search-btn {
            padding: 14px 28px;
            background-color: #6C5CE7;
            color: white;
            border: none;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .search-btn:hover {
            background-color: #5B4BD9;
            transform: translateY(-2px);
        }

        .filter-pills {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
            font-size: 0.95em;
        }

        .filter-pill {
            padding: 8px 16px;
            border: 1px solid #E8E8E8;
            background: white;
            border-radius: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #2D3436;
            font-weight: 500;
        }

        .filter-pill:hover,
        .filter-pill.active {
            background-color: #6C5CE7;
            color: white;
            border-color: #6C5CE7;
        }

        .hero-buttons {
            display: flex;
            gap: 16px;
            justify-content: center;
            flex-wrap: wrap;
            margin-top: 24px;
        }

        .btn-primary,
        .btn-secondary {
            padding: 14px 32px;
            border-radius: 8px;
            font-size: 1.05em;
            font-weight: 600;
            cursor: pointer;
            border: none;
            transition: all 0.3s ease;
        }

        .btn-primary {
            background-color: #6C5CE7;
            color: white;
        }

        .btn-primary:hover {
            background-color: #5B4BD9;
            transform: translateY(-2px);
        }

        .btn-secondary {
            background: transparent;
            color: #6C5CE7;
            border: 2px solid #6C5CE7;
        }

        .btn-secondary:hover {
            background-color: #6C5CE7;
            color: white;
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 4 - CATEGORIES
           ═══════════════════════════════════════════════════════════ */
        .categories-section {
            padding: 80px 20px;
            background-color: #FAFAFA;
        }

        .section-title {
            font-size: 2.2em;
            font-weight: 700;
            color: #2D3436;
            text-align: center;
            margin-bottom: 50px;
        }

        .categories-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 24px;
            max-width: 1200px;
            margin: 0 auto;
        }

        .category-card {
            background: white;
            padding: 32px 24px;
            border-radius: 12px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid #E8E8E8;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        }

        .category-card:hover {
            border-color: #6C5CE7;
            transform: translateY(-8px);
            box-shadow: 0 8px 24px rgba(108, 92, 231, 0.15);
        }

        .category-icon {
            font-size: 3em;
            margin-bottom: 16px;
        }

        .category-title {
            font-size: 1.3em;
            font-weight: 700;
            color: #2D3436;
            margin-bottom: 8px;
        }

        .category-description {
            font-size: 0.95em;
            color: #7F8C8D;
            margin: 0;
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 5 - LATEST LISTINGS
           ═══════════════════════════════════════════════════════════ */
        .listings-section {
            padding: 80px 20px;
            background-color: #FFFFFF;
        }

        .listings-section.hidden {
            display: none;
        }

        .listings-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
            max-width: 1200px;
            margin: 0 auto 40px;
        }

        @media (min-width: 768px) {
            .listings-grid {
                grid-template-columns: repeat(3, 1fr);
                gap: 24px;
            }
        }

        @media (max-width: 1024px) {
            .listings-grid {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        .listing-card {
            background: #FFFFFF;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            flex-direction: column;
            border: 1px solid #E8E8E8;
        }

        .listing-card:hover {
            box-shadow: 0 8px 20px rgba(108, 92, 231, 0.15);
            transform: translateY(-4px);
        }

        .listing-image-wrapper {
            position: relative;
            width: 100%;
            height: 180px;
            overflow: hidden;
            background-color: #F5F5F5;
        }

        .listing-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.3s ease;
        }

        .listing-card:hover .listing-image {
            transform: scale(1.05);
        }

        .category-badge {
            position: absolute;
            top: 10px;
            left: 10px;
            padding: 6px 12px;
            background: #6C5CE7;
            color: white;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 600;
        }

        .like-btn {
            position: absolute;
            top: 10px;
            right: 10px;
            background: rgba(0, 0, 0, 0.5);
            border: none;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
            color: white;
        }

        .like-btn:hover {
            background: rgba(0, 0, 0, 0.7);
        }

        .like-btn.liked {
            color: #FF6B6B;
        }

        .like-icon {
            width: 20px;
            height: 20px;
        }

        .listing-info {
            padding: 14px;
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .listing-title {
            font-size: 15px;
            font-weight: 600;
            color: #2D3436;
            margin: 0;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            line-height: 1.3;
        }

        .listing-price {
            font-size: 18px;
            font-weight: 700;
            color: #6C5CE7;
            margin: 0;
        }

        .listing-meta {
            display: flex;
            flex-direction: column;
            gap: 6px;
            font-size: 12px;
            color: #636E72;
        }

        .location-info {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .location-info svg {
            width: 14px;
            height: 14px;
        }

        .time-info {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .time-info svg {
            width: 14px;
            height: 14px;
        }

        .view-details-btn {
            width: 100%;
            padding: 12px 14px;
            background: #6C5CE7;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-top: auto;
        }

        .view-details-btn:hover {
            background: #5A4FCF;
            transform: translateY(-1px);
        }

        /* Skeleton Loader */
        .skeleton-card {
            background: #FFFFFF;
            border-radius: 12px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            border: 1px solid #E8E8E8;
            animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
        }

        .skeleton-image {
            width: 100%;
            height: 180px;
            background-color: #E8E8E8;
        }

        .skeleton-info {
            padding: 14px;
            flex: 1;
        }

        .skeleton-title {
            height: 16px;
            background-color: #E8E8E8;
            border-radius: 4px;
            margin-bottom: 8px;
        }

        .skeleton-price {
            height: 20px;
            background-color: #E8E8E8;
            border-radius: 4px;
            margin-bottom: 12px;
            width: 60%;
        }

        .skeleton-meta {
            height: 12px;
            background-color: #E8E8E8;
            border-radius: 4px;
            margin-bottom: 6px;
        }

        .skeleton-button {
            height: 36px;
            background-color: #E8E8E8;
            border-radius: 4px;
            margin-top: auto;
        }

        @keyframes pulse {
            0%, 100% {
                opacity: 1;
            }
            50% {
                opacity: 0.5;
            }
        }

        /* Login Popup */
        .login-popup {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            z-index: 2000;
            align-items: center;
            justify-content: center;
            animation: fadeIn 0.3s ease;
        }

        .login-popup.active {
            display: flex;
        }

        .popup-content {
            background: white;
            border-radius: 12px;
            padding: 32px;
            max-width: 400px;
            width: 90%;
            text-align: center;
            animation: slideUp 0.3s ease;
        }

        @keyframes slideUp {
            from {
                transform: translateY(20px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }

        .popup-icon {
            font-size: 2.5em;
            margin-bottom: 16px;
        }

        .popup-title {
            font-size: 1.5em;
            font-weight: 700;
            color: #2D3436;
            margin-bottom: 12px;
        }

        .popup-text {
            font-size: 0.95em;
            color: #636E72;
            margin-bottom: 24px;
            line-height: 1.6;
        }

        .popup-buttons {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .popup-btn {
            padding: 14px 24px;
            border: none;
            border-radius: 8px;
            font-size: 1em;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .popup-btn-primary {
            background-color: #6C5CE7;
            color: white;
        }

        .popup-btn-primary:hover {
            background-color: #5A4FCF;
            transform: translateY(-2px);
        }

        .popup-btn-secondary {
            background-color: transparent;
            color: #6C5CE7;
            border: 2px solid #6C5CE7;
        }

        .popup-btn-secondary:hover {
            background-color: #6C5CE7;
            color: white;
        }

        .view-all-btn {
            display: block;
            margin: 40px auto 0;
            padding: 14px 40px;
            background: transparent;
            color: #6C5CE7;
            border: 2px solid #6C5CE7;
            border-radius: 8px;
            font-weight: 600;
            font-size: 1.05em;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .view-all-btn:hover {
            background-color: #6C5CE7;
            color: white;
            transform: translateY(-2px);
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 6 - HOW IT WORKS
           ═══════════════════════════════════════════════════════════ */
        .how-it-works {
            padding: 80px 20px;
            background-color: #F9F7F4;
        }

        .steps-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 32px;
            max-width: 1200px;
            margin: 0 auto;
        }

        .step-card {
            background: white;
            padding: 32px 24px;
            border-radius: 12px;
            text-align: center;
            border: 1px solid #E8E8E8;
        }

        .step-number {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 50px;
            height: 50px;
            background-color: #6C5CE7;
            color: white;
            border-radius: 50%;
            font-weight: 700;
            font-size: 1.4em;
            margin-bottom: 16px;
        }

        .step-title {
            font-size: 1.2em;
            font-weight: 700;
            color: #2D3436;
            margin-bottom: 12px;
        }

        .step-description {
            font-size: 0.95em;
            color: #7F8C8D;
            line-height: 1.6;
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 7 - WHY DEALKO
           ═══════════════════════════════════════════════════════════ */
        .why-dealko {
            padding: 80px 20px;
            background-color: #FFFFFF;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 32px;
            max-width: 1200px;
            margin: 0 auto;
        }

        .feature-card {
            padding: 28px 24px;
            background: white;
            border: 1px solid #E8E8E8;
            border-radius: 12px;
            text-align: center;
        }

        .feature-icon {
            font-size: 2.4em;
            margin-bottom: 16px;
        }

        .feature-title {
            font-size: 1.1em;
            font-weight: 700;
            color: #2D3436;
            margin-bottom: 8px;
        }

        .feature-description {
            font-size: 0.95em;
            color: #7F8C8D;
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 8 - CTA BOTTOM
           ═══════════════════════════════════════════════════════════ */
        .cta-bottom {
            padding: 80px 20px;
            background: linear-gradient(135deg, #6C5CE7 0%, #5B4BD9 100%);
            text-align: center;
            color: white;
        }

        .cta-headline {
            font-size: 2.4em;
            font-weight: 700;
            margin-bottom: 16px;
        }

        .cta-subtext {
            font-size: 1.2em;
            margin-bottom: 32px;
            opacity: 0.95;
        }

        .cta-button {
            padding: 16px 48px;
            background-color: white;
            color: #6C5CE7;
            border: none;
            border-radius: 8px;
            font-weight: 700;
            font-size: 1.1em;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .cta-button:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        }

        /* ═══════════════════════════════════════════════════════════
           SECTION 9 - FOOTER
           ═══════════════════════════════════════════════════════════ */
        footer {
            background-color: #2D3436;
            color: white;
            padding: 48px 20px 24px;
        }

        .footer-content {
            max-width: 1200px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 40px;
            margin-bottom: 32px;
        }

        .footer-section h4 {
            font-size: 1.1em;
            font-weight: 700;
            margin-bottom: 16px;
        }

        .footer-logo {
            font-size: 1.5em;
            font-weight: 700;
            color: #6C5CE7;
            margin-bottom: 8px;
        }

        .footer-tagline {
            font-size: 0.95em;
            color: #BDC3C7;
        }

        .footer-links {
            list-style: none;
        }

        .footer-links li {
            margin-bottom: 12px;
        }

        .footer-links a {
            color: #BDC3C7;
            text-decoration: none;
            transition: color 0.3s ease;
        }

        .footer-links a:hover {
            color: #6C5CE7;
        }

        .footer-bottom {
            border-top: 1px solid #444;
            padding-top: 24px;
            text-align: center;
            color: #95A5A6;
            font-size: 0.9em;
        }

        /* ═══════════════════════════════════════════════════════════
           RESPONSIVE DESIGN
           ═══════════════════════════════════════════════════════════ */
        @media (max-width: 768px) {
            .hero {
                padding: 60px 20px;
            }

            .hero h1 {
                font-size: 2.2em;
            }

            .hero .subheadline {
                font-size: 1.1em;
            }

            .search-bar {
                flex-direction: column;
            }

            .search-input {
                min-width: 100%;
            }

            .categories-grid,
            .steps-grid,
            .features-grid {
                grid-template-columns: 1fr;
            }

            .listings-grid {
                grid-template-columns: 1fr;
            }

            .nav-menu {
                gap: 8px;
            }

            .nav-btn {
                padding: 8px 16px;
                font-size: 0.9em;
            }

            .section-title,
            .cta-headline {
                font-size: 1.8em;
            }
        }

        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: #7F8C8D;
        }
    </style>
    <script src="https://unpkg.com/lucide@latest/dist/umd/lucide.min.js"></script>
    <script src="/design-system.js"></script>    <script type="module" src="./navbar.js" defer></script>
</head>
<body>

    <!-- SECTION 2: HERO -->
    <section class="hero">
        <h1>Varanasi Ka Apna Marketplace</h1>
        <p class="subheadline">Buy • Sell • Rent — Property, Car, Phone</p>
        
        <div class="search-section">
            <div class="search-bar">
                <input type="text" class="search-input" id="searchInput" placeholder="Search property, car, phone...">
                <button class="search-btn" onclick="handleSearch()">Search</button>
            </div>
            <div class="filter-pills">
                <span class="filter-pill active" onclick="filterByCategory(this, 'all')">All</span>
                <span class="filter-pill" onclick="filterByCategory(this, 'property')">Property</span>
                <span class="filter-pill" onclick="filterByCategory(this, 'car')">Car</span>
                <span class="filter-pill" onclick="filterByCategory(this, 'phone')">Phone</span>
                <span class="filter-pill" onclick="filterByCategory(this, 'rent')">Rent</span>
            </div>
        </div>

        <div class="hero-buttons">
            <button class="btn-primary" onclick="window.location.href='listings.html'">Explore Listings</button>
            <button class="btn-secondary" onclick="window.location.href='post.html'">Post for Free</button>
        </div>
    </section>

    <!-- SECTION 5: LATEST LISTINGS -->
    <section class="listings-section" id="listingsSection">
        <div class="container">
            <h2 class="section-title">Latest Listings</h2>
            <p style="text-align: center; color: #636E72; margin-bottom: 40px; font-size: 0.95em;">Varanasi mein available properties, cars & phones</p>
            <div class="cards-index-grid" id="latestListings">
                <!-- Skeleton loaders will be added here -->
            </div>
            <button class="view-all-btn" onclick="window.location.href='listings.html'">Aur listings dekho →</button>
        </div>
    </section>

    <!-- LOGIN POPUP FOR VIEWING DETAILS -->
    <div class="login-popup" id="detailsLoginPopup">
        <div class="popup-content">
            <div class="popup-icon">🔐</div>
            <h3 class="popup-title">Login karein</h3>
            <p class="popup-text">Contact dekhne ke liye<br>free mein login karein</p>
            <div class="popup-buttons">
                <button class="popup-btn popup-btn-primary" onclick="window.location.href='auth.html'">Login / Register</button>
                <button class="popup-btn popup-btn-secondary" onclick="closeLoginPopup('detailsLoginPopup')">Cancel</button>
            </div>
        </div>
    </div>

    <!-- LOGIN POPUP FOR SAVING LISTING -->
    <div class="login-popup" id="saveLoginPopup">
        <div class="popup-content">
            <div class="popup-icon">❤️</div>
            <h3 class="popup-title">Login karein</h3>
            <p class="popup-text">Login karke listings ko<br>save karo apne account mein</p>
            <div class="popup-buttons">
                <button class="popup-btn popup-btn-primary" onclick="window.location.href='auth.html'">Login / Register</button>
                <button class="popup-btn popup-btn-secondary" onclick="closeLoginPopup('saveLoginPopup')">Cancel</button>
            </div>
        </div>
    </div>

    <!-- SECTION 6: HOW IT WORKS -->
    <section class="how-it-works">
        <div class="container">
            <h2 class="section-title">Kaise Kaam Karta Hai?</h2>
            <div class="steps-grid">
                <div class="step-card">
                    <div class="step-number">1</div>
                    <h3 class="step-title">Post Free</h3>
                    <p class="step-description">Apni property ya item ki free listing daalo</p>
                </div>
                <div class="step-card">
                    <div class="step-number">2</div>
                    <h3 class="step-title">Get Contacted</h3>
                    <p class="step-description">Buyers seedha tumse contact karenge</p>
                </div>
                <div class="step-card">
                    <div class="step-number">3</div>
                    <h3 class="step-title">Deal Done</h3>
                    <p class="step-description">Direct deal — koi commission nahi</p>
                </div>
            </div>
        </div>
    </section>

    <!-- SECTION 8: CTA BOTTOM -->
    <section class="cta-bottom">
        <div class="container">
            <h2 class="cta-headline">Abhi Free Listing Post Karo</h2>
            <p class="cta-subtext">Hazaron buyers wait kar rahe hain</p>
            <button class="cta-button" onclick="window.location.href='post.html'">Post for Free</button>
        </div>
    </section>

    <!-- SECTION 9: FOOTER -->
    <footer>
        <div class="container">
            <div class="footer-content">
                <div>
                    <div class="footer-logo">DEALKO</div>
                    <p class="footer-tagline">Varanasi Ka Apna Marketplace</p>
                </div>
                <div>
                    <h4>Quick Links</h4>
                    <ul class="footer-links">
                        <li><a href="index.html">Home</a></li>
                        <li><a href="listings.html">Listings</a></li>
                        <li><a href="post.html">Post Free</a></li>
                        <li><a href="auth.html">Login</a></li>
                    </ul>
                </div>
                <div>
                    <h4>Support</h4>
                    <ul class="footer-links">
                        <li><a href="contact.html">Contact Us</a></li>
                        <li><a href="privacy.html">Privacy Policy</a></li>
                        <li><a href="#terms">Terms of Service</a></li>
                    </ul>
                </div>
            </div>
            <div class="footer-bottom">
                <p>&copy; 2024 DEALKO. All rights reserved.</p>
            </div>
        </div>
    </footer>

    <script type="module">
        import { initializeApp, getApps } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js';
        import { getFirestore, collection, query, orderBy, getDocs, limit, doc, setDoc, increment, serverTimestamp } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js';
        import { getAuth, onAuthStateChanged } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-auth.js';

        const firebaseConfig = {
            apiKey: "AIzaSyD7eARmicMZpR84KElJg2pBmnlrqIfNA8E",
            authDomain: "auraly-6b8cc.firebaseapp.com",
            databaseURL: "https://auraly-6b8cc-default-rtdb.asia-southeast1.firebasedatabase.app",
            projectId: "auraly-6b8cc",
            storageBucket: "auraly-6b8cc.firebasestorage.app",
            messagingSenderId: "819269167789",
            appId: "1:819269167789:web:979cc8e30142f772167424",
            measurementId: "G-XRVNX352WJ"
        };

        const app = getApps().length > 0 ? getApps()[0] : initializeApp(firebaseConfig);
        const db = getFirestore(app);
        const auth = getAuth(app);

        let currentFilter = 'all';
        let currentUser = null;

        // Check authentication status
        onAuthStateChanged(auth, (user) => {
            currentUser = user;
        });

        async function trackPageView(pageId) {
            if (window.DEALKO_Tracking?.trackPageView) {
                try {
                    await window.DEALKO_Tracking.trackPageView();
                    return;
                } catch (error) {
                    console.warn('Centralized page view tracking failed, falling back to local analytics:', error);
                }
            }

            if (!auth.currentUser) {
                return;
            }

            try {
                await setDoc(doc(db, 'analytics', 'pages'), {
                    [pageId]: increment(1),
                    updatedAt: serverTimestamp()
                }, { merge: true });
            } catch (error) {
                console.error('Page tracking error:', error);
            }
        }

        window.addEventListener('load', () => {
            if (!window.DEALKO_Tracking?.trackPageView) {
                trackPageView('index');
            }
        });

        function showSkeletonLoader() {
            const listingsGrid = document.getElementById('latestListings');
            listingsGrid.innerHTML = '';
            for (let i = 0; i < 6; i++) {
                const skeleton = document.createElement('div');
                skeleton.className = 'skeleton-card';
                skeleton.innerHTML = `
                    <div class="skeleton-image"></div>
                    <div class="skeleton-info">
                        <div class="skeleton-title"></div>
                        <div class="skeleton-title" style="width: 70%;"></div>
                        <div class="skeleton-price"></div>
                        <div class="skeleton-meta"></div>
                        <div class="skeleton-meta"></div>
                        <div class="skeleton-button"></div>
                    </div>
                `;
                listingsGrid.appendChild(skeleton);
            }
        }

        async function loadLatestListings(category = 'all') {
            try {
                showSkeletonLoader();

                const listingsRef = collection(db, 'listings');
                const q = query(listingsRef, orderBy('createdAt', 'desc'));
                const querySnapshot = await getDocs(q);

                const listingsGrid = document.getElementById('latestListings');
                const listingsSection = document.getElementById('listingsSection');
                let listings = [];

                querySnapshot.forEach((doc) => {
                    const listing = doc.data();
                    listings.push({ ...listing, id: doc.id });
                });

                // Filter by category
                if (category !== 'all') {
                    listings = listings.filter(l => l.category?.toLowerCase() === category.toLowerCase());
                }

                listingsGrid.innerHTML = '';

                // Hide section if no listings
                if (listings.length === 0) {
                    listingsSection.classList.add('hidden');
                    return;
                }

                // Show section if listings exist
                listingsSection.classList.remove('hidden');

                listings.forEach((listing) => {
                    const card = createListingCard(listing);
                    listingsGrid.appendChild(card);
                });
            } catch (error) {
                console.error('Error loading listings:', error);
                document.getElementById('latestListings').innerHTML = '<div class="empty-state">Unable to load listings. Please try again later.</div>';
            }
        }

        function createListingCard(listing) {
            const card = document.createElement('div');
            card.className = 'card-index';
            card.onclick = () => openLoginPopup('detailsLoginPopup');

            const hasImages = listing.imageUrls && Array.isArray(listing.imageUrls) && listing.imageUrls.length > 0;
            const hasImageUrl = listing.imageUrl;
            const hasImagesArray = listing.images && Array.isArray(listing.images) && listing.images.length > 0;
            const hasVideo = listing.videoUrl;
            const mediaSrc = hasImages ? listing.imageUrls[0] : hasImageUrl ? listing.imageUrl : hasImagesArray ? listing.images[0] : hasVideo ? listing.videoUrl : '/placeholder.svg';
            const isVideo = hasVideo && !hasImages && !hasImageUrl && !hasImagesArray;
            const displayTime = getTimeAgo(listing.createdAt || listing.timestamp);
            const categorySlug = (listing.category || 'item').toString().toLowerCase().replace(/\s+/g, '-');
            const featuredBadge = listing.isBoost || listing.isPromoted
                ? `<span class="card-featured"><i data-lucide="zap" width="11" height="11"></i> Featured</span>`
                : '';

            const mediaHtml = isVideo
                ? `<video class="listing-image" src="${mediaSrc}" muted autoplay loop playsinline poster="/placeholder.svg"></video>`
                : `<img src="${mediaSrc}" alt="${listing.title}" class="listing-image" loading="lazy" onerror="this.src='/placeholder.svg'" />`;

            card.innerHTML = `
                <div class="card-index-image">
                    ${mediaHtml}
                    <span class="card-badge cat-${categorySlug}">${listing.category || 'Item'}</span>
                    ${featuredBadge}
                </div>
                <div class="card-index-body">
                    <h3 class="card-index-title">${listing.title || 'Untitled Listing'}</h3>
                    <p class="card-index-price">₹${listing.price?.toLocaleString() || 'N/A'}</p>
                    <div class="card-index-meta">
                        <span>
                            <i data-lucide="map-pin" width="11" height="11"></i>
                            ${listing.city || listing.location || 'Location not specified'}
                        </span>
                        <span>
                            <i data-lucide="clock-3" width="11" height="11"></i>
                            ${displayTime}
                        </span>
                    </div>
                </div>
            `;

            if (window.lucide && typeof window.lucide.createIcons === 'function') {
                lucide.createIcons({ 'stroke-width': 2, width: 11, height: 11 });
            }

            return card;
        }

        window.handleViewDetails = function(listingId) {
            if (currentUser) {
                // User is logged in, go directly to details page
                window.location.href = `details.html?id=${listingId}`;
            } else {
                // Show login popup
                openLoginPopup('detailsLoginPopup');
            }
        };

        window.handleLikeClick = function(listingId) {
            if (currentUser) {
                // User is logged in, handle save/like
                console.log('Saving listing:', listingId);
                // TODO: Implement save functionality with user's saved listings
            } else {
                // Show login popup
                openLoginPopup('saveLoginPopup');
            }
        };

        window.openLoginPopup = function(popupId) {
            const popup = document.getElementById(popupId);
            popup.classList.add('active');
        };

        window.closeLoginPopup = function(popupId) {
            const popup = document.getElementById(popupId);
            popup.classList.remove('active');
        };

        // Close popup when clicking outside
        document.addEventListener('click', function(event) {
            ['detailsLoginPopup', 'saveLoginPopup'].forEach(popupId => {
                const popup = document.getElementById(popupId);
                if (event.target === popup) {
                    popup.classList.remove('active');
                }
            });
        });

        window.handleSearch = function() {
            const searchInput = document.getElementById('searchInput').value;
            if (searchInput.trim()) {
                window.location.href = `listings.html?search=${encodeURIComponent(searchInput)}`;
            }
        };

        window.filterByCategory = function(element, category) {
            document.querySelectorAll('.filter-pill').forEach(pill => pill.classList.remove('active'));
            element.classList.add('active');
            currentFilter = category;
            loadLatestListings(category);
        };

        // Allow Enter key in search
        document.addEventListener('DOMContentLoaded', function() {
            const searchInput = document.getElementById('searchInput');
            if (searchInput) {
                searchInput.addEventListener('keypress', function(e) {
                    if (e.key === 'Enter') {
                        window.handleSearch();
                    }
                });
            }
        });

        function getTimeAgo(timestamp) {
            if (!timestamp) return 'Recently';
            
            const now = new Date();
            const time = timestamp.toDate ? timestamp.toDate() : new Date(timestamp);
            const diffInSeconds = Math.floor((now - time) / 1000);
            
            if (diffInSeconds < 60) return 'Just now';
            if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
            if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
            if (diffInSeconds < 604800) return `${Math.floor(diffInSeconds / 86400)}d ago`;
            
            return time.toLocaleDateString();
        }

        // Initialize
        loadLatestListings();
    </script>
    <script type="module">
    </script>
</body>
</html>



