{% load static %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>{% block title %}Matrichaya Properties Ltd.{% endblock %}</title>

    <!-- Google Fonts -->
    <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=Poppins:wght@300;400;500;600;700;800;900&display=swap"
      rel="stylesheet"
    />

    <script src="https://cdn.tailwindcss.com"></script>
    <script>
      tailwind.config = {
        theme: {
          extend: {
            colors: {
              "matrichaya-green": "#22c55e",
              "matrichaya-dark-green": "#16a34a",
            },
            fontFamily: {
              sans: [
                "Poppins",
                "ui-sans-serif",
                "system-ui",
                "-apple-system",
                "BlinkMacSystemFont",
                "Segoe UI",
                "Roboto",
                "Helvetica Neue",
                "Arial",
                "Noto Sans",
                "sans-serif",
              ],
            },
          },
        },
      };
    </script>
    <link
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
      rel="stylesheet"
    />
  </head>
  <body class="bg-gray-50">
    <!-- Header -->
    <header id="navbar" class="bg-white shadow-lg fixed w-full top-0 z-50 transition-all duration-300">

      <!-- Main Navigation -->
      <div class="container mx-auto px-4 py-4">
        <div class="flex justify-between items-center">
          <!-- Logo -->
          <a href="{% url 'home' %}" class="flex items-center space-x-2 hover:opacity-80 transition-opacity">
            {% if navbar_images.logo %}
              <div class="w-12 h-12 rounded-lg overflow-hidden flex items-center justify-center">
                <img 
                  src="{{ navbar_images.logo.image.url }}" 
                  alt="{{ navbar_images.logo.name }}"
                  class="w-full h-full object-cover"
                />
              </div>
            {% else %}
              <div
                class="w-12 h-12 bg-matrichaya-green rounded-lg flex items-center justify-center"
              >
                <i class="fas fa-home text-white text-xl"></i>
              </div>
            {% endif %}
            <div>
              <h1 class="text-xl font-bold text-gray-800">
                {% if navbar_images.logo %}{{ navbar_images.logo.name }}{% else %}Matrichaya Properties Ltd.{% endif %}
              </h1>
            </div>
          </a>

          <!-- Navigation Menu -->
          <nav class="hidden md:flex space-x-8">
            <a
              href="{% url 'home' %}"
              class="text-gray-700 hover:text-matrichaya-green font-medium"
              >Home</a
            >
            
            <!-- Properties Dropdown -->
            <div class="relative group">
              <button class="text-gray-700 hover:text-matrichaya-green font-medium flex items-center">
                Properties
                <i class="fas fa-chevron-down ml-1 text-xs transition-transform duration-200 group-hover:rotate-180"></i>
              </button>
              
              <div class="absolute top-full left-0 mt-2 w-48 bg-white rounded-lg shadow-lg border border-gray-200 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-50">
                <div class="py-2">
                  <a
                    href="{% url 'land_properties' %}"
                    class="block px-4 py-2 text-gray-700 hover:bg-gray-50 hover:text-matrichaya-green font-medium"
                  >
                    <i class="fas fa-map-marked-alt mr-2 text-matrichaya-green"></i>
                    Land Properties
                  </a>
                  
                </div>
              </div>
            </div>
            
            <a
              href="#"
              class="text-gray-700 hover:text-matrichaya-green font-medium"
              >Corporate Info</a
            >
            <a
              href="#about"
              class="text-gray-700 hover:text-matrichaya-green font-medium"
              >About</a
            >
            <a
              href="#"
              class="text-gray-700 hover:text-matrichaya-green font-medium"
              >Blog</a
            >
            <a
              href="{% url 'contact' %}"
              class="text-gray-700 hover:text-matrichaya-green font-medium"
              >Contact</a
            >
          </nav>

          <!-- Mobile Menu Button -->
          <button id="mobile-menu-button" class="md:hidden text-gray-700 hover:text-matrichaya-green transition-colors">
            <i class="fas fa-bars text-xl"></i>
          </button>
        </div>

        <!-- Mobile Menu -->
        <div id="mobile-menu" class="md:hidden hidden bg-white border-t border-gray-200 shadow-lg">
          <div class="px-4 py-6 space-y-4">
            <a
              href="{% url 'home' %}"
              class="block text-gray-700 hover:text-matrichaya-green font-medium py-2"
              >Home</a
            >
            
            <!-- Mobile Properties Dropdown -->
            <div class="space-y-2">
              <button id="mobile-properties-toggle" class="flex items-center justify-between w-full text-gray-700 hover:text-matrichaya-green font-medium py-2">
                Properties
                <i class="fas fa-chevron-down text-xs transition-transform duration-200" id="mobile-properties-arrow"></i>
              </button>
              
              <div id="mobile-properties-menu" class="hidden pl-4 space-y-2">
                <a
                  href="{% url 'land_properties' %}"
                  class="block text-gray-600 hover:text-matrichaya-green font-medium py-2"
                >
                  <i class="fas fa-map-marked-alt mr-2 text-matrichaya-green"></i>
                  Land Properties
                </a>
              </div>
            </div>
            
            <a
              href="#"
              class="block text-gray-700 hover:text-matrichaya-green font-medium py-2"
              >Corporate Info</a
            >
            <a
              href="#about"
              class="block text-gray-700 hover:text-matrichaya-green font-medium py-2"
              >About</a
            >
            <a
              href="#"
              class="block text-gray-700 hover:text-matrichaya-green font-medium py-2"
              >Blog</a
            >
            <a
              href="{% url 'contact' %}"
              class="block text-gray-700 hover:text-matrichaya-green font-medium py-2"
              >Contact</a
            >
          </div>
        </div>
      </div>
    </header>

    <!-- Main Content -->
    <main class="pt-20">{% block content %} {% endblock %}</main>

    <!-- Footer -->
    <footer class="bg-gray-800 text-white">
      <div class="container mx-auto px-4 py-12">
        <div class="grid md:grid-cols-3 gap-8">
          <!-- About Company -->
          <div>
            <h3 class="text-lg font-semibold mb-4">About Company</h3>
            <div class="space-y-3">
              <div class="flex items-start space-x-3">
                <i class="fas fa-map-marker-alt text-matrichaya-green mt-1"></i>
                <p class="text-sm">
                  Nasiruddin Tower (10th Floor), 104/1 Kakrail, Dhaka-1000.
                </p>
              </div>
              <div class="flex items-center space-x-3">
                <i class="fas fa-phone text-matrichaya-green"></i>
                <p class="text-sm">(+880) 1404 055171-9</p>
              </div>
              <div class="flex items-center space-x-3">
                <i class="fas fa-envelope text-matrichaya-green"></i>
                <p class="text-sm">info@matrichayabd.com</p>
              </div>
            </div>
          </div>

          <!-- Useful Links -->
          <div>
            <h3 class="text-lg font-semibold mb-4">Useful Links</h3>
            <ul class="space-y-2">
              <li>
                <a href="#" class="text-sm hover:text-matrichaya-green">Help</a>
              </li>
              <li>
                <a href="#" class="text-sm hover:text-matrichaya-green">FAQ</a>
              </li>
              <li>
                <a href="#" class="text-sm hover:text-matrichaya-green"
                  >Contact</a
                >
              </li>
              <li>
                <a href="#" class="text-sm hover:text-matrichaya-green"
                  >About Company</a
                >
              </li>
              <li>
                <a href="#" class="text-sm hover:text-matrichaya-green"
                  >Blogs</a
                >
              </li>
            </ul>
          </div>

          <!-- Email Subscription -->
          <div>
            <h3 class="text-lg font-semibold mb-4">Email Subscription</h3>
            <div class="space-y-4">
              <div class="flex">
                <input
                  type="email"
                  placeholder="example@mail.com"
                  class="flex-1 px-3 py-2 text-gray-800 rounded-l-md focus:outline-none"
                />
                <button
                  class="bg-matrichaya-green px-4 py-2 rounded-r-md hover:bg-matrichaya-dark-green"
                >
                  Submit
                </button>
              </div>
              <div>
                <h4 class="font-semibold mb-2">Connect With Us</h4>
                <div class="flex space-x-3">
                  <a
                    href="#"
                    class="w-8 h-8 bg-gray-700 rounded-full flex items-center justify-center hover:bg-matrichaya-green"
                  >
                    <i class="fab fa-facebook-f text-sm"></i>
                  </a>
                  <a
                    href="#"
                    class="w-8 h-8 bg-gray-700 rounded-full flex items-center justify-center hover:bg-matrichaya-green"
                  >
                    <i class="fab fa-twitter text-sm"></i>
                  </a>
                  <a
                    href="#"
                    class="w-8 h-8 bg-gray-700 rounded-full flex items-center justify-center hover:bg-matrichaya-green"
                  >
                    <i class="fab fa-youtube text-sm"></i>
                  </a>
                  <a
                    href="#"
                    class="w-8 h-8 bg-gray-700 rounded-full flex items-center justify-center hover:bg-matrichaya-green"
                  >
                    <i class="fab fa-pinterest text-sm"></i>
                  </a>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- Copyright -->
      <div class="bg-matrichaya-green py-4">
        <div class="container mx-auto px-4 text-center text-sm">
          All right reserved by © Matrichaya Properties Ltd. | Design &
          Developed by © Tech Bungalow
        </div>
      </div>
    </footer>

    <!-- Scroll to Top Button -->
    <button id="scrollToTop" class="fixed bottom-8 right-8 bg-matrichaya-green hover:bg-matrichaya-dark-green text-white p-3 rounded-full shadow-lg transition-all duration-300 opacity-0 invisible z-50">
      <i class="fas fa-arrow-up text-xl"></i>
    </button>

    <!-- Scroll Animation Script -->
    <script>
      // Mobile menu functionality
      const mobileMenuButton = document.getElementById('mobile-menu-button');
      const mobileMenu = document.getElementById('mobile-menu');
      const mobilePropertiesToggle = document.getElementById('mobile-properties-toggle');
      const mobilePropertiesMenu = document.getElementById('mobile-properties-menu');
      const mobilePropertiesArrow = document.getElementById('mobile-properties-arrow');

      // Toggle mobile menu
      mobileMenuButton.addEventListener('click', function() {
        mobileMenu.classList.toggle('hidden');
        // Change icon from bars to X
        const icon = mobileMenuButton.querySelector('i');
        if (mobileMenu.classList.contains('hidden')) {
          icon.className = 'fas fa-bars text-xl';
        } else {
          icon.className = 'fas fa-times text-xl';
        }
      });

      // Toggle mobile properties dropdown
      mobilePropertiesToggle.addEventListener('click', function() {
        mobilePropertiesMenu.classList.toggle('hidden');
        mobilePropertiesArrow.classList.toggle('rotate-180');
      });

      // Close mobile menu when clicking outside
      document.addEventListener('click', function(event) {
        if (!mobileMenuButton.contains(event.target) && !mobileMenu.contains(event.target)) {
          mobileMenu.classList.add('hidden');
          const icon = mobileMenuButton.querySelector('i');
          icon.className = 'fas fa-bars text-xl';
        }
      });

      // Navbar scroll animation
      let lastScrollTop = 0;
      const navbar = document.getElementById('navbar');
      const scrollToTopBtn = document.getElementById('scrollToTop');
      
      window.addEventListener('scroll', function() {
        const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
        
        // Navbar animation
        if (scrollTop > lastScrollTop && scrollTop > 100) {
          // Scrolling down - hide navbar
          navbar.style.transform = 'translateY(-100%)';
          navbar.style.backgroundColor = 'rgba(255, 255, 255, 0.95)';
          navbar.style.backdropFilter = 'blur(10px)';
        } else {
          // Scrolling up - show navbar
          navbar.style.transform = 'translateY(0)';
          navbar.style.backgroundColor = 'rgba(255, 255, 255, 1)';
          navbar.style.backdropFilter = 'none';
        }
        
        // Add shadow when scrolled
        if (scrollTop > 50) {
          navbar.classList.add('shadow-xl');
          navbar.classList.remove('shadow-lg');
        } else {
          navbar.classList.add('shadow-lg');
          navbar.classList.remove('shadow-xl');
        }
        
        // Scroll to top button visibility
        if (scrollTop > 300) {
          scrollToTopBtn.style.opacity = '1';
          scrollToTopBtn.style.visibility = 'visible';
          scrollToTopBtn.style.transform = 'translateY(0)';
        } else {
          scrollToTopBtn.style.opacity = '0';
          scrollToTopBtn.style.visibility = 'invisible';
          scrollToTopBtn.style.transform = 'translateY(20px)';
        }
        
        lastScrollTop = scrollTop;
      });
      
      // Scroll to top functionality
      scrollToTopBtn.addEventListener('click', function() {
        window.scrollTo({
          top: 0,
          behavior: 'smooth'
        });
      });
      
      // Smooth scroll for anchor links
      document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
          e.preventDefault();
          const target = document.querySelector(this.getAttribute('href'));
          if (target) {
            const offsetTop = target.offsetTop - 80; // Account for fixed navbar
            window.scrollTo({
              top: offsetTop,
              behavior: 'smooth'
            });
          }
        });
      });
    </script>
  </body>
</html>
