<%# app/views/layouts/_sidebar.html.erb %>
<div class="flex flex-col h-full">
  <%# Logo %>
  <div class="flex items-center gap-3 px-6 py-5 border-b border-white/5">
    <div class="w-10 h-10 rounded-xl bg-[#f97316] flex items-center justify-center flex-shrink-0">
      <svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
              d="M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 01-1 1H9m4-1V8a1 1 0 011-1h2.586a1 1 0 01.707.293l3.414 3.414a1 1 0 01.293.707V16a1 1 0 01-1 1h-1m-6-1a1 1 0 001 1h1M5 17a2 2 0 104 0m-4 0a2 2 0 114 0m6 0a2 2 0 104 0m-4 0a2 2 0 114 0"/>
      </svg>
    </div>
    <div>
      <p class="text-white font-bold text-sm leading-tight">Gade Logística</p>
      <p class="text-gray-500 text-xs">Controle de Custos</p>
    </div>
  </div>

  <%# Navegação %>
  <nav class="flex-1 px-3 py-4 space-y-1 overflow-y-auto scrollbar-hidden">

    <%# Dashboard (todos exceto motorista) %>
    <%= nav_link_to 'Dashboard', dashboard_path, icon: :dashboard %>

    <%# Consolidações (admin, gerente, operador) %>
    <% if current_user.pode_criar_consolidacao? %>
      <%= nav_link_to 'Consolidações', consolidacoes_path, icon: :consolidacoes %>
    <% end %>

    <%# Separador Admin %>
    <% if current_user.pode_acessar_admin? %>
      <div class="pt-3 pb-1">
        <p class="px-4 text-xs font-semibold text-gray-600 uppercase tracking-wider">Administração</p>
      </div>

      <%= nav_link_to 'Usuários', usuarios_path, icon: :usuarios %>
      <%= nav_link_to 'Configurações', configuracoes_path, icon: :configuracoes %>
    <% end %>

    <%# PDFs (fase 7 — link desabilitado por enquanto) %>
    <% if current_user.pode_acessar_admin? %>
      <div class="pt-3 pb-1">
        <p class="px-4 text-xs font-semibold text-gray-600 uppercase tracking-wider">Relatórios</p>
      </div>
      <div class="flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium text-gray-600 cursor-not-allowed">
        <%= icone :documento, cor: nil, tamanho: 'w-6 h-6' %>
        <span>Relatórios PDF</span>
        <span class="ml-auto text-[10px] bg-gray-800 text-gray-500 px-1.5 py-0.5 rounded">Em breve</span>
      </div>
    <% end %>
  </nav>

  <%# Footer do sidebar - info do usuário %>
  <div class="px-3 py-4 border-t border-white/5">
    <div class="flex items-center gap-3 px-3 py-3 rounded-xl bg-white/5">
      <div class="w-8 h-8 rounded-full bg-[#f97316]/20 border border-[#f97316]/30
                  flex items-center justify-center text-[#f97316] font-bold text-sm flex-shrink-0">
        <%= current_user.name.to_s[0].upcase %>
      </div>
      <div class="flex-1 min-w-0">
        <p class="text-white text-sm font-medium truncate"><%= current_user.name %></p>
        <p class="text-gray-500 text-xs truncate"><%= current_user.role.humanize %></p>
      </div>
    </div>
  </div>
</div>
