<style>
/* ---------------- Body & Layout ---------------- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
  /* Dark gradient background */
  background: linear-gradient(135deg, #0f1724, #1e293b); /* deep navy/charcoal */
  color: #e6eef6;
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.container {
  max-width: 1900px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
}

/* ---------------- Header ---------------- */
.page-header {
  text-align: center;
  margin-bottom: 15px;
}

.page-header h1 {
  font-weight: 700;
  font-size: 3rem;
  background: linear-gradient(90deg, #1e88e5, #43a047, #1e88e5);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-move 3s linear infinite;
  margin-bottom: 5px;
}

@keyframes gradient-move {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.logo-img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  margin-bottom: 10px;
}

.divider {
  width: 80px;
  height: 4px;
  background: linear-gradient(to right, #1e88e5, #43a047);
  margin: 15px auto;
  border-radius: 3px;
}

/* ---------------- Stats Cards ---------------- */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 0 0 auto;
  width: 140px; /* compact cards */
  margin: 6px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(2,6,23,0.6);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-align: center;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(2,6,23,0.7);
}

.stat-label {
  font-weight: 600;
  color: rgba(230,238,246,0.8);
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.stat-value {
  font-size: 1.4rem; /* smaller count */
  font-weight: 700;
  color: #7dd3fc; /* soft cyan */
}

/* ---------------- Glass Cards ---------------- */
.glass-card {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border-radius: 18px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 25px;
  transition: 0.3s ease;
  width: 100%;
}

.glass-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

/* ---------------- Section Titles ---------------- */
.section-title {
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 20px;
  text-align: center;
}

/* ---------------- Item Cards ---------------- */
.item-card {
  border-radius: 15px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  padding: 15px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.item-card:hover {
  transform: scale(1.03);
  background: #f9f9f9;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.item-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0d47a1;
  margin-bottom: 5px;
}

.item-desc {
  font-size: 0.95rem;
  color: #37474f;
  margin-bottom: 10px;
}

.item-footer {
  text-align: right;
}

/* ---------------- Buttons ---------------- */
.btn-custom {
  border-radius: 25px;
  font-weight: 600;
  padding: 7px 18px;
  transition: 0.3s ease;
}

.btn-primary-custom { background-color: #1e88e5; color: #fff; }
.btn-primary-custom:hover { background-color: #1565c0; }

.btn-success-custom { background-color: #43a047; color: #fff; }
.btn-success-custom:hover { background-color: #2e7d32; }

/* ---------------- Ziyara Section ---------------- */
.ziyara-card {
  border-top: 5px solid #fbc02d;
  background: rgba(255,255,240,0.95);
}

.ziyara-title {
  background: linear-gradient(90deg, #fdd835, #fbc02d, #f57f17);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-move 4s linear infinite;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 992px) {
  .stats-row { flex-direction: column; align-items: center; }
}
</style>

<div class="page-wrapper">
  <div class="container">
    <!-- Header -->
    <div class="page-header d-flex flex-column align-items-center">
      <%= image_tag("unnamed.jpg", alt: "Logo", class: "logo-img") %>
      <h1>BADAR MADEENA CULTURAL CENTER AND CHARITY TRUST</h1>
      <div class="divider"></div>
    </div>

    <!-- Stats Row -->
    <div class="stats-row">
      <div class="stat-card">
        <div class="stat-label">INSTITUTION</div>
        <div class="stat-value"><%= @institution_count || 0 %></div>
      </div>
      <div class="stat-card">
        <div class="stat-label">PROGRAMS</div>
        <div class="stat-value"><%= @program_count || 0 %></div>
      </div>
      <div class="stat-card">
        <div class="stat-label">STUDENTS</div>
        <div class="stat-value"><%= @student_count || 0 %></div>
      </div>
      <div class="stat-card">
        <div class="stat-label">ZIYARA</div>
        <div class="stat-value"><%= @ziyara_count || 0 %></div>
      </div>
      <div class="stat-card">
        <div class="stat-label">TRADITIONAL RECORDS</div>
        <div class="stat-value"><%= @exclusive_traditional_records_count || 0 %></div>
      </div>
    </div>



    <!-- Two Column Sections -->
    <div class="row g-4">
      <!-- Institutions -->
      <div class="col-lg-6 d-flex">
        <div class="glass-card">
          <h3 class="section-title text-primary">🏫 Institutions</h3>
          <% if @institutions.present? %>
            <div class="row g-3">
              <% @institutions.each do |institution| %>
                <div class="col-12">
                  <div class="item-card">
                    <div class="item-title"><%= institution.name %></div>
                    <% if institution.respond_to?(:description) %>
                      <p class="item-desc"><%= institution.description.truncate(100) %></p>
                    <% end %>
                    <div class="item-footer d-flex justify-content-end gap-2">
                          <%= link_to "Students", institution_students_path(institution), class: "btn btn-success-custom btn-sm btn-custom" %>
                        </div>
                  </div>
                </div>
              <% end %>
            </div>
          <% else %>
            <p class="item-desc text-center">No institutions added yet.</p>
          <% end %>
          <div class="text-center mt-3">
            <%= link_to "➕ New Institution", new_institution_path, class: "btn btn-success-custom btn-custom me-2" %>
            <%= link_to "📚 All Students", students_path, class: "btn btn-primary-custom btn-custom" %>
          </div>
        </div>
      </div>

      <!-- Programs -->
      <div class="col-lg-6 d-flex">
        <div class="glass-card">
          <h3 class="section-title text-success">🎓 Programs</h3>
          <% if @programs.present? %>
            <div class="row g-3">
              <% @programs.each do |program| %>
                <div class="col-12">
                  <div class="item-card">
                    <div class="item-title"><%= program.name %></div>
                    <% if program.respond_to?(:date) %>
                      <p class="item-desc"><strong>Date:</strong> <%= program.date %></p>
                    <% end %>
                    <% if program.respond_to?(:leadingPerson) %>
                      <p class="item-desc"><strong>Lead:</strong> <%= program.leadingPerson %></p>
                    <% end %>
                    <div class="item-footer">
                      <%= link_to "View", program, class: "btn btn-success-custom btn-sm btn-custom" %>
                    </div>
                  </div>
                </div>
              <% end %>
            </div>
          <% else %>
            <p class="item-desc text-center">No programs available yet.</p>
          <% end %>
          <div class="text-center mt-3">
            <%= link_to "➕ New Program", new_program_path, class: "btn btn-success-custom btn-custom" %>
          </div>
        </div>
      </div>
    </div>

    <!-- Ziyara & Exclusive Traditional Records Side-by-side -->
    <div class="row mt-4 g-4 justify-content-center">
      <div class="col-lg-5 d-flex">
        <div class="glass-card ziyara-card w-100">
          <h3 class="section-title ziyara-title">🕌 Ziyara</h3>
          <% if @ziyaras.present? %>
            <div class="row g-3">
              <% @ziyaras.each do |ziyara| %>
                <div class="col-12">
                  <div class="item-card">
                    <div class="item-title"><%= ziyara.name %></div>
                    <% if ziyara.respond_to?(:location) %>
                      <p class="item-desc"><strong>📍 Location:</strong> <%= ziyara.location %></p>
                    <% end %>
                    <% if ziyara.respond_to?(:date) %>
                      <p class="item-desc"><strong>📅 Date:</strong> <%= ziyara.date %></p>
                    <% end %>
                    <div class="item-footer">
                      <%= link_to "View", ziyara, class: "btn btn-primary-custom btn-sm btn-custom" %>
                    </div>
                  </div>
                </div>
              <% end %>
            </div>
          <% else %>
            <p class="item-desc text-center">No Ziyara records yet.</p>
          <% end %>
          <div class="text-center mt-3">
            <%= link_to "➕ New Ziyara", new_ziyara_path, class: "btn btn-success-custom btn-custom" %>
          </div>
        </div>
      </div>

      <div class="col-lg-5 d-flex">
        <div class="glass-card w-100">
          <h3 class="section-title text-secondary">📜 Exclusive Traditional Records</h3>
          <% if @exclusive_traditional_records.present? %>
            <div class="row g-3">
              <% @exclusive_traditional_records.each do |record| %>
                <div class="col-12">
                  <div class="item-card">
                    <div class="item-title"><%= record.name if record.respond_to?(:name) %></div>
                    <% if record.respond_to?(:description) %>
                      <p class="item-desc"><%= record.description.truncate(100) %></p>
                    <% end %>
                    <div class="item-footer">
                      <%= link_to "View", record, class: "btn btn-primary-custom btn-sm btn-custom" %>
                    </div>
                  </div>
                </div>
              <% end %>
            </div>
          <% else %>
            <p class="item-desc text-center">No exclusive traditional records yet.</p>
          <% end %>
          <div class="text-center mt-3">
            <%= link_to "➕ New Record", new_exclusive_traditional_record_path, class: "btn btn-success-custom btn-custom" %>
          </div>
        </div>
      </div>
    </div>
<% content_for :title, "Expenses" %>




<style>
  /* Main card container */
  .expense-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 20px 25px;
    max-width: 420px;
    margin: 30px auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }

  /* Hover effect */
  .expense-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  }

  /* Card header */
  .expense-card h1 {
    font-size: 1.7rem;
    margin-bottom: 15px;
    color: #333333;
    text-align: center;
    font-weight: 600;
  }

  /* Flash notice */
  .expense-card .flash-notice {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
  }

  /* Button styling */
  .expense-card .btn {
    display: block;
    width: 100%;
    text-align: center;
    background-color: #007bff;
    color: #fff;
    padding: 10px 0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.3s ease, transform 0.2s ease;
  }

  /* Button hover */
  .expense-card .btn:hover {
    background-color: #0056b3;
    transform: scale(1.03);
  }





    /* Main card container */
  .income-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 20px 25px;
    max-width: 420px;
    margin: 30px auto;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }

  /* Hover effect */
  .income-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  }

  /* Card header */
  .income-card h1 {
    font-size: 1.7rem;
    margin-bottom: 15px;
    color: #333333;
    text-align: center;
    font-weight: 600;
  }

  /* Flash notice */
  .income-card .flash-notice {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
  }

  /* Button styling */
  .income-card .btn {
    display: block;
    width: 100%;
    text-align: center;
    background-color: #007bff;
    color: #fff;
    padding: 10px 0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.3s ease, transform 0.2s ease;
  }

  /* Button hover */
  .income-card .btn:hover {
    background-color: #0056b3;
    transform: scale(1.03);
  }
</style>

<div class="row mt-4 g-4 justify-content-center">
  <!-- Expense Card -->
  <div class="col-lg-5 d-flex">
    <div class="expense-card w-100">
      <% if notice.present? %>
        <div class="flash-notice">
          <%= notice %>
        </div>
      <% end %>

      <h1>📊 Expenses</h1>
      <%= link_to "Expenses List", expenses_path, class: "btn" %>
    </div>
  </div>

  <!-- Income Card -->
  <div class="col-lg-5 d-flex">
    <div class="income-card w-100">
      <% if notice.present? %>
        <div class="flash-notice">
          <%= notice %>
        </div>
      <% end %>

      <h1>💰 Incomes</h1>
      <%= link_to "Incomes List", incomes_path, class: "btn" %>
    </div>
  </div>
</div>


  </div> <!-- container -->
</div> <!-- page-wrapper -->
