<aside class="sidebar">
  <!-- Sidebar Header -->
  <div class="sidebar-header">
    <div class="sidebar-brand">
      <div class="brand-icon">🏢</div>
      <div class="brand-text">
        <div class="brand-title">PoultryPro</div>
        <div class="brand-subtitle">Management System</div>
      </div>
    </div>
  </div>

  <!-- User Info Section -->
  <div class="user-section">
    <div class="user-info">
      <div class="user-avatar">{{ current_user.name[0].upper() }}</div>
      <div class="user-details">
        <div class="user-name">Hello, {{ current_user.name }}</div>
        <div class="user-role">Role: {{ current_user.role }}</div>
      </div>
    </div>
  </div>

  <!-- Sidebar Navigation -->
  <nav class="sidebar-nav">
    <!-- Dashboard -->
    <div class="nav-item">
      <a class="nav-link {% if request.endpoint == 'dashboard' or request.endpoint == 'dashboard_admin' %}active{% endif %}" href="{{ url_for('dashboard') }}">
        <span class="nav-icon">📊</span>
        <span class="nav-text">Dashboard</span>
      </a>
    </div>

    {% if current_user.role == 'admin' %}
      <!-- Operations -->
      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('purchases_list') }}">
          <span class="nav-icon">📦</span>
          <span class="nav-text">Purchases</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('sales_list') }}">
          <span class="nav-icon">💰</span>
          <span class="nav-text">Sales</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('farms_list') }}">
          <span class="nav-icon">🏭</span>
          <span class="nav-text">Farms</span>
        </a>
      </div>

      <!-- Administration -->
      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('users_list') }}">
          <span class="nav-icon">👥</span>
          <span class="nav-text">Users</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('demand_orders_list') }}">
          <span class="nav-icon">📋</span>
          <span class="nav-text">Demand Orders</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('sale_new') }}">
          <span class="nav-icon">➕</span>
          <span class="nav-text">Create Order</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('purchase_new') }}">
          <span class="nav-icon">📝</span>
          <span class="nav-text">Record Purchase</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('farm_new') }}">
          <span class="nav-icon">🏗️</span>
          <span class="nav-text">Add Farm</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('waste_list') }}">
          <span class="nav-icon">🗑️</span>
          <span class="nav-text">Waste Management</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('reports_home') }}">
          <span class="nav-icon">📈</span>
          <span class="nav-text">Reports</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('list_accounts') }}">
          <span class="nav-icon">🏦</span>
          <span class="nav-text">Cash & Bank</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('accounts_customers') }}">
          <span class="nav-icon">👤</span>
          <span class="nav-text">Customer Accounts</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('farm_accounts') }}">
          <span class="nav-icon">🏭</span>
          <span class="nav-text">Farm Accounts</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('admin_online_payments') }}">
          <span class="nav-icon">💳</span>
          <span class="nav-text">Online Payments</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('admin_expenses') }}">
          <span class="nav-icon">💸</span>
          <span class="nav-text">Expenses</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('admin_payments') }}">
          <span class="nav-icon">💵</span>
          <span class="nav-text">Payments</span>
        </a>
      </div>

    {% elif current_user.role == 'customer' %}
      <!-- Customer Portal -->
      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('demand_orders_list') }}">
          <span class="nav-icon">📋</span>
          <span class="nav-text">Demand Orders</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('sales_list') }}">
          <span class="nav-icon">📦</span>
          <span class="nav-text">My Orders</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('customer_my_ledger') }}">
          <span class="nav-icon">📊</span>
          <span class="nav-text">My Ledger</span>
        </a>
      </div>

      <div class="nav-item">
        <a class="nav-link" href="{{ url_for('online_payment_home') }}">
          <span class="nav-icon">💳</span>
          <span class="nav-text">Online Payment</span>
        </a>
      </div>
    {% endif %}
  </nav>
</aside>