<%= render "shared/aircraft_header", aircraft: @aircraft %>

<%= t(".flight_on_html", date: (fmt_date(@flight_log.date))) %>

<% if can_edit_flight?(@flight_log) %><%= link_to t(".edit"), edit_aircraft_flight_log_path(@aircraft, @flight_log), class: "btn-secondary btn-sm" %><% end %> <% if can?(:delete_flights) %><%= delete_button t(".delete"), aircraft_flight_log_path(@aircraft, @flight_log), confirm: t(".delete_this_flight_log_aircraft") %><% end %>
<%# One item per row on a phone (label, then value); two columns on wider screens. %>
<%= t(".tach") %>
<%= hours(@flight_log.tach_time) %> <%= "(#{@flight_log.tach_out} → #{@flight_log.tach_in})" if @flight_log.tach_out && @flight_log.tach_in %>
<%= t(".hobbs") %>
<%= hours(@flight_log.hobbs_time) %> <%= "(#{@flight_log.hobbs_out} → #{@flight_log.hobbs_in})" if @flight_log.hobbs_out && @flight_log.hobbs_in %>
<%= t(".route") %>
<%= @flight_log.route_summary.presence || "—" %> <%= @flight_log.route %>
<%= t(".oil_added") %>
<%= @flight_log.oil_added ? "#{@flight_log.oil_added} qt #{@flight_log.oil_added_type}" : "—" %>
<%= t(".fuel_added") %>
<%= @flight_log.fuel_added ? "#{@flight_log.fuel_added} gal #{@flight_log.fuel_added_type}" : "—" %>
<%= t(".pilot") %>
<%= @flight_log.user&.display_name || "—" %>
<%= t(".track_log") %>
<%= @flight_log.track_log.attached? ? link_to(@flight_log.track_log.filename, rails_blob_path(@flight_log.track_log, disposition: :attachment), class: "link") : "—" %> <% if @track %> <%= t(".gps_points_html", points: (number_with_delimiter(@track.points)), max_altitude_ft: (t(".max_ft", max_altitude_ft: (number_with_delimiter(@track.max_altitude_ft))) if @track.max_altitude_ft)) %> <% elsif @track_error %> · <%= @track_error %><% end %>
<% if @air_trail_sync || @air_trail_connection %>
<%= t(".airtrail") %>
<% if @air_trail_sync&.status == "synced" %><%= t(".synced") %> <%= t(".ago_html", synced_at: (time_ago_in_words(@air_trail_sync.synced_at))) %> <% elsif @air_trail_sync&.status == "error" %><%= t(".not_synced") %> <%= @air_trail_sync.last_error %> <% else %><%= t(".pending") %><% end %>
<% end %>
<% if @flight_log.notes.present? %>
<%= simple_format @flight_log.notes %>
<% end %>
<%= render "engine_data", flight_log: @flight_log, recording: @engine_data, error: @engine_data_error %>