{{> header}}

<style>
  .courses-page {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    padding: 100px 20px 80px;
    position: relative;
    z-index: 1;
  }
  .courses-container {
    max-width: 1200px;
    margin: 0 auto;
  }
  .courses-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  .courses-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.75rem;
  }
  .courses-header p {
    color: #94a3b8;
    font-size: 1.1rem;
  }
  .courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
  }
  .course-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
  }
  .course-card:hover {
    border-color: rgba(16, 185, 129, 0.4);
    transform: translateY(-4px);
  }
  .course-image {
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(99, 102, 241, 0.3) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
  }
  .course-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: rgba(0,0,0,0.2);
  }
  .course-placeholder {
    font-size: 4rem;
  }
  .course-price {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(15, 23, 42, 0.9);
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    backdrop-filter: blur(8px);
  }
  .course-price.free {
    background: rgba(16, 185, 129, 0.9);
  }
  .course-body {
    padding: 1.5rem;
  }
  .course-body h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #fff;
  }
  .course-body h3 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
  }
  .course-body h3 a:hover {
    color: #10b981;
  }
  .course-body p {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.6;
  }
  .course-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
  }
  .course-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #94a3b8;
  }
  .btn-enroll {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
  }
  .btn-enroll:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  }
  .empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
  }
  .empty-state span {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
  }
  .empty-state h2 {
    color: #fff;
    margin-bottom: 0.5rem;
  }
  .empty-state p {
    color: #94a3b8;
  }
  @media (max-width: 768px) {
    .courses-page { padding-top: 80px; }
    .courses-header h1 { font-size: 2rem; }
    .courses-grid { grid-template-columns: 1fr; }
  }
</style>

<div class="courses-page">
  <div class="courses-container">
    <div class="courses-header">
      <h1>📚 All Courses</h1>
      <p>Browse our collection of courses and start learning today.</p>
    </div>

    {{#if courses.length}}
    <div class="courses-grid">
      {{#each courses}}
      <div class="course-card">
        <div class="course-image">
          {{#if featuredImage}}
          <img src="{{featuredImage}}" alt="{{title}}" onerror="this.src='/api/lms/courses/placeholder-image'">
          {{else}}
          <img src="/api/lms/courses/placeholder-image" alt="{{title}}">
          {{/if}}
          {{#if price}}
          <span class="course-price">${{price}}</span>
          {{else}}
          <span class="course-price free">Free</span>
          {{/if}}
        </div>
        <div class="course-body">
          <h3><a href="/courses/{{slug}}">{{title}}</a></h3>
          <p>{{shortDescription}}</p>
          <div class="course-meta">
            {{#if level}}<span class="course-badge">{{level}}</span>{{/if}}
            {{#if _count.lessons}}<span class="course-badge">{{_count.lessons}} lessons</span>{{/if}}
          </div>
          <a href="/courses/{{slug}}" class="btn-enroll">View Course</a>
        </div>
      </div>
      {{/each}}
    </div>
    {{else}}
    <div class="empty-state">
      <span>📭</span>
      <h2>No courses available yet</h2>
      <p>Check back soon for new learning opportunities!</p>
    </div>
    {{/if}}
  </div>
</div>

{{> footer}}

