<div class="simple-calendar">
  <div class="calendar-header">
    <div class="sun-info">
      <div class="sun-time sunrise">
        <span class="sun-icon">🌅</span>
        <div class="sun-details">
          <span class="sun-label">Sunrise</span>
          <time><%= sunrise_time(Date.today) %></time>
        </div>
      </div>
      <div class="sun-time sunset">
        <span class="sun-icon">🌆</span>
        <div class="sun-details">
          <span class="sun-label">Sunset</span>
          <time><%= sunset_time(Date.today) %></time>
        </div>
      </div>
    </div>

    <div class="calendar-navigation">
      <%= link_to calendar.url_for_previous_view, class: "nav-btn prev" do %>
        <span class="nav-icon">←</span>
        <span class="nav-text">Previous</span>
      <% end %>

      <div class="current-date">
        <time datetime="<%= start_date.strftime('%Y-%m') %>">
          <span class="month"><%= t('date.month_names')[start_date.month] %></span>
          <span class="year"><%= start_date.year %></span>
        </time>
      </div>

      <%= link_to calendar.url_for_next_view, class: "nav-btn next" do %>
        <span class="nav-text">Next</span>
        <span class="nav-icon">→</span>
      <% end %>
    </div>

    <%= link_to calendar.url_for_today_view, class: "today-btn" do %>
      <span class="today-icon">⦿</span>
      <span class="today-text">Today</span>
    <% end %>
  </div>

  <table class="table table-striped">
    <thead>
      <tr>
        <% date_range.slice(0, 7).each do |day| %>
          <th style="text-align: center;">
            <% rank = Rank.find_by(planet: planet_for_day(day.strftime("%A"))) %>
            <div class="day-header">
              <div class="day-name">
                <%= t('date.abbr_day_names')[day.wday] %> <%= celestial_emoji(planet_for_day(day.strftime("%A"))) %>
              </div>
              <div class="rank-info">
                <div class="rank-type"><%= rank.type_name %></div>
                <div class="time-requirements">
                  <%= time_requirement_icon(rank.time) %>
                  <span class="time-hint"><%= rank.time %></span>
                </div>
              </div>
            </div>
          </th>
        <% end %>
      </tr>
    </thead>

    <tbody>
      <% date_range.each_slice(7) do |week| %>
        <tr>
          <% week.each do |day| %>
            <%= content_tag :td, class: calendar.td_classes_for(day) do %>
              <div class="date-number"><%= day.day %></div>
              <% if current_time_valid?(day) %>
                <% rank = Rank.find_by(planet: planet_for_day(day.strftime("%A"))) %>
                <% if moon_phase_matches?(day) && rank.present? %>
                  <% spirits = Spirit.joins(:rank)
                                  .where(ranks: { planet: planet_for_day(day.strftime("%A")) })
                                  .order('ranks.type_name') %>
                  <% spirits.each do |spirit| %>
                    <div class="spirit-entry" title="<%= spirit.description %>">
                      <strong><%= spirit.name %></strong>
                      <div class="spirit-abilities"><%= spirit.abilities %></div>
                    </div>
                  <% end %>
                <% end %>
              <% else %>
                <div class="time-invalid">Invalid time for summoning</div>
              <% end %>
            <% end %>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
</div>

<style>
.rank-info {
  font-size: 0.8em;
  margin-top: 0.2em;
  padding: 0.2em;
  background: rgba(248, 249, 250, 0.5);
  border-radius: 4px;
}
.time-hint {
  display: block;
  color: #666;
  font-style: italic;
}
.spirit-entry {
  border-left: 3px solid #6c757d;
  margin: 0.5em 0;
  padding: 0.5em;
  font-size: 0.9em;
  background: rgba(248, 249, 250, 0.5);
  border-radius: 0 4px 4px 0;
  transition: all 0.2s ease;
}
.spirit-entry:hover {
  background: rgba(248, 249, 250, 0.8);
  transform: translateX(2px);
}
.spirit-abilities {
  font-size: 0.8em;
  color: #666;
}
.time-invalid {
  color: #dc3545;
  font-style: italic;
  font-size: 0.8em;
  padding: 0.3em;
  background: rgba(220, 53, 69, 0.1);
  border-radius: 4px;
  text-align: center;
}
.date-number {
  float: right;
  color: #adb5bd;
  font-weight: 500;
  font-size: 0.875rem;
}
.calendar-header {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
}
.calendar-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.nav-btn {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: #495057;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.nav-btn:hover {
  background: #e9ecef;
  color: #212529;
  text-decoration: none;
}
.nav-btn.prev .nav-icon {
  margin-right: 0.5rem;
}
.nav-btn.next .nav-icon {
  margin-left: 0.5rem;
}
.current-date {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 500;
  color: #212529;
}
.current-date .month {
  margin-right: 0.5rem;
}
.current-date .year {
  color: #6c757d;
}
.today-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  margin: 0 auto;
  text-decoration: none;
  color: #495057;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  transition: all 0.2s ease;
  width: fit-content;
}
.today-btn:hover {
  background: #e9ecef;
  color: #212529;
  text-decoration: none;
}
.today-icon {
  margin-right: 0.5rem;
  font-size: 0.875rem;
}
.table {
  border-collapse: separate;
  border-spacing: 0.5rem;
}
.table th {
  border: none;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 4px;
}
.table td {
  border: 1px solid #dee2e6;
  padding: 0.75rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.table td:hover {
  background: #f8f9fa;
}
.table td.today {
  background-color: rgba(13, 110, 253, 0.1);
  border-color: rgba(13, 110, 253, 0.3);
}
.table td.prev-month,
.table td.next-month {
  background-color: #f8f9fa;
  opacity: 0.5;
}
.day-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.day-name {
  font-size: 1.1em;
  font-weight: 500;
  color: #212529;
}
.rank-info {
  padding: 0.5rem;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.rank-type {
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.3rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #e9ecef;
}
.time-requirements {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8em;
  color: #6c757d;
}
.time-hint {
  display: block;
  color: #6c757d;
  font-style: italic;
}
.time-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: #f8f9fa;
  border-radius: 50%;
  font-size: 0.9em;
}
.sun-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: linear-gradient(to right, #ffecd2, #fcb69f);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.sun-time {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  transition: transform 0.2s ease;
}
.sun-time:hover {
  transform: translateY(-2px);
}
.sun-icon {
  font-size: 1.5rem;
}
.sun-details {
  display: flex;
  flex-direction: column;
}
.sun-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
}
.sun-details time {
  font-weight: 500;
  color: #212529;
}
</style>
