<div class="student-card" id="<%= dom_id student %>">
  <div class="student-header">
    <div class="student-photo">
      <% if student.photo.attached? %>
        <%# Fallback for image processing errors %>
        <% begin %>
          <%= image_tag url_for(student.photo.variant(resize_to_limit: [120, 120]).processed), alt: student.first_name %>
        <% rescue => e %>
          <%= image_tag url_for(student.photo), alt: student.first_name %>
        <% end %>
      <% else %>
        <span class="placeholder">No Photo</span>
      <% end %>
    </div>
    <div class="student-name">
      <h3><%= student.first_name %> <%= student.last_name %></h3>
      <% if student.institution.present? %>
        <%= link_to student.institution.name, institution_path(student.institution), class: "badge badge-primary" %>
      <% else %>
        <span class="badge badge-secondary">No institution</span>
      <% end %>
      <p class="student-email"><%= student.email %></p>
    </div>
  </div>

  <div class="student-info">
    <div class="info-item"><strong>Phone:</strong> <%= student.phone_number %></div>
    <div class="info-item"><strong>Place:</strong> <%= student.place %></div>
    <div class="info-item"><strong>Age:</strong> <%= student.age %></div>
  </div>
</div>

<style>
.student-card {
  background: linear-gradient(135deg, #ffffff, #f9fafb);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  max-width: 500px;
}

.student-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

.student-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.student-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}

.student-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.student-name h3 {
  margin: 0 0 4px 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
}

.student-name .badge {
  margin-top: 6px;
}

.student-name .student-email {
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 4px;
}

.student-info {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.info-item {
  font-size: 0.95rem;
  color: #374151;
}

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.badge-primary { background: #2563eb; }
.badge-secondary { background: #6b7280; }

.placeholder {
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}
</style>
