<section id="projects" class="py-24 bg-white relative overflow-hidden">
  <!-- Background elements -->
  <div class="absolute inset-0 bg-gradient-to-br from-green-50 to-teal-50 opacity-30"></div>
  <div class="absolute inset-0 overflow-hidden">
    <div class="absolute inset-0 opacity-[0.03]" aria-hidden="true">
      <svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <pattern id="projects-grid" width="40" height="40" patternUnits="userSpaceOnUse">
            <path d="M0 0h40v40H0z" fill="none" />
            <path d="M0 0h1v40H0zm40 0v1H0V0zm0 40h-1V0h1zM0 40v-1h40v1z" fill="currentColor" />
          </pattern>
        </defs>
        <rect width="100%" height="100%" fill="url(#projects-grid)" />
      </svg>
    </div>
  </div>
  
  <div class="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
    <!-- Section header -->
    <div class="text-center max-w-3xl mx-auto mb-16" data-aos="fade-up">
      {% if sections.projects.badge %}
      <span class="inline-block px-4 py-1 rounded-full text-sm font-medium bg-teal-100 text-teal-700 mb-4">
        {{ sections.projects.badge }}
      </span>
      {% endif %}
      <h2 class="text-4xl font-bold text-gray-900 mb-4">
        {{ sections.projects.title }}
      </h2>
      <p class="text-lg text-gray-600 max-w-2xl mx-auto">
        {{ sections.projects.subtitle }}
      </p>
    </div>
    
    <!-- Filter categories if available -->
    {% if sections.projects.categories %}
    <div class="flex flex-wrap justify-center gap-4 mb-12" data-aos="fade-up" data-aos-delay="100">
      <button class="px-6 py-2 rounded-full text-sm font-medium bg-teal-600 text-white" data-filter="all">
        All Projects
      </button>
      {% for category in sections.projects.categories %}
      <button class="px-6 py-2 rounded-full text-sm font-medium bg-gray-100 text-gray-700 hover:bg-gray-200 transition-colors duration-300" data-filter="{{ category.value }}">
        {{ category.label }}
      </button>
      {% endfor %}
    </div>
    {% endif %}
    
    <!-- Projects layout options -->
    {% if sections.projects.layout == 'grid' %}
    <!-- Grid layout -->
    <div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-8" data-aos="fade-up" data-aos-delay="200">
      {% for project in sections.projects.items %}
      <div 
        class="project-item bg-white rounded-xl shadow-md overflow-hidden border border-gray-100 transition-all duration-300 hover:shadow-lg hover:border-teal-200 group"
        data-category="{{ project.category|default('') }}"
      >
        <!-- Project image -->
        <div class="aspect-[4/3] w-full relative overflow-hidden">
          <img 
            src="{{ project.image }}" 
            alt="{{ project.title }}" 
            class="w-full h-full object-cover transition-transform duration-500 ease-out group-hover:scale-105"
            loading="lazy"
          >
          
          <!-- Status badge if available -->
          {% if project.status %}
          <div class="absolute top-4 left-4">
            <span class="inline-block px-3 py-1 text-xs font-medium rounded-full 
              {% if project.status == 'completed' %}bg-green-500 text-white
              {% elif project.status == 'in_progress' %}bg-amber-500 text-white
              {% elif project.status == 'upcoming' %}bg-blue-500 text-white
              {% else %}bg-gray-500 text-white{% endif %}">
              {{ project.status_label|default(project.status|title) }}
            </span>
          </div>
          {% endif %}
          
          <!-- Overlay with actions -->
          <div class="absolute inset-0 bg-teal-900/80 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-col items-center justify-center p-6">
            <h3 class="text-xl font-semibold text-white mb-2">{{ project.title }}</h3>
            <p class="text-teal-100 text-center mb-6">{{ project.short_description }}</p>
            <div class="flex gap-4">
              {% if project.demo_url %}
              <a 
                href="{{ project.demo_url }}" 
                class="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center text-white hover:bg-white/40 transition-colors duration-300"
                aria-label="View Demo"
                target="_blank"
                rel="noopener"
              >
                <i class="ri-eye-line" aria-hidden="true"></i>
              </a>
              {% endif %}
              
              {% if project.url %}
              <a 
                href="{{ project.url }}" 
                class="w-10 h-10 rounded-full bg-white/20 flex items-center justify-center text-white hover:bg-white/40 transition-colors duration-300"
                aria-label="View Project Details"
                target="_blank"
                rel="noopener"
              >
                <i class="ri-arrow-right-line" aria-hidden="true"></i>
              </a>
              {% endif %}
            </div>
          </div>
        </div>
        
        <!-- Project info -->
        <div class="p-6">
          <!-- Category -->
          {% if project.category_label %}
          <div class="text-sm text-teal-600 mb-1">{{ project.category_label }}</div>
          {% endif %}
          
          <!-- Title -->
          <h3 class="text-lg font-semibold text-gray-900 mb-2 group-hover:text-teal-600 transition-colors duration-300">
            <a href="{{ project.url }}">{{ project.title }}</a>
          </h3>
          
          <!-- Description -->
          <p class="text-gray-600 mb-4">{{ project.short_description }}</p>
          
          <!-- Timeline if available -->
          {% if project.timeline %}
          <div class="flex items-center text-sm text-gray-500">
            <i class="ri-calendar-line mr-2" aria-hidden="true"></i>
            <span>{{ project.timeline }}</span>
          </div>
          {% endif %}
        </div>
      </div>
      {% endfor %}
    </div>
    
    {% elif sections.projects.layout == 'timeline' %}
    <!-- Timeline layout -->
    <div class="relative" data-aos="fade-up" data-aos-delay="200">
      <!-- Timeline line -->
      <div class="absolute left-1/2 transform -translate-x-1/2 h-full w-0.5 bg-teal-200"></div>
      
      <div class="space-y-16">
        {% for project in sections.projects.items %}
        <div class="relative">
          <!-- Timeline dot -->
          <div class="absolute left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-6 h-6 rounded-full border-4 border-teal-200 bg-white"></div>
          
          <!-- Project card -->
          <div class="grid md:grid-cols-2 gap-8 items-center {% if loop.index is even %}md:flex-row-reverse{% endif %}">
            <!-- Date column -->
            <div class="text-center md:text-{% if loop.index is even %}left{% else %}right{% endif %}">
              <div class="inline-block px-4 py-1 rounded-full text-sm font-medium bg-teal-100 text-teal-700">
                {{ project.date }}
              </div>
              
              {% if project.status %}
              <div class="mt-2">
                <span class="inline-block px-3 py-1 text-xs font-medium rounded-full 
                  {% if project.status == 'completed' %}bg-green-500 text-white
                  {% elif project.status == 'in_progress' %}bg-amber-500 text-white
                  {% elif project.status == 'upcoming' %}bg-blue-500 text-white
                  {% else %}bg-gray-500 text-white{% endif %}">
                  {{ project.status_label|default(project.status|title) }}
                </span>
              </div>
              {% endif %}
            </div>
            
            <!-- Content column -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden border border-gray-100 transition-all duration-300 hover:shadow-lg hover:border-teal-200">
              <!-- Project image if available -->
              {% if project.image %}
              <div class="aspect-[16/9] w-full relative overflow-hidden">
                <img 
                  src="{{ project.image }}" 
                  alt="{{ project.title }}" 
                  class="w-full h-full object-cover"
                  loading="lazy"
                >
              </div>
              {% endif %}
              
              <!-- Project info -->
              <div class="p-6">
                <!-- Category -->
                {% if project.category_label %}
                <div class="text-sm text-teal-600 mb-1">{{ project.category_label }}</div>
                {% endif %}
                
                <!-- Title -->
                <h3 class="text-xl font-bold text-gray-900 mb-2">
                  <a href="{{ project.url }}" class="hover:text-teal-600 transition-colors duration-300">{{ project.title }}</a>
                </h3>
                
                <!-- Description -->
                <p class="text-gray-600 mb-4">{{ project.description }}</p>
                
                <!-- Project details if available -->
                {% if project.details %}
                <ul class="space-y-2 mb-6">
                  {% for detail in project.details %}
                  <li class="flex items-center">
                    <svg class="w-5 h-5 text-teal-500 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
                    </svg>
                    <span class="text-gray-600">{{ detail }}</span>
                  </li>
                  {% endfor %}
                </ul>
                {% endif %}
                
                <!-- CTA buttons -->
                <div class="flex flex-wrap gap-4 mt-6">
                  {% if project.demo_url %}
                  <a 
                    href="{{ project.demo_url }}" 
                    class="inline-flex items-center px-4 py-2 bg-teal-600 text-white text-sm font-medium rounded-lg hover:bg-teal-700 transition-colors duration-300"
                    target="_blank"
                    rel="noopener"
                  >
                    <i class="ri-eye-line mr-2" aria-hidden="true"></i>
                    View Demo
                  </a>
                  {% endif %}
                  
                  {% if project.url %}
                  <a 
                    href="{{ project.url }}" 
                    class="inline-flex items-center px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 transition-colors duration-300"
                    target="_blank"
                    rel="noopener"
                  >
                    View Details
                    <svg class="w-4 h-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
                    </svg>
                  </a>
                  {% endif %}
                </div>
              </div>
            </div>
          </div>
        </div>
        {% endfor %}
      </div>
    </div>
    
    {% else %}
    <!-- Default cards layout -->
    <div class="space-y-12" data-aos="fade-up" data-aos-delay="200">
      {% for project in sections.projects.items %}
      <div 
        class="project-item bg-white rounded-xl shadow-md overflow-hidden border border-gray-100 transition-all duration-300 hover:shadow-lg hover:border-teal-200"
        data-category="{{ project.category|default('') }}"
      >
        <div class="grid md:grid-cols-2 items-center">
          <!-- Media column -->
          <div class="aspect-[4/3] w-full h-full relative overflow-hidden">
            <img 
              src="{{ project.image }}" 
              alt="{{ project.title }}" 
              class="w-full h-full object-cover transition-transform duration-500 ease-out hover:scale-105"
              loading="lazy"
            >
            
            <!-- Status badge if available -->
            {% if project.status %}
            <div class="absolute top-4 left-4">
              <span class="inline-block px-3 py-1 text-xs font-medium rounded-full 
                {% if project.status == 'completed' %}bg-green-500 text-white
                {% elif project.status == 'in_progress' %}bg-amber-500 text-white
                {% elif project.status == 'upcoming' %}bg-blue-500 text-white
                {% else %}bg-gray-500 text-white{% endif %}">
                {{ project.status_label|default(project.status|title) }}
              </span>
            </div>
            {% endif %}
          </div>
          
          <!-- Content column -->
          <div class="p-8 md:p-12">
            {% if project.category_label %}
            <div class="text-sm text-teal-600 mb-2">{{ project.category_label }}</div>
            {% endif %}
            <h3 class="text-2xl font-bold text-gray-900 mb-4">{{ project.title }}</h3>
            <p class="text-gray-600 mb-6">{{ project.description }}</p>
            
            <!-- Timeline if available -->
            {% if project.timeline %}
            <div class="flex items-center text-sm text-gray-500 mb-6">
              <i class="ri-calendar-line mr-2" aria-hidden="true"></i>
              <span>{{ project.timeline }}</span>
            </div>
            {% endif %}
            
            <!-- Project details if available -->
            {% if project.details %}
            <ul class="space-y-3 mb-6">
              {% for detail in project.details %}
              <li class="flex items-center">
                <svg class="w-5 h-5 text-teal-500 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
                </svg>
                <span class="text-gray-600">{{ detail }}</span>
              </li>
              {% endfor %}
            </ul>
            {% endif %}
            
            <!-- CTA buttons -->
            <div class="flex flex-wrap gap-4 mt-8">
              {% if project.demo_url %}
              <a 
                href="{{ project.demo_url }}" 
                class="inline-flex items-center px-6 py-3 bg-teal-600 text-white font-medium rounded-lg hover:bg-teal-700 transition-colors duration-300"
                target="_blank"
                rel="noopener"
              >
                <i class="ri-eye-line mr-2" aria-hidden="true"></i>
                View Demo
              </a>
              {% endif %}
              
              {% if project.url %}
              <a 
                href="{{ project.url }}" 
                class="inline-flex items-center px-6 py-3 bg-gray-100 text-gray-700 font-medium rounded-lg hover:bg-gray-200 transition-colors duration-300"
                target="_blank"
                rel="noopener"
              >
                View Details
                <svg class="w-4 h-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3" />
                </svg>
              </a>
              {% endif %}
            </div>
          </div>
        </div>
      </div>
      {% endfor %}
    </div>
    {% endif %}
    
    <!-- Load more button if available -->
    {% if sections.projects.load_more %}
    <div class="mt-16 text-center" data-aos="fade-up" data-aos-delay="300">
      <button 
        class="inline-flex items-center px-8 py-3 bg-teal-600 text-white font-medium rounded-lg hover:bg-teal-700 transition-colors duration-300"
        id="load-more-projects"
      >
        {{ sections.projects.load_more.label }}
        <svg class="w-4 h-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
          <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
        </svg>
      </button>
    </div>
    {% endif %}
    
    <!-- Projects CTA if available -->
    {% if sections.projects.cta %}
    <div class="mt-24 text-center" data-aos="fade-up" data-aos-delay="300">
      <h3 class="text-3xl font-bold text-gray-900 mb-4">{{ sections.projects.cta.title }}</h3>
      <p class="text-lg text-gray-600 mb-8 max-w-2xl mx-auto">{{ sections.projects.cta.description }}</p>
      <div class="flex flex-col sm:flex-row gap-4 justify-center">
        {% for button in sections.projects.cta.buttons %}
        <a 
          href="{{ button.url }}" 
          class="inline-flex items-center justify-center px-6 py-3 rounded-lg font-medium transition-all duration-300 {% if button.style == 'primary' %}bg-teal-600 text-white hover:bg-teal-700{% else %}bg-gray-100 text-gray-700 hover:bg-gray-200{% endif %}"
        >
          {% if button.icon %}
          <i class="{{ button.icon }} mr-2" aria-hidden="true"></i>
          {% endif %}
          {{ button.label }}
        </a>
        {% endfor %}
      </div>
    </div>
    {% endif %}
  </div>
</section>
